Index: trunk/tools/wmib/Core.cs |
— | — | @@ -11,6 +11,7 @@ |
12 | 12 | using System; |
13 | 13 | using System.Collections.Generic; |
14 | 14 | using System.IO; |
| 15 | +using System.Text.RegularExpressions; |
15 | 16 | |
16 | 17 | namespace wmib |
17 | 18 | { |
— | — | @@ -22,7 +23,7 @@ |
23 | 24 | |
24 | 25 | try |
25 | 26 | { |
26 | | - System.Text.RegularExpressions.Regex.Match("", pattern); |
| 27 | + Regex.Match("", pattern); |
27 | 28 | } |
28 | 29 | catch (ArgumentException) |
29 | 30 | { |
— | — | @@ -88,7 +89,7 @@ |
89 | 90 | |
90 | 91 | private void Run() |
91 | 92 | { |
92 | | - System.Text.RegularExpressions.Regex c = new System.Text.RegularExpressions.Regex(regex); |
| 93 | + Regex c = new Regex(regex); |
93 | 94 | result = c.Match(value).Success; |
94 | 95 | searching = false; |
95 | 96 | } |
— | — | @@ -172,7 +173,7 @@ |
173 | 174 | |
174 | 175 | public static string normalize(string name) |
175 | 176 | { |
176 | | - name = System.Text.RegularExpressions.Regex.Escape(name); |
| 177 | + name = Regex.Escape(name); |
177 | 178 | name = name.Replace("?", "\\?"); |
178 | 179 | return name; |
179 | 180 | } |
— | — | @@ -277,7 +278,7 @@ |
278 | 279 | string users_ok = ""; |
279 | 280 | foreach (user b in Users) |
280 | 281 | { |
281 | | - users_ok = users_ok + " " + b.name + ","; |
| 282 | + users_ok += users_ok + " " + b.name + ","; |
282 | 283 | } |
283 | 284 | Message("I trust: " + users_ok, _Channel); |
284 | 285 | } |
— | — | @@ -666,11 +667,7 @@ |
667 | 668 | |
668 | 669 | private void StartSearch() |
669 | 670 | { |
670 | | - System.Text.RegularExpressions.Regex value = new System.Text.RegularExpressions.Regex(search_key, |
671 | | - System.Text. |
672 | | - RegularExpressions |
673 | | - .RegexOptions. |
674 | | - Compiled); |
| 671 | + Regex value = new Regex(search_key, RegexOptions.Compiled); |
675 | 672 | string results = ""; |
676 | 673 | foreach (item data in text) |
677 | 674 | { |
— | — | @@ -713,7 +710,7 @@ |
714 | 711 | } |
715 | 712 | search_key = key.Substring(11); |
716 | 713 | running = true; |
717 | | - System.Threading.Thread th = new System.Threading.Thread(new System.Threading.ThreadStart(StartSearch)); |
| 714 | + System.Threading.Thread th = new System.Threading.Thread(StartSearch); |
718 | 715 | th.Start(); |
719 | 716 | int check = 1; |
720 | 717 | while (running) |
— | — | @@ -1000,11 +997,8 @@ |
1001 | 998 | channel.Users.delUser(rights_info[1]); |
1002 | 999 | return 0; |
1003 | 1000 | } |
1004 | | - else |
1005 | | - { |
1006 | | - Message("You are not autorized to perform this, sorry", channel.name); |
1007 | | - return 0; |
1008 | | - } |
| 1001 | + Message("You are not autorized to perform this, sorry", channel.name); |
| 1002 | + return 0; |
1009 | 1003 | } |
1010 | 1004 | Message("Invalid user", channel.name); |
1011 | 1005 | } |
— | — | @@ -1044,7 +1038,7 @@ |
1045 | 1039 | timedateToString(System.DateTime.Now.Second) + "] " + "<" + user + ">\t " + message + "\n"; |
1046 | 1040 | } |
1047 | 1041 | File.AppendAllText( |
1048 | | - channel.log + DateTime.Now.Year + DateTime.Now.Month + System.DateTime.Now.Day + ".txt", log); |
| 1042 | + channel.log + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt", log); |
1049 | 1043 | } |
1050 | 1044 | } |
1051 | 1045 | catch (Exception er) |
— | — | @@ -1156,11 +1150,8 @@ |
1157 | 1151 | config.Save(); |
1158 | 1152 | return; |
1159 | 1153 | } |
1160 | | - else |
1161 | | - { |
1162 | | - Message(messages.PermissionDenied, chan.name); |
1163 | | - return; |
1164 | | - } |
| 1154 | + Message(messages.PermissionDenied, chan.name); |
| 1155 | + return; |
1165 | 1156 | } |
1166 | 1157 | if (message == "@part") |
1167 | 1158 | { |
— | — | @@ -1203,11 +1194,8 @@ |
1204 | 1195 | Message("Channel config was reloaded", chan.name); |
1205 | 1196 | return; |
1206 | 1197 | } |
1207 | | - else |
1208 | | - { |
1209 | | - Message(messages.PermissionDenied, chan.name); |
1210 | | - return; |
1211 | | - } |
| 1198 | + Message(messages.PermissionDenied, chan.name); |
| 1199 | + return; |
1212 | 1200 | } |
1213 | 1201 | if (message == "@logon") |
1214 | 1202 | { |
— | — | @@ -1218,14 +1206,11 @@ |
1219 | 1207 | Message("Channel is already logged", chan.name); |
1220 | 1208 | return; |
1221 | 1209 | } |
1222 | | - else |
1223 | | - { |
1224 | | - Message("Channel is now logged", chan.name); |
1225 | | - chan.logged = true; |
1226 | | - chan.SaveConfig(); |
1227 | | - config.Save(); |
1228 | | - return; |
1229 | | - } |
| 1210 | + Message("Channel is now logged", chan.name); |
| 1211 | + chan.logged = true; |
| 1212 | + chan.SaveConfig(); |
| 1213 | + config.Save(); |
| 1214 | + return; |
1230 | 1215 | } |
1231 | 1216 | else |
1232 | 1217 | { |
— | — | @@ -1241,11 +1226,8 @@ |
1242 | 1227 | Message("You are unknown to me :)", chan.name); |
1243 | 1228 | return; |
1244 | 1229 | } |
1245 | | - else |
1246 | | - { |
1247 | | - Message("You are " + current.level + " identified by name " + current.name, chan.name); |
1248 | | - return; |
1249 | | - } |
| 1230 | + Message("You are " + current.level + " identified by name " + current.name, chan.name); |
| 1231 | + return; |
1250 | 1232 | } |
1251 | 1233 | |
1252 | 1234 | if (message == "@logoff") |
— | — | @@ -1257,19 +1239,13 @@ |
1258 | 1240 | Message("Channel was already not logged", chan.name); |
1259 | 1241 | return; |
1260 | 1242 | } |
1261 | | - else |
1262 | | - { |
1263 | | - chan.logged = false; |
1264 | | - config.Save(); |
1265 | | - chan.SaveConfig(); |
1266 | | - Message("Channel is not logged", chan.name); |
1267 | | - return; |
1268 | | - } |
| 1243 | + chan.logged = false; |
| 1244 | + config.Save(); |
| 1245 | + chan.SaveConfig(); |
| 1246 | + Message("Channel is not logged", chan.name); |
| 1247 | + return; |
1269 | 1248 | } |
1270 | | - else |
1271 | | - { |
1272 | | - Message(messages.PermissionDenied, chan.name); |
1273 | | - } |
| 1249 | + Message(messages.PermissionDenied, chan.name); |
1274 | 1250 | } |
1275 | 1251 | if (message == "@channellist") |
1276 | 1252 | { |
— | — | @@ -1290,20 +1266,14 @@ |
1291 | 1267 | Message("Channel had infobot disabled", chan.name); |
1292 | 1268 | return; |
1293 | 1269 | } |
1294 | | - else |
1295 | | - { |
1296 | | - Message("Infobot disabled", chan.name); |
1297 | | - chan.info = false; |
1298 | | - chan.SaveConfig(); |
1299 | | - config.Save(); |
1300 | | - return; |
1301 | | - } |
1302 | | - } |
1303 | | - else |
1304 | | - { |
1305 | | - Message(messages.PermissionDenied, chan.name); |
| 1270 | + Message("Infobot disabled", chan.name); |
| 1271 | + chan.info = false; |
| 1272 | + chan.SaveConfig(); |
| 1273 | + config.Save(); |
1306 | 1274 | return; |
1307 | 1275 | } |
| 1276 | + Message(messages.PermissionDenied, chan.name); |
| 1277 | + return; |
1308 | 1278 | } |
1309 | 1279 | if (message == "@infobot-on") |
1310 | 1280 | { |
— | — | @@ -1314,14 +1284,11 @@ |
1315 | 1285 | Message("Infobot was already enabled :O", chan.name); |
1316 | 1286 | return; |
1317 | 1287 | } |
1318 | | - else |
1319 | | - { |
1320 | | - chan.info = true; |
1321 | | - config.Save(); |
1322 | | - chan.SaveConfig(); |
1323 | | - Message("Infobot enabled", chan.name); |
1324 | | - return; |
1325 | | - } |
| 1288 | + chan.info = true; |
| 1289 | + config.Save(); |
| 1290 | + chan.SaveConfig(); |
| 1291 | + Message("Infobot enabled", chan.name); |
| 1292 | + return; |
1326 | 1293 | } |
1327 | 1294 | Message(messages.PermissionDenied, chan.name); |
1328 | 1295 | return; |
— | — | @@ -1488,7 +1455,7 @@ |
1489 | 1456 | if (message.StartsWith(":" + delimiter.ToString() + "TIME")) |
1490 | 1457 | { |
1491 | 1458 | wd.WriteLine("NOTICE " + nick + " :" + delimiter.ToString() + "TIME " + |
1492 | | - System.DateTime.Now.ToString()); |
| 1459 | + DateTime.Now.ToString()); |
1493 | 1460 | wd.Flush(); |
1494 | 1461 | continue; |
1495 | 1462 | } |