-
Notifications
You must be signed in to change notification settings - Fork 1
/
bot_main.py
27 lines (18 loc) · 1.09 KB
/
bot_main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import bot_api
from bot_api.utils import yaml_util
token = yaml_util.read('config.yaml')
bot = bot_api.BotApp(token['bot']['id'], token['bot']['token'], token['bot']['secret'],
is_sandbox=True, debug=True, api_return_pydantic=True,
inters=[bot_api.Intents.GUILDS, bot_api.Intents.AT_MESSAGES, bot_api.Intents.GUILD_MEMBERS])
@bot.receiver(bot_api.structs.Codes.SeverCode.BotGroupAtMessage)
def get_at_message(chain: bot_api.structs.Message):
bot.logger(f"收到来自频道:{chain.guild_id} 子频道: {chain.channel_id} "
f"内用户: {chain.author.username}({chain.author.id}) 的消息: {chain.content} ({chain.id})")
if "你好" in chain.content:
bot.api_send_reply_message(chain.channel_id, chain.id, "hello world!")
elif "test" in chain.content:
bot.api_send_reply_message(chain.channel_id, chain.id, "chieri在哟~")
elif "/echo" in chain.content:
reply = chain.content[chain.content.find("/echo") + len("/echo"):].strip()
bot.api_send_reply_message(chain.channel_id, chain.id, reply)
bot.start()