10
10
from libs import inital_command ,schedule
11
11
12
12
skip = False
13
+
13
14
def load_config ():
14
15
global vcbot_api
15
16
vcbot_api = {"send_msg" : send_msgs ,"exception" : vcbot_plugin_DoNotContinue ,"ban_uid" :ignore .ban_uid }
16
17
config .loadroomcfg ()
17
18
vcbot_api ["roomcfg" ]= config .roomcfg
19
+
18
20
def load_plugin ():
19
21
for file in os .listdir ("plugins" ):
20
22
if file .endswith (".py" ) and file != "__init__.py" :
@@ -50,10 +52,11 @@ def send_msgs(text:str):
50
52
logger .info (f'send:{ text } ' )
51
53
sync (live .send_danmu (text ))
52
54
53
- @logger .catch
54
55
def listen ():
55
56
@live .LiveDanma .on ("ALL" )
56
57
async def event (event :str ):
58
+ if event ["type" ] in ignore .ban_type : # 屏蔽一些乱七八糟的类型段
59
+ return
57
60
logger .debug (f'收到事件:\n { json .dumps (event ,ensure_ascii = False )} ' )
58
61
await plugins_event (event )
59
62
return
@@ -63,23 +66,29 @@ async def event(event:str):
63
66
sync (live .LiveDanma .connect ())
64
67
finally :
65
68
sync (live .LiveDanma .disconnect ())
66
- schedule .close ()
69
+ threading . Thread ( target = schedule .close ). start ()
67
70
os ._exit (0 )
68
71
69
72
class vcbot_plugin_DoNotContinue (Exception ):
70
73
def __init__ (self ,msg :str = None ):
71
74
self .msg = msg
72
75
skip = True
73
76
74
- if __name__ == '__main__' :
77
+ @logger .catch
78
+ def main ():
75
79
logger .info ("Starting..." )
76
80
today = datetime .date .today ()
77
81
logger .add (f"logs/log-{ today } .log" ,rotation = "1 day" ,encoding = "utf-8" ,format = "{time} {level}-{function} {message}" )
78
82
load_config ()
79
83
user .user_login ()
84
+ live .set (config .room ,user .c )
80
85
botuid = user .get_self_uid (user .c )
86
+ live_room_owner_uid = live .owner_uid
81
87
vcbot_api ["bot_uid" ]= botuid
82
- live . set ( config . room , user . c )
88
+ vcbot_api [ "room_owner_uid" ] = live_room_owner_uid
83
89
load_plugin ()
84
90
threading .Thread (target = schedule .start ).start ()
85
- listen ()
91
+ listen ()
92
+
93
+ if __name__ == "__main__" :
94
+ main ()
0 commit comments