-
Notifications
You must be signed in to change notification settings - Fork 2
/
main.py
51 lines (43 loc) · 2.12 KB
/
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import os
import pytz
import qqbot
from apscheduler.schedulers.background import BackgroundScheduler
from qqbot.core.util.yaml_util import YamlUtil
from cronjob.dragon import cron_add_dragon_coin
from handler.at_message import at_message_handler
from handler.member_event import guild_member_event_handler
from handler.message import message_handler
# ___====-_ _-====___
# _--^^^#####// \\#####^^^--_
# _-^##########// ( ) \\##########^-_
# -############// |\^^/| \\############-
# _/############// (@::@) \\############\_
# /#############(( \\// ))#############\
# -###############\\ (oo) //###############-
# -#################\\ / VV \ //#################-
# -###################\\/ \//###################-
# _#/|##########/\######( /\ )######/\##########|\#_
# |/ |#/\#/\#/\/ \#/\##\ | | /##/\#/ \/\#/\#/\#| \|
# ` |/ V V ` V \#\| | | |/#/ V ' V V \| '
# ` ` ` ` / | | | | \ ' ' ' '
# ( | | | | )
# __\ | | | | /__
# (vvv(VVV)(VVV)vvv)
# 神兽保佑 神龙在此
# 代码无BUG! 代码坚不可摧!
# SOLID CODE
if __name__ == '__main__':
config = YamlUtil.read(os.path.join(os.path.dirname(__file__), "config.yaml"))
token = qqbot.Token(config["token"]["appid"], config["token"]["token"])
# 普通消息
message_handler = qqbot.Handler(qqbot.HandlerType.MESSAGE_EVENT_HANDLER, message_handler)
# 被@的消息
at_message_handler = qqbot.Handler(qqbot.HandlerType.AT_MESSAGE_EVENT_HANDLER, at_message_handler)
# 成员信息更新
guild_member_event_handler = qqbot.Handler(qqbot.HandlerType.GUILD_MEMBER_EVENT_HANDLER, guild_member_event_handler)
# 定时任务
scheduler = BackgroundScheduler(timezone=pytz.timezone('Asia/Shanghai'))
scheduler.add_job(cron_add_dragon_coin, 'cron', hour='8', minute='1')
scheduler.start()
# 注册消息处理器并启动
qqbot.async_listen_events(token, False, message_handler, at_message_handler)