r107684 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107683‎ | r107684 | r107685 >
Date:00:29, 31 December 2011
Author:reedy
Status:ok
Tags:
Comment:
Reformat

Remove/add using statements
Modified paths:
  • /trunk/tools/wmib/Config.cs (modified) (history)
  • /trunk/tools/wmib/DumpHtm.cs (modified) (history)
  • /trunk/tools/wmib/Infobot.cs (modified) (history)
  • /trunk/tools/wmib/Program.cs (modified) (history)
  • /trunk/tools/wmib/RClogs.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/DumpHtm.cs
@@ -8,8 +8,6 @@
99 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
1010 //GNU General Public License for more details.
1111
12 -
13 -
1412 using System;
1513 using System.IO;
1614 using System.Threading;
@@ -22,10 +20,12 @@
2321 /// Channel name
2422 /// </summary>
2523 public config.channel Channel;
 24+
2625 /// <summary>
2726 /// Dump
2827 /// </summary>
2928 public string dumpname;
 29+
3030 // This function is called on start of bot
3131 public static void Start()
3232 {
@@ -43,6 +43,7 @@
4444 Thread.Sleep(320000);
4545 }
4646 }
 47+
4748 /// <summary>
4849 /// Constructor
4950 /// </summary>
Index: trunk/tools/wmib/Infobot.cs
@@ -13,7 +13,6 @@
1414 using System.Threading;
1515 using System.Text.RegularExpressions;
1616 using System.IO;
17 -using System.Text;
1817
1918 namespace wmib
2019 {
@@ -38,6 +37,7 @@
3938 /// Text
4039 /// </summary>
4140 public string text;
 41+
4242 /// <summary>
4343 /// Key
4444 /// </summary>
@@ -62,16 +62,19 @@
6363 user = User;
6464 }
6565 }
 66+
6667 public class staticalias
6768 {
6869 /// <summary>
6970 /// Name
7071 /// </summary>
7172 public string Name;
 73+
7274 /// <summary>
7375 /// Key
7476 /// </summary>
7577 public string Key;
 78+
7679 /// <summary>
7780 /// Constructor
7881 /// </summary>
@@ -160,11 +163,14 @@
161164 File.WriteAllText(datafile, "");
162165 foreach (staticalias key in Alias)
163166 {
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");
165169 }
166170 foreach (item key in text)
167171 {
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");
169175 }
170176 }
171177 catch (Exception b)
@@ -262,10 +268,7 @@
263269 }
264270 return false;
265271 }
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);
270273 return false;
271274 }
272275 if (parm[1] == "del")
Index: trunk/tools/wmib/Config.cs
@@ -226,11 +226,13 @@
227227 }
228228
229229 public static string text;
 230+
230231 /// <summary>
231232 /// Network
232233 /// </summary>
233234
234235 public static string network = "irc.freenode.net";
 236+
235237 /// <summary>
236238 /// Nick name
237239 /// </summary>
Index: trunk/tools/wmib/Program.cs
@@ -11,11 +11,7 @@
1212 // Created by Petr Bena <benapetr@gmail.com>
1313
1414 using System;
15 -using System.Collections.Generic;
16 -using System.Text;
17 -using System.Net;
1815
19 -
2016 namespace wmib
2117 {
2218 internal class Program
Index: trunk/tools/wmib/RClogs.cs
@@ -11,8 +11,8 @@
1212 using System;
1313 using System.Collections.Generic;
1414 using System.Threading;
15 -using System.Text;
1615 using System.IO;
 16+using System.Text.RegularExpressions;
1717
1818 namespace wmib
1919 {
@@ -23,6 +23,7 @@
2424 public string Channel;
2525 public string Page;
2626 public wiki URL;
 27+
2728 public IWatch(wiki site, string page, string channel)
2829 {
2930 Channel = channel;
@@ -30,11 +31,13 @@
3132 URL = site;
3233 }
3334 }
 35+
3436 public class wiki
3537 {
3638 public string name;
3739 public string channel;
3840 public string url;
 41+
3942 public wiki(string _channel, string _url, string _name)
4043 {
4144 url = _url;
@@ -47,31 +50,43 @@
4851 /// List of pages
4952 /// </summary>
5053 private List<IWatch> pages = new List<IWatch>();
 54+
5155 /// <summary>
5256 /// Wiki
5357 /// </summary>
5458 public static List<wiki> wikiinfo = new List<wiki>();
 59+
5560 /// <summary>
5661 /// Channels
5762 /// </summary>
5863 private static List<string> channels;
 64+
5965 private static List<RecentChanges> rc = new List<RecentChanges>();
 66+
6067 /// <summary>
6168 /// Stream reader
6269 /// </summary>
6370 private static StreamReader RD;
 71+
6472 private static string channeldata = variables.config + "/feed";
6573 public static StreamWriter WD;
6674 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+
6980 public config.channel channel;
7081
7182 ~RecentChanges()
7283 {
73 - try {
74 - rc.Remove(this);
75 - } catch (Exception) {}
 84+ try
 85+ {
 86+ rc.Remove(this);
 87+ }
 88+ catch (Exception)
 89+ {
 90+ }
7691 }
7792
7893 public RecentChanges(config.channel _channel)
@@ -111,10 +126,10 @@
112127 channels.Add(web.channel);
113128 WD.WriteLine("JOIN " + web.channel);
114129 WD.Flush();
115 - System.IO.File.WriteAllText(channeldata, "");
 130+ File.WriteAllText(channeldata, "");
116131 foreach (string x in channels)
117132 {
118 - System.IO.File.AppendAllText(channeldata, x + "\n");
 133+ File.AppendAllText(channeldata, x + "\n");
119134 }
120135 return true;
121136 }
@@ -149,10 +164,10 @@
150165 channels.Remove(W.channel);
151166 WD.WriteLine("PART " + W.channel);
152167 WD.Flush();
153 - System.IO.File.WriteAllText(channeldata, "");
 168+ File.WriteAllText(channeldata, "");
154169 foreach (string x in channels)
155170 {
156 - System.IO.File.AppendAllText(channeldata, x + "\n");
 171+ File.AppendAllText(channeldata, x + "\n");
157172 }
158173 return true;
159174 }
@@ -167,9 +182,11 @@
168183 stream = new System.Net.Sockets.TcpClient("irc.wikimedia.org", 6667).GetStream();
169184 WD = new StreamWriter(stream);
170185 RD = new StreamReader(stream, System.Text.Encoding.UTF8);
171 - System.Threading.Thread pinger = new System.Threading.Thread(Pong);
 186+ Thread pinger = new Thread(Pong);
172187 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(".", ""));
174191 WD.Flush();
175192 pinger.Start();
176193 foreach (string b in channels)
@@ -180,8 +197,8 @@
181198 }
182199 }
183200 catch (Exception)
184 - {
185 -
 201+ {
 202+
186203 }
187204 }
188205
@@ -232,25 +249,30 @@
233250 string content = "";
234251 foreach (IWatch values in pages)
235252 {
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";
237255 }
238256 File.WriteAllText(dbn, content);
239257 }
240258
241259 private static void Pong()
242260 {
243 - try {
 261+ try
 262+ {
244263 while (true)
245264 {
246265 WD.WriteLine("PING irc.wikimedia.org");
247266 WD.Flush();
248 - System.Threading.Thread.Sleep(12000);
 267+ Thread.Sleep(12000);
249268 }
250 - } catch ( System.IO.IOException )
 269+ }
 270+ catch (IOException)
251271 {
252272 Thread.CurrentThread.Abort();
253273 }
254 - catch (Exception) { }
 274+ catch (Exception)
 275+ {
 276+ }
255277 }
256278
257279 public bool removeString(string WS, string Page)
@@ -287,10 +309,13 @@
288310 irc.SlowQueue.DeliverMessage("Can't find item in a list", channel.name);
289311 return true;
290312 }
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);
292315 return false;
293316 }
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);
295320 return false;
296321 }
297322
@@ -360,7 +385,8 @@
361386 }
362387 if (pages.Contains(currpage))
363388 {
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);
365391 return true;
366392 }
367393 pages.Add(new IWatch(site, Page, site.channel));
@@ -368,10 +394,13 @@
369395 Save();
370396 return true;
371397 }
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);
373400 return false;
374401 }
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);
376405 return false;
377406 }
378407
@@ -398,7 +427,7 @@
399428 while (!RD.EndOfStream)
400429 {
401430 message = RD.ReadLine();
402 - System.Text.RegularExpressions.Match Edit = line.Match(message);
 431+ Match Edit = line.Match(message);
403432 if (line.IsMatch(message))
404433 {
405434 string _channel = message.Substring(message.IndexOf("PRIVMSG"));
@@ -422,17 +451,20 @@
423452 {
424453 if (w.Channel == _channel && page == w.Page)
425454 {
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);
427459 }
428460 }
429461 }
430462 }
431463 }
432 - System.Threading.Thread.Sleep(100);
 464+ Thread.Sleep(100);
433465 }
434 - System.Threading.Thread.Sleep(100);
 466+ Thread.Sleep(100);
435467 }
436 - catch (System.IO.IOException)
 468+ catch (IOException)
437469 {
438470 Connect();
439471 }

Sign-offs

UserFlagDate
Nikerabbitinspected09:35, 31 December 2011

Status & tagging log