mirror of
https://github.com/nonebot/nonebot2.git
synced 2024-11-28 03:15:24 +08:00
Update something
This commit is contained in:
parent
fc89aa847c
commit
e215da8a1d
@ -1,3 +1,5 @@
|
|||||||
|
import os
|
||||||
|
|
||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
@ -16,4 +18,4 @@ class ApiClient:
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
client = ApiClient('http://127.0.0.1:5000/openqq')
|
client = ApiClient(os.environ.get('QQ_API_URL'))
|
||||||
|
2
app.py
2
app.py
@ -107,4 +107,4 @@ def _load_commands():
|
|||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
_load_commands()
|
_load_commands()
|
||||||
app.run(host='127.0.0.1', port=8888)
|
app.run(host=os.environ.get('HOST'), port=os.environ.get('PORT'))
|
||||||
|
29
commands/todayinhistory.py
Normal file
29
commands/todayinhistory.py
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
import requests
|
||||||
|
from lxml import etree
|
||||||
|
|
||||||
|
from command import CommandRegistry
|
||||||
|
from commands import core
|
||||||
|
|
||||||
|
__registry__ = cr = CommandRegistry()
|
||||||
|
|
||||||
|
|
||||||
|
@cr.register('today_in_history', '历史上的今天')
|
||||||
|
def today_in_history(_, ctx_msg):
|
||||||
|
core.echo('正在查询,请稍等……', ctx_msg)
|
||||||
|
resp = requests.get('http://tool.lu/todayonhistory/')
|
||||||
|
ok = False
|
||||||
|
if resp.status_code == 200:
|
||||||
|
html = etree.HTML(resp.text)
|
||||||
|
li_elems = html.xpath('//ul[@id="tohlis"]/li')
|
||||||
|
# reply = reduce(lambda x, y: x.text + '\n' + y.text, li_elems)
|
||||||
|
step = 10
|
||||||
|
for start in range(0, len(li_elems), step):
|
||||||
|
reply = ''
|
||||||
|
for item in li_elems[start:start + step]:
|
||||||
|
reply += item.text + '\n'
|
||||||
|
reply = reply.rstrip()
|
||||||
|
core.echo(reply, ctx_msg)
|
||||||
|
core.echo('以上~', ctx_msg)
|
||||||
|
ok = True
|
||||||
|
if not ok:
|
||||||
|
core.echo('很抱歉,网络出错了……建议等会儿再试吧~', ctx_msg)
|
@ -147,7 +147,7 @@ def _subscribe_interactively(args_text, ctx_msg, source):
|
|||||||
if s.data['need_confirm']:
|
if s.data['need_confirm']:
|
||||||
if a.strip() != '1':
|
if a.strip() != '1':
|
||||||
# Cancel
|
# Cancel
|
||||||
core.echo('已放弃更改~')
|
core.echo('已放弃更改~', c)
|
||||||
return True
|
return True
|
||||||
core.echo('请发送想要获取推送的时间(格式如 20:05):', c)
|
core.echo('请发送想要获取推送的时间(格式如 20:05):', c)
|
||||||
s.state += 1
|
s.state += 1
|
||||||
|
Loading…
Reference in New Issue
Block a user