Skip to content

Commit 925bd8b

Browse files
committed
Update
1 parent e43c286 commit 925bd8b

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

libs/ignore.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
#黑名单,遇到以下uid直接忽略
22
global ban_uid
33
ban_uid=['3546377875360540','3546632014531086']
4+
#屏蔽消息类型,遇到以下类型直接忽略
5+
global ban_type
6+
ban_type=["STOP_LIVE_ROOM_LIST","NOTICE_MSG","VIEW"]

main.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@
1010
from libs import inital_command,schedule
1111

1212
skip=False
13+
1314
def load_config():
1415
global vcbot_api
1516
vcbot_api={"send_msg": send_msgs ,"exception": vcbot_plugin_DoNotContinue,"ban_uid":ignore.ban_uid}
1617
config.loadroomcfg()
1718
vcbot_api["roomcfg"]=config.roomcfg
19+
1820
def load_plugin():
1921
for file in os.listdir("plugins"):
2022
if file.endswith(".py") and file!="__init__.py":
@@ -50,10 +52,11 @@ def send_msgs(text:str):
5052
logger.info(f'send:{text}')
5153
sync(live.send_danmu(text))
5254

53-
@logger.catch
5455
def listen():
5556
@live.LiveDanma.on("ALL")
5657
async def event(event:str):
58+
if event["type"] in ignore.ban_type: # 屏蔽一些乱七八糟的类型段
59+
return
5760
logger.debug(f'收到事件:\n{json.dumps(event,ensure_ascii=False)}')
5861
await plugins_event(event)
5962
return
@@ -63,23 +66,29 @@ async def event(event:str):
6366
sync(live.LiveDanma.connect())
6467
finally:
6568
sync(live.LiveDanma.disconnect())
66-
schedule.close()
69+
threading.Thread(target=schedule.close).start()
6770
os._exit(0)
6871

6972
class vcbot_plugin_DoNotContinue(Exception):
7073
def __init__(self,msg:str=None):
7174
self.msg=msg
7275
skip=True
7376

74-
if __name__ == '__main__':
77+
@logger.catch
78+
def main():
7579
logger.info("Starting...")
7680
today=datetime.date.today()
7781
logger.add(f"logs/log-{today}.log",rotation="1 day",encoding="utf-8",format="{time} {level}-{function} {message}")
7882
load_config()
7983
user.user_login()
84+
live.set(config.room,user.c)
8085
botuid=user.get_self_uid(user.c)
86+
live_room_owner_uid=live.owner_uid
8187
vcbot_api["bot_uid"]=botuid
82-
live.set(config.room,user.c)
88+
vcbot_api["room_owner_uid"]=live_room_owner_uid
8389
load_plugin()
8490
threading.Thread(target=schedule.start).start()
85-
listen()
91+
listen()
92+
93+
if __name__ == "__main__":
94+
main()

0 commit comments

Comments
 (0)