This repository has been archived by the owner on Jan 15, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathSoamManager.cs
229 lines (226 loc) · 9.82 KB
/
SoamManager.cs
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
227
228
229
using CNBlackListSoamChecker.DbManager;
using ReimuAPI.ReimuBase;
using ReimuAPI.ReimuBase.TgData;
namespace CNBlackListSoamChecker.CommandObject
{
class SoamManager
{
public void SoamEnable(TgMessage message)
{
if (!TgApi.getDefaultApiConnection().checkIsAdmin(message.chat.id, message.from.id))
{
TgApi.getDefaultApiConnection().sendMessage(message.chat.id, "您不是这个群组的管理员,无法执行此操作。", message.message_id);
return;
}
string enabled = "";
string otherMsg = "";
int AdminOnly = 3;
int Blacklist = 3;
int AutoKick = 3;
int AntiHalal = 3;
int AutoDeleteSpamMessage = 3;
int AutoDeleteCommand = 3;
int SubscribeBanList = 3;
string text = message.text.ToLower();
if (text.IndexOf(" adminonly") != -1)
{
AdminOnly = 0;
enabled += " AdminOnly";
}
if (text.IndexOf(" blacklist") != -1)
{
Blacklist = 0;
if (Temp.DisableBanList)
{
otherMsg += "\nBlackList 开启失败,因为当前的编译已经禁用封禁用户的功能。";
}
else
{
enabled += " Blacklist";
}
}
if (text.IndexOf(" autokick") != -1)
{
AutoKick = 0;
if (Temp.DisableBanList)
{
otherMsg += "\nAutoKick 开启失败,因为当前的编译已经禁用封禁用户的功能。";
}
else
{
enabled += " AutoKick";
}
}
if (text.IndexOf(" antihalal") != -1)
{
AntiHalal = 0;
enabled += " AntiHalal";
}
if (text.IndexOf(" autodeletespammessage") != -1)
{
AutoDeleteSpamMessage = 0;
if (Temp.DisableBanList)
{
otherMsg += "\nAutoDeleteSpamMessage 开启失败,因为当前的编译已经禁用封禁用户的功能。";
}
else
{
enabled += " AutoDeleteSpamMessage";
}
}
if (text.IndexOf(" autodeletecommand") != -1)
{
AutoDeleteCommand = 0;
enabled += " AutoDeleteCommand";
}
if (text.IndexOf(" subscribebanlist") != -1)
{
SubscribeBanList = 0;
if (Temp.DisableBanList)
{
otherMsg += "\nSubscribeBanList 开启失败,因为当前的编译已经禁用封禁用户的功能。";
}
else
{
enabled += " SubscribeBanList";
}
enabled += " SubscribeBanList";
}
Temp.GetDatabaseManager().SetGroupConfig(
message.chat.id,
AdminOnly: AdminOnly,
BlackList: Blacklist,
AutoKick: AutoKick,
AntiHalal: AntiHalal,
AutoDeleteSpamMessage: AutoDeleteSpamMessage,
AutoDeleteCommand: AutoDeleteCommand,
SubscribeBanList: SubscribeBanList
);
if (enabled == "")
{
if (Temp.MainChannelName == null)
{
enabled = "[[null]]\n\n请您使用 /soamenable [所需的功能] 来启用您需要的功能。\n" +
"例如: \"/soamenable BlackList\" (不包含引号) 则可以启用黑名单列表警告。\n" +
"您也可以使用多个选项,例如: \"/soamenable BlackList AutoKick\" (不包含引号) " +
"则可以启用黑名单列表警告,在警告后还会将成员移出群组。\n\n" +
"您可以使用 /soamstatus 查看当前群组开启或关闭了的功能。";
}
else
{
enabled = "[[null]]\n\n请您使用 /soamenable [所需的功能] 来启用您需要的功能。\n" +
"例如: \"/soamenable BlackList\" (不包含引号) 则可以启用由 @" + Temp.MainChannelName + " 提供的黑名单列表警告。\n" +
"您也可以使用多个选项,例如: \"/soamenable BlackList AutoKick\" (不包含引号) " +
"则可以启用由 @" + Temp.MainChannelName + " 提供的黑名单列表警告,在警告后还会将成员移出群组。\n\n" +
"您可以使用 /soamstatus 查看当前群组开启或关闭了的功能。";
}
}
TgApi.getDefaultApiConnection().sendMessage(message.chat.id, "成功,开启了的功能有: " + enabled + otherMsg, message.message_id);
return;
}
public void SoamDisable(TgMessage message)
{
if (!TgApi.getDefaultApiConnection().checkIsAdmin(message.chat.id, message.from.id))
{
TgApi.getDefaultApiConnection().sendMessage(message.chat.id, "您不是这个群组的管理员,无法执行此操作。", message.message_id);
return;
}
string enabled = "";
int AdminOnly = 3;
int Blacklist = 3;
int AutoKick = 3;
int AntiHalal = 3;
int AutoDeleteSpamMessage = 3;
int AutoDeleteCommand = 3;
int SubscribeBanList = 3;
string text = message.text.ToLower();
if (text.IndexOf(" adminonly") != -1)
{
AdminOnly = 1;
enabled += " AdminOnly";
}
if (text.IndexOf(" blacklist") != -1)
{
Blacklist = 1;
enabled += " Blacklist";
}
if (text.IndexOf(" autokick") != -1)
{
AutoKick = 1;
enabled += " AutoKick";
}
if (text.IndexOf(" antihalal") != -1)
{
AntiHalal = 1;
enabled += " AntiHalal";
}
if (text.IndexOf(" autodeletespammessage") != -1)
{
AutoDeleteSpamMessage = 1;
enabled += " AutoDeleteSpamMessage";
}
if (text.IndexOf(" autodeletecommand") != -1)
{
AutoDeleteCommand = 1;
enabled += " AutoDeleteCommand";
}
if (text.IndexOf(" subcribebanlist") != -1)
{
SubscribeBanList = 1;
enabled += " SubscribeBanList";
}
Temp.GetDatabaseManager().SetGroupConfig(
message.chat.id,
AdminOnly: AdminOnly,
BlackList: Blacklist,
AutoKick: AutoKick,
AntiHalal: AntiHalal,
AutoDeleteSpamMessage: AutoDeleteSpamMessage,
AutoDeleteCommand: AutoDeleteCommand,
SubscribeBanList: SubscribeBanList
);
if (enabled == "")
{
if (Temp.MainChannelName == null)
{
enabled = "[[null]]\n\n请您使用 /soamdisable [所需的功能] 来禁用您需要的功能。\n" +
"例如: \"/soamdisable BlackList\" (不包含引号) 则可以禁用黑名单列表警告。\n" +
"您也可以使用多个选项,例如: \"/soamdisable BlackList AutoKick\" (不包含引号) " +
"则可以禁用黑名单列表警告,并禁用在警告后将成员移出群组的功能。" +
"您可以使用 /soamstatus 查看当前群组开启或关闭了的功能。";
}
else
{
enabled = "[[null]]\n\n请您使用 /soamdisable [所需的功能] 来禁用您需要的功能。\n" +
"例如: \"/soamdisable BlackList\" (不包含引号) 则可以禁用由 @" + Temp.MainChannelName + " 提供的黑名单列表警告。\n" +
"您也可以使用多个选项,例如: \"/soamdisable BlackList AutoKick\" (不包含引号) " +
"则可以禁用由 @" + Temp.MainChannelName + " 提供的黑名单列表警告,并禁用在警告后将成员移出群组的功能。" +
"您可以使用 /soamstatus 查看当前群组开启或关闭了的功能。";
}
}
TgApi.getDefaultApiConnection().sendMessage(message.chat.id, "成功,关闭了的功能有: " + enabled, message.message_id);
return;
}
public void SoamStatus(TgMessage message)
{
string byChannelName = "";
if (Temp.MainChannelName != null)
{
byChannelName = " (by @CNBlackList )";
}
GroupCfg gc = Temp.GetDatabaseManager().GetGroupConfig(message.chat.id);
TgApi.getDefaultApiConnection().sendMessage(
message.chat.id,
"BlackList" + byChannelName + ": " + (gc.BlackList == 0) + "\n" +
"AutoKick: " + (gc.AutoKick == 0) + "\n" +
"AntiHalal: " + (gc.AntiHalal == 0) + "\n" +
"AutoDeleteSpamMessage: " + (gc.AutoDeleteSpamMessage == 0) + "\n" +
"AutoDeleteCommand: " + (gc.AutoDeleteCommand == 0) + "\n" +
"AdminOnly: " + (gc.AdminOnly == 0) + "\n" +
"SubscribeBanList: " + (gc.SubscribeBanList == 0),
message.message_id
);
return;
}
}
}