This repository has been archived by the owner on Feb 23, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
notice.py
99 lines (82 loc) · 2.71 KB
/
notice.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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
# 此源代码的使用受 GNU AFFERO GENERAL PUBLIC LICENSE version 3 许可证的约束, 您可以在下面的链接找到该许可证.
# https://github.com/weilinfox/py-hakuBot/blob/main/LICENSE
"""
notice 配置
自定义入群欢迎
设置 入群欢迎 notice 功能 pastebin 上传 打开与关闭
"""
import haku_router.notice as notice
import haku_data.method
configDict = haku_data.method.get_config_dict()
serverConfig = configDict.get('server_config', {})
hakuConfig = configDict.get('haku_config', {})
INDEX = hakuConfig.get('index', '.')
ADMINQID = hakuConfig.get('admin_qq', 0)
ADMINGID = hakuConfig.get('admin_group', 0)
def handle_help():
return f'''notice 配置
{INDEX}notice [greet msg | on fun | off fun | show fun] [gid]
greet msg: 自定义入群欢迎消息
on fun: 打开功能
off fun: 关闭功能
show fun: 显示功能状态
fun:
greet: 入群欢迎
pb: 群新文件自动 pb 上传
notice: 整个 notice 功能
gid:
操作的群号,默认当前群,指定群需要 bot 管理权限
'''
def handle_greet(gid, msg):
if notice.notice_update_greetmsg(gid, msg):
return f'更新成功: {msg}'
else:
return '更新失败'
def handle_on(gid, fun):
if fun == 'pb':
fun = 'pastebin'
if notice.notice_update_block(gid, fun, False):
return '打开成功'
else:
return '打开失败'
def handle_off(gid, fun):
if fun == 'pb':
fun = 'pastebin'
if notice.notice_update_block(gid, fun, True):
return '关闭成功'
else:
return '关闭失败'
def handle_show(gid, fun):
if fun == 'pb':
fun = 'pastebin'
flag = '关闭' if notice.notice_check_block(gid, fun) else '打开'
msg = f'状态: {flag}'
if fun == 'greet':
msg = f'{msg}\n消息: {notice.notice_get_greet(gid)}'
return msg
def main(msgDict):
com = msgDict['message'].split()
if len(com) <= 2:
return handle_help()
else:
if msgDict['message_type'] == 'group':
gid = msgDict['group_id']
isadmin = ADMINQID == msgDict['user_id'] or ADMINGID == gid
else:
gid = 0
isadmin = ADMINQID == msgDict['user_id']
if isadmin:
try: gid = int(com[3])
except: pass
if not gid:
return '不被支持的私聊配置'
if com[1] == 'greet':
return handle_greet(gid, com[2])
elif com[1] == 'on':
return handle_on(gid, com[2])
elif com[1] == 'off':
return handle_off(gid, com[2])
elif com[1] == 'show':
return handle_show(gid, com[2])
else:
return f'非法命令: {com[1]}'