Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
from aiocqhttp import CQHttp, ApiError
bot = CQHttp(api_root='http://127.0.0.1:5700/',
access_token='123',
secret='abc')
@bot.on_message
# 上面这句等价于 @bot.on('message')
async def handle_msg(context):
# 下面这句等价于 bot.send_private_msg(user_id=context['user_id'], message='你好呀,下面一条是你刚刚发的:')
try:
await bot.send(context, '你好呀,下面一条是你刚刚发的:')
except ApiError:
pass
return {'reply': context['message'],
'at_sender': False} # 返回给 HTTP API 插件,走快速回复途径
from util import load_json, purgeMsg
from datetime import datetime, timezone, timedelta
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from apscheduler.triggers.cron import CronTrigger
from queue import Queue
logging.basicConfig(
level=logging.INFO,
format=
'%(asctime)s %(filename)s[line:%(lineno)d] %(levelname)s %(message)s',
datefmt='%Y-%m-%d %H:%M:%S',
filename=os.path.join(os.path.abspath(os.path.dirname(__file__)),
'coolq.log'),
filemode='w+')
bot = CQHttp(api_root='http://127.0.0.1:5700/')
app = bot.server_app
GroupDict = dict()
SETTINGS = load_json('settings.json')
REPLY = load_json('data/reply.json')
msgQueue = Queue()
@app.route('/danmu/coolq')
async def danmu():
re = []
while not msgQueue.empty():
re.append(msgQueue.get())
return jsonify(re)