-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathmain.py
More file actions
31 lines (22 loc) · 1.08 KB
/
main.py
File metadata and controls
31 lines (22 loc) · 1.08 KB
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
30
31
from ncatbot.core import BotClient, GroupMessage, PrivateMessage
from ncatbot.utils import ncatbot_config, get_log
_log = get_log()
ncatbot_config.set_bot_uin("123456") # 设置 bot qq 号 (必填)
ncatbot_config.set_root("123456") # 设置 bot 超级管理员账号 (建议填写)
ncatbot_config.set_ws_uri("ws://localhost:3001") # 设置 napcat websocket server 地址
ncatbot_config.set_ws_token("napcat_ws") # 设置 token (websocket 的 token)
ncatbot_config.set_webui_uri("http://localhost:6099") # 设置 napcat webui 地址
ncatbot_config.set_webui_token("napcat_webui") # 设置 token (webui 的 token)
bot = BotClient()
@bot.on_group_message()
async def on_group_message(msg: GroupMessage):
_log.info(msg)
if msg.raw_message == "测试":
await msg.reply(text="NcatBot 测试成功喵~")
@bot.on_private_message()
def on_private_message(msg: PrivateMessage):
_log.info(msg)
if msg.raw_message == "测试":
bot.api.post_private_msg_sync(msg.user_id, text="NcatBot 测试成功喵~")
if __name__ == "__main__":
bot.run()