r107307 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r107306‎ | r107307 | r107308 >
Date:23:36, 25 December 2011
Author:petrb
Status:deferred
Tags:
Comment:
merged some more changes made in previous revisions from Reedy
Modified paths:
  • /trunk/tools/wmib/Config.cs (modified) (history)
  • /trunk/tools/wmib/Core.cs (modified) (history)
  • /trunk/tools/wmib/DumpHtm.cs (modified) (history)
  • /trunk/tools/wmib/Program.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/Config.cs
@@ -77,17 +77,17 @@
7878 return;
7979 }
8080 conf = File.ReadAllText(conf_file);
81 - if (config.parseConfig(conf, "keysdb") != "")
 81+ if (parseConfig(conf, "keysdb") != "")
8282 {
83 - keydb = (config.parseConfig(conf, "keysdb"));
 83+ keydb = (parseConfig(conf, "keysdb"));
8484 }
85 - if (config.parseConfig(conf, "logged") != "")
 85+ if (parseConfig(conf, "logged") != "")
8686 {
87 - logged = bool.Parse(config.parseConfig(conf, "logged"));
 87+ logged = bool.Parse(parseConfig(conf, "logged"));
8888 }
89 - if (config.parseConfig(conf, "infodb") != "")
 89+ if (parseConfig(conf, "infodb") != "")
9090 {
91 - info = bool.Parse(config.parseConfig(conf, "infodb"));
 91+ info = bool.Parse(parseConfig(conf, "infodb"));
9292 }
9393 }
9494
@@ -147,7 +147,7 @@
148148 AddConfig("network", network);
149149 AddConfig("debug", debugchan);
150150 AddConfig("nick", login);
151 - text = text + "\nchannels=";
 151+ text += text + "\nchannels=";
152152 foreach (channel current in channels)
153153 {
154154 text = text + current.name + ",\n";
@@ -210,12 +210,12 @@
211211 /// <summary>
212212 /// Network
213213 /// </summary>
214 - ///
 214+
215215 public static string network = "irc.freenode.net";
216216 /// <summary>
217217 /// Nick name
218218 /// </summary>
219 - ///
 219+
220220 public static string username = "wm-bot";
221221
222222 public static string debugchan = null;
Index: trunk/tools/wmib/Program.cs
@@ -18,14 +18,14 @@
1919
2020 namespace wmib
2121 {
22 - class Program
 22+ internal class Program
2323 {
24 - public static bool Log(string msg )
 24+ public static bool Log(string msg)
2525 {
2626 Console.WriteLine("LOG: " + msg);
2727 return false;
2828 }
29 - static void Main(string[] args)
 29+ private static void Main(string[] args)
3030 {
3131 Log("Connecting");
3232 config.Load();
Index: trunk/tools/wmib/Core.cs
@@ -42,8 +42,8 @@
4343 private static System.Net.Sockets.NetworkStream data;
4444 public static Thread dumphtmt;
4545 public static Thread check_thread;
46 - public static System.IO.StreamReader rd;
47 - private static System.IO.StreamWriter wd;
 46+ public static StreamReader rd;
 47+ private static StreamWriter wd;
4848 private static List<user> User = new List<user>();
4949
5050 public class messages
@@ -140,7 +140,7 @@
141141 }
142142 public int IsMatch()
143143 {
144 - Thread quick = new Thread(new ThreadStart(Run));
 144+ Thread quick = new Thread(Run);
145145 searching = true;
146146 quick.Start();
147147 int check = 0;
@@ -358,7 +358,7 @@
359359 string users_ok = "";
360360 foreach (user b in Users)
361361 {
362 - users_ok = users_ok + " " + b.name + ",";
 362+ users_ok += " " + b.name + ",";
363363 }
364364 Message("I trust: " + users_ok, _Channel);
365365 }
@@ -615,11 +615,17 @@
616616 string log;
617617 if (!noac)
618618 {
619 - log = "[" + timedateToString(DateTime.Now.Hour) + ":" + timedateToString(DateTime.Now.Minute) + ":" + timedateToString(DateTime.Now.Second) + "] * " + user + " " + message + "\n";
 619+ log = "[" + timedateToString(DateTime.Now.Hour) + ":" +
 620+ timedateToString(DateTime.Now.Minute) + ":" +
 621+ timedateToString(DateTime.Now.Second) + "] * " +
 622+ user + " " + message + "\n";
620623 }
621624 else
622625 {
623 - log = "[" + timedateToString(DateTime.Now.Hour) + ":" + timedateToString(DateTime.Now.Minute) + ":" + timedateToString(DateTime.Now.Second) + "] " + "<" + user + ">\t " + message + "\n";
 626+ log = "[" + timedateToString(DateTime.Now.Hour) + ":"
 627+ + timedateToString(DateTime.Now.Minute) + ":" +
 628+ timedateToString(DateTime.Now.Second) + "] " + "<" +
 629+ user + ">\t " + message + "\n";
624630 }
625631 File.AppendAllText(channel.log + DateTime.Now.Year + DateTime.Now.Month + DateTime.Now.Day + ".txt", log);
626632 }
@@ -648,7 +654,8 @@
649655
650656 public static bool validFile(string name)
651657 {
652 - return !(name.Contains(" ") || name.Contains("?") || name.Contains("|") || name.Contains("/") || name.Contains("\\") || name.Contains(">") || name.Contains("<") || name.Contains("*"));
 658+ return !(name.Contains(" ") || name.Contains("?") || name.Contains("|") || name.Contains("/")
 659+ || name.Contains("\\") || name.Contains(">") || name.Contains("<") || name.Contains("*"));
653660 }
654661
655662 /// <summary>
@@ -690,13 +697,11 @@
691698 Chan.Users.addUser("admin", IRCTrust.normalize(user) + "!.*@" + host);
692699 return;
693700 }
694 - else
695 - {
696 - Message("Invalid name", chan.name);
697 - return;
698 - }
 701+ Message("Invalid name", chan.name);
 702+ return;
699703 }
700704 Message(messages.PermissionDenied, chan.name);
 705+ return;
701706 }
702707 }
703708 catch (Exception b)
@@ -738,11 +743,8 @@
739744 config.Save();
740745 return;
741746 }
742 - else
743 - {
744 - Message(messages.PermissionDenied, chan.name);
745 - return;
746 - }
 747+ Message(messages.PermissionDenied, chan.name);
 748+ return;
747749 }
748750 if (message == "@part")
749751 {
@@ -783,11 +785,8 @@
784786 Message("Channel config was reloaded", chan.name);
785787 return;
786788 }
787 - else
788 - {
789 - Message(messages.PermissionDenied, chan.name);
790 - return;
791 - }
 789+ Message(messages.PermissionDenied, chan.name);
 790+ return;
792791 }
793792 if (message == "@refresh")
794793 {
@@ -801,11 +800,8 @@
802801 Message("Message queue was reloaded", chan.name);
803802 return;
804803 }
805 - else
806 - {
807 - Message(messages.PermissionDenied, chan.name);
808 - return;
809 - }
 804+ Message(messages.PermissionDenied, chan.name);
 805+ return;
810806 }
811807 if (message == "@logon")
812808 {
@@ -825,11 +821,8 @@
826822 return;
827823 }
828824 }
829 - else
830 - {
831 - SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
832 - return;
833 - }
 825+ SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
 826+ return;
834827 }
835828 if (message == "@whoami")
836829 {
@@ -839,11 +832,8 @@
840833 Message("You are unknown to me :)", chan.name);
841834 return;
842835 }
843 - else
844 - {
845 - Message("You are " + current.level + " identified by name " + current.name, chan.name);
846 - return;
847 - }
 836+ Message("You are " + current.level + " identified by name " + current.name, chan.name);
 837+ return;
848838 }
849839
850840 if (message == "@logoff")
@@ -864,11 +854,8 @@
865855 return;
866856 }
867857 }
868 - else
869 - {
870 - SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
871 - return;
872 - }
 858+ SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
 859+ return;
873860 }
874861 if (message == "@channellist")
875862 {
@@ -898,11 +885,8 @@
899886 return;
900887 }
901888 }
902 - else
903 - {
904 - SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
905 - return;
906 - }
 889+ SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
 890+ return;
907891 }
908892 if (message == "@infobot-on")
909893 {
@@ -913,20 +897,14 @@
914898 Message("Infobot was already enabled :O", chan.name);
915899 return;
916900 }
917 - else
918 - {
919 - chan.info = true;
920 - config.Save();
921 - chan.SaveConfig();
922 - Message("Infobot enabled", chan.name);
923 - return;
924 - }
925 - }
926 - else
927 - {
928 - SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
 901+ chan.info = true;
 902+ config.Save();
 903+ chan.SaveConfig();
 904+ Message("Infobot enabled", chan.name);
929905 return;
930906 }
 907+ SlowQueue.DeliverMessage(messages.PermissionDenied, chan.name);
 908+ return;
931909 }
932910 if (message == "@commands")
933911 {
@@ -983,7 +961,7 @@
984962 wd.WriteLine("USER " + config.name + " 8 * :" + config.name);
985963 wd.WriteLine("NICK " + config.username);
986964 Authenticate();
987 - _Queue = new Thread(new ThreadStart(SlowQueue.Run));
 965+ _Queue = new Thread(SlowQueue.Run);
988966 foreach (config.channel ch in config.channels)
989967 {
990968 Thread.Sleep(2000);
@@ -1006,10 +984,10 @@
1007985 rd = new System.IO.StreamReader(data, System.Text.Encoding.UTF8);
1008986 wd = new System.IO.StreamWriter(data);
1009987
1010 - _Queue = new Thread(new ThreadStart(SlowQueue.Run));
1011 - dumphtmt = new Thread(new ThreadStart(HtmlDump.Start));
 988+ _Queue = new Thread(SlowQueue.Run);
 989+ dumphtmt = new Thread(HtmlDump.Start);
1012990 dumphtmt.Start();
1013 - check_thread = new Thread(new ThreadStart(Ping));
 991+ check_thread = new Thread(Ping);
1014992 check_thread.Start();
1015993
1016994 wd.WriteLine("USER " + config.name + " 8 * :" + config.name);
Index: trunk/tools/wmib/DumpHtm.cs
@@ -105,15 +105,14 @@
106106 {
107107 try
108108 {
109 - string text;
110 - text = CreateHeader();
 109+ string text = CreateHeader();
111110 text = text + "<table border=1 width=100%>\n<tr><td width=10%>Key</td><td>Value</td></tr>\n";
112111 Channel.Keys.locked = true;
113112 if (Channel.Keys.text.Count > 0)
114113 {
115114 foreach (dictionary.item Key in Channel.Keys.text)
116115 {
117 - text = text + AddLine(Key.key, Key.text);
 116+ text += AddLine(Key.key, Key.text);
118117 }
119118 }
120119 Channel.Keys.locked = false;

Status & tagging log