예제 #1
0
async def hello_handler(bot: DingBot, event: MessageEvent):
    message = MessageSegment.raw({
        "msgtype": "text",
        "text": {
            "content": 'hello '
        },
    })
    message += MessageSegment.atDingtalkIds(event.senderId)
    await hello.send(message)

    message = MessageSegment.text(f"@{event.senderId},你好")
    message += MessageSegment.atDingtalkIds(event.senderId)
    await hello.finish(message)
async def webhook_handler(bot: DingBot, event: MessageEvent):
    print(event)
    message = MessageSegment.raw({
        "msgtype": "text",
        "text": {
            "content": 'hello from webhook,一定要注意安全方式的鉴权哦,否则可能发送失败的'
        },
    })
    message += MessageSegment.atDingtalkIds(event.senderId)
    await hello.send(
        message,
        webhook=
        "https://oapi.dingtalk.com/robot/send?access_token=XXXXXXXXXXXXXX",
        secret="SECXXXXXXXXXXXXXXXXXXXXXXXXX")

    message = MessageSegment.text("TEST 123123  S")
    await hello.send(
        message,
        webhook=
        "https://oapi.dingtalk.com/robot/send?access_token=XXXXXXXXXXXXXX",
    )
예제 #3
0
async def atme_handler(bot: DingBot, event: MessageEvent):
    message = f"@{event.senderId} manually at you" + MessageSegment.atDingtalkIds(
        event.senderId)
    await atme.send("matcher send auto at you", at_sender=True)
    await bot.send(event, "bot send auto at you", at_sender=True)
    await atme.finish(message)