This repository has been archived by the owner on Oct 18, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathhandleins.py
226 lines (216 loc) · 9.12 KB
/
handleins.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
import miraicle
import random
import os
import json
import emoji
import base64
def handle_ins(
ins: str,
argv: list,
bot: miraicle,
msg: miraicle.GroupMessage,
config: dict,
load_dict: dict,
):
if load_dict.get(str(msg.group)) == None or load_dict[str(msg.group)] == 1:
match ins:
case "在线编译":
try:
from plugins.onlinecompile import Compile
from plugins.banwords import BanWord
raw_info = Compile(
argv[1], argv[0], config["plugin"]["OnlineCompile"]
)
info = ""
for index in range(len(raw_info)):
info += raw_info[index]
info = info[:256]
if info.count("\n") > 8:
info = "请勿滥用本bot恶意刷屏"
except Exception as e:
info = str(e)
finally:
bot.send_group_msg(
msg.group, msg=[miraicle.MiraiCode(BanWord(info))]
)
case "查云黑":
from plugins.blacklist import IsBlacklisted
bot.send_group_msg(
msg.group, msg=[miraicle.Plain(IsBlacklisted(argv[0]))]
)
case "每日一题":
url = "https://www.luogu.com.cn/problem/P" + str(
random.randint(1000, 8308)
)
bot.send_group_msg(msg.group, msg=[miraicle.Plain(url)])
case "警告":
from plugins.warn import WarnMember
if (
bot.is_administrator(msg.sender, msg.group) == True
or config["Master"] == msg.sender
) and len(msg.chain) == 3:
WarnMember(
str(msg.group),
str(msg.chain[1].qq),
str(msg.sender),
msg.chain[2].text,
)
else:
bot.send_group_msg(msg.group, msg=[miraicle.Plain("你没有权限或语法错误。")])
case "查警告":
from plugins.warn import NumberOfWarnings
bot.send_group_msg(
msg.group,
msg=[
miraicle.MiraiCode(
NumberOfWarnings(str(msg.group), str(msg.chain[1].qq))
)
],
)
case "冷更新":
if config["Master"] == msg.sender:
bot.send_group_msg(msg.group, msg=[miraicle.Plain("bot已经停止运作!")])
os._exit(0)
case "LIST":
output = ""
buffer = bot.group_list()
for i in range(0, len(buffer["data"])):
output += (
buffer["data"][i]["name"]
+ "("
+ str(buffer["data"][i]["id"])
+ ")"
)
output += "\t"
output += buffer["data"][i]["permission"]
output += "\n"
bot.send_group_msg(msg.group, msg=[miraicle.Plain(output)])
case "来只兽":
from plugins.randomfurryimg import GetRandomFurryImg
if len(argv) == 0:
dataSet = GetRandomFurryImg(
config["plugin"]["E621"], "changed_(video_game)"
)
bot.send_group_msg(
msg.group,
msg=[
miraicle.Image(url=dataSet["url"]),
miraicle.Plain(
"sources:"
+ json.dumps(dataSet["sources"])
+ "\nid:"
+ str(dataSet["id"])
),
],
)
else:
dataSet = GetRandomFurryImg(
config["plugin"]["E621"], "+".join(argv)
)
bot.send_group_msg(
msg.group,
msg=[
miraicle.Image(url=dataSet["url"]),
miraicle.Plain(
"sources:"
+ json.dumps(dataSet["sources"])
+ "\nid:"
+ str(dataSet["id"])
),
],
)
case "来个meme":
from plugins.randomvideo import GetRanDomVideo
if len(argv) == 0:
buffer = GetRanDomVideo(config["plugin"]["randomvideo"])
else:
buffer = GetRanDomVideo({"fav_id": argv[0]})
bot.send_group_msg(msg.group, msg=[miraicle.Plain(buffer)])
case "设定上传":
from plugins.fursonahandle import AddFursona
from plugins.fursonahandle import SaveImg
from plugins.fursonahandle import RetSomebodyFursonaProfile
if (
RetSomebodyFursonaProfile(argv[0]) == None
or RetSomebodyFursonaProfile(argv[0])["Owner"] == msg.sender
):
if (
len(msg.chain) == 3
and AddFursona(
argv[0],
msg.sender,
argv[1],
SaveImg(msg.chain[1].url, argv[0], msg.chain[1].image_id),
)
!= True
):
bot.send_group_msg(msg.group, msg=[miraicle.Plain("发生错误")])
if (
len(msg.chain) == 1
and AddFursona(argv[0], msg.sender, argv[1], None) != True
):
bot.send_group_msg(msg.group, msg=[miraicle.Plain("发生错误")])
if (
len(msg.chain) == 2
and AddFursona(
argv[0],
msg.sender,
None,
SaveImg(msg.chain[1].url, argv[0], msg.chain[1].image_id),
)
!= True
):
bot.send_group_msg(msg.group, msg=[miraicle.Plain("发生错误")])
else:
bot.send_group_msg(msg.group, msg=[miraicle.Plain("你没有权限。")])
case "设定":
from plugins.fursonahandle import RetSomebodyFursonaProfile
if len(argv) == 0:
root = r"./plugins/database/"
files_list = os.listdir(root)
filter_files_list = [fn for fn in files_list if fn.endswith("json")]
files_list = [os.path.join(root, fn) for fn in files_list]
argv.append(
base64.b64decode(
os.path.basename(
files_list[random.randint(0, len(files_list) - 1)]
).split(".")[0]
).decode()
)
print(argv[0])
data = RetSomebodyFursonaProfile(argv[0])
if data == None:
bot.send_group_msg(
msg.group, msg=[miraicle.Plain("没有叫%s的兽兽!" % argv[0])]
)
return
master = miraicle.Plain(
emoji.emojize("\n[主人::paw_prints:%s:paw_prints:]" % data["Owner"])
)
cub = miraicle.Plain(emoji.emojize(":star:%s:star:\n" % argv[0]))
if data["Img"] == None:
output = [cub, miraicle.Plain(data["Desc"]), master]
elif data["Desc"] == None:
output = [
cub,
miraicle.Image.from_url(
r"file:///%s/plugins/database/%s"
% (os.getcwd(), data["Img"])
),
master,
]
else:
output = [
cub,
miraicle.Plain(data["Desc"]),
miraicle.Image.from_url(
r"file:///%s/plugins/database/%s"
% (os.getcwd(), data["Img"])
),
master,
]
bot.send_group_msg(msg.group, msg=output)
case _:
bot.send_group_msg(msg.group, msg=[miraicle.Plain("未知指令:" + ins)])
else:
bot.send_group_msg(msg.group, msg=[miraicle.Plain("主人已设置不响应")], quote=msg.id)