-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathmain.py
29 lines (20 loc) · 839 Bytes
/
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
28
29
from ncatbot.core import BotClient, GroupMessage, PrivateMessage
from ncatbot.utils.config import config
from ncatbot.utils.logger import get_log
_log = get_log()
config.set_bot_uin("123456") # 设置 bot qq 号 (必填)
config.set_ws_uri("ws://localhost:3001") # 设置 napcat websocket server 地址
config.set_token("") # 设置 token (napcat 服务器的 token)
bot = BotClient()
@bot.group_event()
async def on_group_message(msg: GroupMessage):
_log.info(msg)
if msg.raw_message == "测试":
await msg.reply(text="NcatBot 测试成功喵~")
@bot.private_event()
async def on_private_message(msg: PrivateMessage):
_log.info(msg)
if msg.raw_message == "测试":
await bot.api.post_private_msg(msg.user_id, text="NcatBot 测试成功喵~")
if __name__ == "__main__":
bot.run(reload=False)