Index: trunk/tools/wmib/DumpHtm.cs |
— | — | @@ -8,8 +8,6 @@ |
9 | 9 | //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
10 | 10 | //GNU General Public License for more details. |
11 | 11 | |
12 | | - |
13 | | - |
14 | 12 | using System; |
15 | 13 | using System.IO; |
16 | 14 | using System.Threading; |
— | — | @@ -22,10 +20,12 @@ |
23 | 21 | /// Channel name |
24 | 22 | /// </summary> |
25 | 23 | public config.channel Channel; |
| 24 | + |
26 | 25 | /// <summary> |
27 | 26 | /// Dump |
28 | 27 | /// </summary> |
29 | 28 | public string dumpname; |
| 29 | + |
30 | 30 | // This function is called on start of bot |
31 | 31 | public static void Start() |
32 | 32 | { |
— | — | @@ -43,6 +43,7 @@ |
44 | 44 | Thread.Sleep(320000); |
45 | 45 | } |
46 | 46 | } |
| 47 | + |
47 | 48 | /// <summary> |
48 | 49 | /// Constructor |
49 | 50 | /// </summary> |
Index: trunk/tools/wmib/Infobot.cs |
— | — | @@ -13,7 +13,6 @@ |
14 | 14 | using System.Threading; |
15 | 15 | using System.Text.RegularExpressions; |
16 | 16 | using System.IO; |
17 | | -using System.Text; |
18 | 17 | |
19 | 18 | namespace wmib |
20 | 19 | { |
— | — | @@ -38,6 +37,7 @@ |
39 | 38 | /// Text |
40 | 39 | /// </summary> |
41 | 40 | public string text; |
| 41 | + |
42 | 42 | /// <summary> |
43 | 43 | /// Key |
44 | 44 | /// </summary> |
— | — | @@ -62,16 +62,19 @@ |
63 | 63 | user = User; |
64 | 64 | } |
65 | 65 | } |
| 66 | + |
66 | 67 | public class staticalias |
67 | 68 | { |
68 | 69 | /// <summary> |
69 | 70 | /// Name |
70 | 71 | /// </summary> |
71 | 72 | public string Name; |
| 73 | + |
72 | 74 | /// <summary> |
73 | 75 | /// Key |
74 | 76 | /// </summary> |
75 | 77 | public string Key; |
| 78 | + |
76 | 79 | /// <summary> |
77 | 80 | /// Constructor |
78 | 81 | /// </summary> |
— | — | @@ -160,11 +163,14 @@ |
161 | 164 | File.WriteAllText(datafile, ""); |
162 | 165 | foreach (staticalias key in Alias) |
163 | 166 | { |
164 | | - File.AppendAllText(datafile, key.Name + config.separator + key.Key + config.separator + "alias" + "\n"); |
| 167 | + File.AppendAllText(datafile, |
| 168 | + key.Name + config.separator + key.Key + config.separator + "alias" + "\n"); |
165 | 169 | } |
166 | 170 | foreach (item key in text) |
167 | 171 | { |
168 | | - File.AppendAllText(datafile, key.key + config.separator + key.text + config.separator + "key" + config.separator + key.locked + config.separator + key.user + "\n"); |
| 172 | + File.AppendAllText(datafile, |
| 173 | + key.key + config.separator + key.text + config.separator + "key" + |
| 174 | + config.separator + key.locked + config.separator + key.user + "\n"); |
169 | 175 | } |
170 | 176 | } |
171 | 177 | catch (Exception b) |
— | — | @@ -262,10 +268,7 @@ |
263 | 269 | } |
264 | 270 | return false; |
265 | 271 | } |
266 | | - else |
267 | | - { |
268 | | - irc.Message("You are not autorized to perform this, sorry", Channel); |
269 | | - } |
| 272 | + irc.Message("You are not autorized to perform this, sorry", Channel); |
270 | 273 | return false; |
271 | 274 | } |
272 | 275 | if (parm[1] == "del") |
Index: trunk/tools/wmib/Config.cs |
— | — | @@ -226,11 +226,13 @@ |
227 | 227 | } |
228 | 228 | |
229 | 229 | public static string text; |
| 230 | + |
230 | 231 | /// <summary> |
231 | 232 | /// Network |
232 | 233 | /// </summary> |
233 | 234 | |
234 | 235 | public static string network = "irc.freenode.net"; |
| 236 | + |
235 | 237 | /// <summary> |
236 | 238 | /// Nick name |
237 | 239 | /// </summary> |
Index: trunk/tools/wmib/Program.cs |
— | — | @@ -11,11 +11,7 @@ |
12 | 12 | // Created by Petr Bena <benapetr@gmail.com> |
13 | 13 | |
14 | 14 | using System; |
15 | | -using System.Collections.Generic; |
16 | | -using System.Text; |
17 | | -using System.Net; |
18 | 15 | |
19 | | - |
20 | 16 | namespace wmib |
21 | 17 | { |
22 | 18 | internal class Program |
Index: trunk/tools/wmib/RClogs.cs |
— | — | @@ -11,8 +11,8 @@ |
12 | 12 | using System; |
13 | 13 | using System.Collections.Generic; |
14 | 14 | using System.Threading; |
15 | | -using System.Text; |
16 | 15 | using System.IO; |
| 16 | +using System.Text.RegularExpressions; |
17 | 17 | |
18 | 18 | namespace wmib |
19 | 19 | { |
— | — | @@ -23,6 +23,7 @@ |
24 | 24 | public string Channel; |
25 | 25 | public string Page; |
26 | 26 | public wiki URL; |
| 27 | + |
27 | 28 | public IWatch(wiki site, string page, string channel) |
28 | 29 | { |
29 | 30 | Channel = channel; |
— | — | @@ -30,11 +31,13 @@ |
31 | 32 | URL = site; |
32 | 33 | } |
33 | 34 | } |
| 35 | + |
34 | 36 | public class wiki |
35 | 37 | { |
36 | 38 | public string name; |
37 | 39 | public string channel; |
38 | 40 | public string url; |
| 41 | + |
39 | 42 | public wiki(string _channel, string _url, string _name) |
40 | 43 | { |
41 | 44 | url = _url; |
— | — | @@ -47,31 +50,43 @@ |
48 | 51 | /// List of pages |
49 | 52 | /// </summary> |
50 | 53 | private List<IWatch> pages = new List<IWatch>(); |
| 54 | + |
51 | 55 | /// <summary> |
52 | 56 | /// Wiki |
53 | 57 | /// </summary> |
54 | 58 | public static List<wiki> wikiinfo = new List<wiki>(); |
| 59 | + |
55 | 60 | /// <summary> |
56 | 61 | /// Channels |
57 | 62 | /// </summary> |
58 | 63 | private static List<string> channels; |
| 64 | + |
59 | 65 | private static List<RecentChanges> rc = new List<RecentChanges>(); |
| 66 | + |
60 | 67 | /// <summary> |
61 | 68 | /// Stream reader |
62 | 69 | /// </summary> |
63 | 70 | private static StreamReader RD; |
| 71 | + |
64 | 72 | private static string channeldata = variables.config + "/feed"; |
65 | 73 | public static StreamWriter WD; |
66 | 74 | public static System.Net.Sockets.NetworkStream stream; |
67 | | - public static System.Text.RegularExpressions.Regex line = new System.Text.RegularExpressions.Regex(":rc-pmtpa!~rc-pmtpa@[^ ]* PRIVMSG #[^:]*:14\\[\\[07([^]*)14\\]\\]4 (M?)(B?)10 02.*di" + |
68 | | - "ff=([^&]*)&oldid=([^]*) 5\\* 03([^]*) 5\\* \\(?([^]*)?\\) 10([^]*)?"); |
| 75 | + |
| 76 | + public static Regex line = |
| 77 | + new Regex(":rc-pmtpa!~rc-pmtpa@[^ ]* PRIVMSG #[^:]*:14\\[\\[07([^]*)14\\]\\]4 (M?)(B?)10 02.*di" + |
| 78 | + "ff=([^&]*)&oldid=([^]*) 5\\* 03([^]*) 5\\* \\(?([^]*)?\\) 10([^]*)?"); |
| 79 | + |
69 | 80 | public config.channel channel; |
70 | 81 | |
71 | 82 | ~RecentChanges() |
72 | 83 | { |
73 | | - try { |
74 | | - rc.Remove(this); |
75 | | - } catch (Exception) {} |
| 84 | + try |
| 85 | + { |
| 86 | + rc.Remove(this); |
| 87 | + } |
| 88 | + catch (Exception) |
| 89 | + { |
| 90 | + } |
76 | 91 | } |
77 | 92 | |
78 | 93 | public RecentChanges(config.channel _channel) |
— | — | @@ -111,10 +126,10 @@ |
112 | 127 | channels.Add(web.channel); |
113 | 128 | WD.WriteLine("JOIN " + web.channel); |
114 | 129 | WD.Flush(); |
115 | | - System.IO.File.WriteAllText(channeldata, ""); |
| 130 | + File.WriteAllText(channeldata, ""); |
116 | 131 | foreach (string x in channels) |
117 | 132 | { |
118 | | - System.IO.File.AppendAllText(channeldata, x + "\n"); |
| 133 | + File.AppendAllText(channeldata, x + "\n"); |
119 | 134 | } |
120 | 135 | return true; |
121 | 136 | } |
— | — | @@ -149,10 +164,10 @@ |
150 | 165 | channels.Remove(W.channel); |
151 | 166 | WD.WriteLine("PART " + W.channel); |
152 | 167 | WD.Flush(); |
153 | | - System.IO.File.WriteAllText(channeldata, ""); |
| 168 | + File.WriteAllText(channeldata, ""); |
154 | 169 | foreach (string x in channels) |
155 | 170 | { |
156 | | - System.IO.File.AppendAllText(channeldata, x + "\n"); |
| 171 | + File.AppendAllText(channeldata, x + "\n"); |
157 | 172 | } |
158 | 173 | return true; |
159 | 174 | } |
— | — | @@ -167,9 +182,11 @@ |
168 | 183 | stream = new System.Net.Sockets.TcpClient("irc.wikimedia.org", 6667).GetStream(); |
169 | 184 | WD = new StreamWriter(stream); |
170 | 185 | RD = new StreamReader(stream, System.Text.Encoding.UTF8); |
171 | | - System.Threading.Thread pinger = new System.Threading.Thread(Pong); |
| 186 | + Thread pinger = new Thread(Pong); |
172 | 187 | WD.WriteLine("USER " + "wm-bot" + " 8 * :" + "wm-bot"); |
173 | | - WD.WriteLine("NICK " + "wm-bot" + System.DateTime.Now.ToShortDateString().Replace("/", "").Replace(":", "").Replace("\\", "").Replace(".", "")); |
| 188 | + WD.WriteLine("NICK " + "wm-bot" + |
| 189 | + System.DateTime.Now.ToShortDateString().Replace("/", "").Replace(":", "").Replace("\\", "") |
| 190 | + .Replace(".", "")); |
174 | 191 | WD.Flush(); |
175 | 192 | pinger.Start(); |
176 | 193 | foreach (string b in channels) |
— | — | @@ -180,8 +197,8 @@ |
181 | 198 | } |
182 | 199 | } |
183 | 200 | catch (Exception) |
184 | | - { |
185 | | - |
| 201 | + { |
| 202 | + |
186 | 203 | } |
187 | 204 | } |
188 | 205 | |
— | — | @@ -232,25 +249,30 @@ |
233 | 250 | string content = ""; |
234 | 251 | foreach (IWatch values in pages) |
235 | 252 | { |
236 | | - content = content + values.URL.name + "|" + values.Page.Replace("|", "<separator>") + "|" + values.Channel + "\n"; |
| 253 | + content = content + values.URL.name + "|" + values.Page.Replace("|", "<separator>") + "|" + |
| 254 | + values.Channel + "\n"; |
237 | 255 | } |
238 | 256 | File.WriteAllText(dbn, content); |
239 | 257 | } |
240 | 258 | |
241 | 259 | private static void Pong() |
242 | 260 | { |
243 | | - try { |
| 261 | + try |
| 262 | + { |
244 | 263 | while (true) |
245 | 264 | { |
246 | 265 | WD.WriteLine("PING irc.wikimedia.org"); |
247 | 266 | WD.Flush(); |
248 | | - System.Threading.Thread.Sleep(12000); |
| 267 | + Thread.Sleep(12000); |
249 | 268 | } |
250 | | - } catch ( System.IO.IOException ) |
| 269 | + } |
| 270 | + catch (IOException) |
251 | 271 | { |
252 | 272 | Thread.CurrentThread.Abort(); |
253 | 273 | } |
254 | | - catch (Exception) { } |
| 274 | + catch (Exception) |
| 275 | + { |
| 276 | + } |
255 | 277 | } |
256 | 278 | |
257 | 279 | public bool removeString(string WS, string Page) |
— | — | @@ -287,10 +309,13 @@ |
288 | 310 | irc.SlowQueue.DeliverMessage("Can't find item in a list", channel.name); |
289 | 311 | return true; |
290 | 312 | } |
291 | | - irc.SlowQueue.DeliverMessage("Unable to delete the string because the channel is not being watched now", channel.name); |
| 313 | + irc.SlowQueue.DeliverMessage( |
| 314 | + "Unable to delete the string because the channel is not being watched now", channel.name); |
292 | 315 | return false; |
293 | 316 | } |
294 | | - irc.SlowQueue.DeliverMessage("Unable to delete the string from the list because there is no such wiki site known by a bot", channel.name); |
| 317 | + irc.SlowQueue.DeliverMessage( |
| 318 | + "Unable to delete the string from the list because there is no such wiki site known by a bot", |
| 319 | + channel.name); |
295 | 320 | return false; |
296 | 321 | } |
297 | 322 | |
— | — | @@ -360,7 +385,8 @@ |
361 | 386 | } |
362 | 387 | if (pages.Contains(currpage)) |
363 | 388 | { |
364 | | - irc.SlowQueue.DeliverMessage("There is already this string in a list of watched items", channel.name); |
| 389 | + irc.SlowQueue.DeliverMessage("There is already this string in a list of watched items", |
| 390 | + channel.name); |
365 | 391 | return true; |
366 | 392 | } |
367 | 393 | pages.Add(new IWatch(site, Page, site.channel)); |
— | — | @@ -368,10 +394,13 @@ |
369 | 395 | Save(); |
370 | 396 | return true; |
371 | 397 | } |
372 | | - irc.SlowQueue.DeliverMessage("Unable to insert the string because the channel is not being watched now", channel.name); |
| 398 | + irc.SlowQueue.DeliverMessage( |
| 399 | + "Unable to insert the string because the channel is not being watched now", channel.name); |
373 | 400 | return false; |
374 | 401 | } |
375 | | - irc.SlowQueue.DeliverMessage("Unable to insert the string to the list because there is no such wiki site known by a bot, contact some developer with svn access in order to insert it", channel.name); |
| 402 | + irc.SlowQueue.DeliverMessage( |
| 403 | + "Unable to insert the string to the list because there is no such wiki site known by a bot, contact some developer with svn access in order to insert it", |
| 404 | + channel.name); |
376 | 405 | return false; |
377 | 406 | } |
378 | 407 | |
— | — | @@ -398,7 +427,7 @@ |
399 | 428 | while (!RD.EndOfStream) |
400 | 429 | { |
401 | 430 | message = RD.ReadLine(); |
402 | | - System.Text.RegularExpressions.Match Edit = line.Match(message); |
| 431 | + Match Edit = line.Match(message); |
403 | 432 | if (line.IsMatch(message)) |
404 | 433 | { |
405 | 434 | string _channel = message.Substring(message.IndexOf("PRIVMSG")); |
— | — | @@ -422,17 +451,20 @@ |
423 | 452 | { |
424 | 453 | if (w.Channel == _channel && page == w.Page) |
425 | 454 | { |
426 | | - irc.SlowQueue.DeliverMessage("Change on 12" + w.URL.name + "1 a page " + page + " was modified, summary: " + summary + " changed by " + username + " link " + w.URL.url + "?diff=" + link, curr.channel.name); |
| 455 | + irc.SlowQueue.DeliverMessage( |
| 456 | + "Change on 12" + w.URL.name + "1 a page " + page + |
| 457 | + " was modified, summary: " + summary + " changed by " + username + |
| 458 | + " link " + w.URL.url + "?diff=" + link, curr.channel.name); |
427 | 459 | } |
428 | 460 | } |
429 | 461 | } |
430 | 462 | } |
431 | 463 | } |
432 | | - System.Threading.Thread.Sleep(100); |
| 464 | + Thread.Sleep(100); |
433 | 465 | } |
434 | | - System.Threading.Thread.Sleep(100); |
| 466 | + Thread.Sleep(100); |
435 | 467 | } |
436 | | - catch (System.IO.IOException) |
| 468 | + catch (IOException) |
437 | 469 | { |
438 | 470 | Connect(); |
439 | 471 | } |