How to use the aiocqhttp.CQHttp function in aiocqhttp

To help you get started, we’ve selected a few aiocqhttp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github richardchien / python-aiocqhttp / demo.py View on Github external
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 插件,走快速回复途径
github BoYanZh / QQGroupRepeater / coolq.py View on Github external
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)