r106542 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106541‎ | r106542 | r106543 >
Date:00:50, 18 December 2011
Author:reedy
Status:deferred
Tags:
Comment:
Few more using statements

Code simplification
Modified paths:
  • /trunk/tools/wmib/Config.cs (modified) (history)
  • /trunk/tools/wmib/Core.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/Config.cs
@@ -60,7 +60,7 @@
6161 /// <param name="b">Value</param>
6262 private void AddConfig(string a, string b)
6363 {
64 - conf = conf + "\n" + a + "=" + b + ";";
 64+ conf += "\n" + a + "=" + b + ";";
6565 }
6666
6767 /// <summary>
Index: trunk/tools/wmib/Core.cs
@@ -12,6 +12,7 @@
1313 using System.Collections.Generic;
1414 using System.IO;
1515 using System.Text.RegularExpressions;
 16+using System.Threading;
1617
1718 namespace wmib
1819 {
@@ -37,8 +38,8 @@
3839 public class irc
3940 {
4041 private static System.Net.Sockets.NetworkStream data;
41 - public static System.Threading.Thread dumphtmt;
42 - public static System.Threading.Thread check_thread;
 42+ public static Thread dumphtmt;
 43+ public static Thread check_thread;
4344 public static StreamReader rd;
4445 private static StreamWriter wd;
4546 private static List<user> User = new List<user>();
@@ -96,14 +97,14 @@
9798
9899 public int IsMatch()
99100 {
100 - System.Threading.Thread quick = new System.Threading.Thread(Run);
 101+ Thread quick = new Thread(Run);
101102 searching = true;
102103 quick.Start();
103104 int check = 0;
104105 while (searching)
105106 {
106107 check++;
107 - System.Threading.Thread.Sleep(10);
 108+ Thread.Sleep(10);
108109 if (check <= 50) continue;
109110 quick.Abort();
110111 return 2;
@@ -707,13 +708,13 @@
708709 }
709710 search_key = key.Substring(11);
710711 running = true;
711 - System.Threading.Thread th = new System.Threading.Thread(StartSearch);
 712+ Thread th = new Thread(StartSearch);
712713 th.Start();
713714 int check = 1;
714715 while (running)
715716 {
716717 check++;
717 - System.Threading.Thread.Sleep(10);
 718+ Thread.Sleep(10);
718719 if (check > 80)
719720 {
720721 th.Abort();
@@ -764,7 +765,7 @@
765766 {
766767 while (locked)
767768 {
768 - System.Threading.Thread.Sleep(200);
 769+ Thread.Sleep(200);
769770 }
770771 try
771772 {
@@ -811,7 +812,7 @@
812813 {
813814 while (locked)
814815 {
815 - System.Threading.Thread.Sleep(200);
 816+ Thread.Sleep(200);
816817 }
817818 foreach (item keys in text)
818819 {
@@ -834,7 +835,7 @@
835836 {
836837 while (true)
837838 {
838 - System.Threading.Thread.Sleep(20000);
 839+ Thread.Sleep(20000);
839840 wd.WriteLine("PING :" + config.network);
840841 wd.Flush();
841842 }
@@ -860,7 +861,7 @@
861862 {
862863 wd.WriteLine("PRIVMSG nickserv :identify " + config.login + " " + config.password);
863864 wd.Flush();
864 - System.Threading.Thread.Sleep(4000);
 865+ Thread.Sleep(4000);
865866 }
866867 return true;
867868 }
@@ -1024,15 +1025,15 @@
10251026 string log;
10261027 if (!noac)
10271028 {
1028 - log = "[" + timedateToString(System.DateTime.Now.Hour) + ":" +
1029 - timedateToString(System.DateTime.Now.Minute) + ":" +
1030 - timedateToString(System.DateTime.Now.Second) + "] * " + user + " " + message + "\n";
 1029+ log = "[" + timedateToString(DateTime.Now.Hour) + ":" +
 1030+ timedateToString(DateTime.Now.Minute) + ":" +
 1031+ timedateToString(DateTime.Now.Second) + "] * " + user + " " + message + "\n";
10311032 }
10321033 else
10331034 {
1034 - log = "[" + timedateToString(System.DateTime.Now.Hour) + ":" +
1035 - timedateToString(System.DateTime.Now.Minute) + ":" +
1036 - timedateToString(System.DateTime.Now.Second) + "] " + "<" + user + ">\t " + message + "\n";
 1035+ log = "[" + timedateToString(DateTime.Now.Hour) + ":" +
 1036+ timedateToString(DateTime.Now.Minute) + ":" +
 1037+ timedateToString(DateTime.Now.Second) + "] " + "<" + user + ">\t " + message + "\n";
10371038 }
10381039 File.AppendAllText(
10391040 channel.log + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt", log);
@@ -1060,6 +1061,11 @@
10611062 return false;
10621063 }
10631064
 1065+ /// <summary>
 1066+ ///
 1067+ /// </summary>
 1068+ /// <param name="name"></param>
 1069+ /// <returns></returns>
10641070 public static bool validFile(string name)
10651071 {
10661072 return
@@ -1109,7 +1115,7 @@
11101116 config.Save();
11111117 wd.WriteLine("JOIN " + channel);
11121118 wd.Flush();
1113 - System.Threading.Thread.Sleep(100);
 1119+ Thread.Sleep(100);
11141120 config.channel Chan = getChannel(channel);
11151121 Chan.Users.addUser("admin", IRCTrust.normalize(user) + "!.*@" + host);
11161122 }
@@ -1135,7 +1141,7 @@
11361142 if (chan.Users.isApproved(user, host, "admin"))
11371143 {
11381144 wd.WriteLine("PART " + chan.name);
1139 - System.Threading.Thread.Sleep(100);
 1145+ Thread.Sleep(100);
11401146 wd.Flush();
11411147 if (!Directory.Exists(chan.log))
11421148 {
@@ -1155,7 +1161,7 @@
11561162 if (chan.Users.isApproved(user, host, "admin"))
11571163 {
11581164 wd.WriteLine("PART " + chan.name);
1159 - System.Threading.Thread.Sleep(100);
 1165+ Thread.Sleep(100);
11601166 wd.Flush();
11611167 config.channels.Remove(chan);
11621168 config.Save();
@@ -1345,7 +1351,7 @@
13461352 Authenticate();
13471353 foreach (config.channel ch in config.channels)
13481354 {
1349 - System.Threading.Thread.Sleep(2000);
 1355+ Thread.Sleep(2000);
13501356 wd.WriteLine("JOIN " + ch.name);
13511357 }
13521358 wd.Flush();
@@ -1362,15 +1368,15 @@
13631369 rd = new StreamReader(data, System.Text.Encoding.UTF8);
13641370 wd = new StreamWriter(data);
13651371
1366 - dumphtmt = new System.Threading.Thread(HtmlDump.Start);
 1372+ dumphtmt = new Thread(HtmlDump.Start);
13671373 dumphtmt.Start();
1368 - check_thread = new System.Threading.Thread(Ping);
 1374+ check_thread = new Thread(Ping);
13691375 check_thread.Start();
13701376
13711377 wd.WriteLine("USER " + config.name + " 8 * :" + config.name);
13721378 wd.WriteLine("NICK " + config.username);
13731379
1374 - System.Threading.Thread.Sleep(2000);
 1380+ Thread.Sleep(2000);
13751381
13761382 Authenticate();
13771383
@@ -1379,14 +1385,14 @@
13801386 if (ch.name != "")
13811387 {
13821388 wd.WriteLine("JOIN " + ch.name);
1383 - System.Threading.Thread.Sleep(2000);
 1389+ Thread.Sleep(2000);
13841390 }
13851391 }
13861392 wd.Flush();
13871393 string nick = "";
13881394 string host = "";
13891395 string channel = "";
1390 - char delimiter = (char) 001;
 1396+ const char delimiter = (char) 001;
13911397
13921398 while (true)
13931399 {
@@ -1403,7 +1409,6 @@
14041410 if (text.Contains("PRIVMSG"))
14051411 {
14061412 string info = text.Substring(1, text.IndexOf(" :", 1) - 1);
1407 - string info_host;
14081413 // we got a message here :)
14091414 if (text.Contains("!") && text.Contains("@"))
14101415 {
@@ -1412,7 +1417,7 @@
14131418 info.IndexOf(" ", info.IndexOf("@")) - 1 -
14141419 info.IndexOf("@"));
14151420 }
1416 - info_host = info.Substring(info.IndexOf("PRIVMSG "));
 1421+ string info_host = info.Substring(info.IndexOf("PRIVMSG "));
14171422
14181423 string message;
14191424 if (info_host.Contains("#"))
@@ -1469,7 +1474,7 @@
14701475 }
14711476 }
14721477 }
1473 - System.Threading.Thread.Sleep(50);
 1478+ Thread.Sleep(50);
14741479 }
14751480 Program.Log("Reconnecting, end of data stream");
14761481 Reconnect();

Status & tagging log