r106486 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106485‎ | r106486 | r106487 >
Date:23:21, 16 December 2011
Author:petrb
Status:deferred
Tags:
Comment:
Fixed a bug in key parsing where index was out of array
Modified paths:
  • /trunk/tools/wmib/Config.cs (modified) (history)
  • /trunk/tools/wmib/Core.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/Config.cs
@@ -140,6 +140,7 @@
141141 AddConfig("username", username);
142142 AddConfig("password", password);
143143 AddConfig("network", network);
 144+ AddConfig("debug", debugchan);
144145 AddConfig("nick", login);
145146 text = text + "\nchannels=";
146147 foreach (channel current in channels)
@@ -185,6 +186,7 @@
186187 username = parseConfig(text, "username");
187188 network = parseConfig(text, "network");
188189 login = parseConfig(text, "nick");
 190+ debugchan = parseConfig(text, "debug");
189191 password = parseConfig(text, "password");
190192 if (!System.IO.Directory.Exists(config.DumpDir))
191193 {
@@ -200,6 +202,7 @@
201203 /// Nick name
202204 /// </summary>
203205 public static string username = "wm-bot";
 206+ public static string debugchan = "";
204207 /// <summary>
205208 /// Login name
206209 /// </summary>
Index: trunk/tools/wmib/Core.cs
@@ -520,11 +520,11 @@
521521 {
522522 if ( parameters > 1)
523523 {
524 - int curr = 0;
525 - while ( parameters >= curr )
 524+ int curr = 1;
 525+ while ( parameters > curr )
526526 {
527 - curr++;
528527 keyv = keyv.Replace("$" + curr.ToString(), p[curr]);
 528+ curr++;
529529 }
530530 }
531531 if (User == "")
@@ -761,7 +761,11 @@
762762 /// <param name="chan">Channel name</param>
763763 public static void handleException(Exception ex, string chan)
764764 {
765 - Message("DEBUG Exception: " + ex.Message + " I feel crushed, uh :|", chan);
 765+ if (config.debugchan != null)
 766+ {
 767+ Message("DEBUG Exception: " + ex.Message + " I feel crushed, uh :|", config.debugchan);
 768+ }
 769+ Program.Log(ex.Message + ex.Source + ex.StackTrace);
766770 }
767771
768772 /// <summary>
@@ -1063,6 +1067,7 @@
10641068 if (!chan.logged)
10651069 {
10661070 Message("Channel was already not logged", chan.name);
 1071+ return;
10671072 }
10681073 else
10691074 {
@@ -1085,6 +1090,7 @@
10861091 channels = channels + a.name + ", ";
10871092 }
10881093 Message("I am now in following channels: " + channels, chan.name);
 1094+ return;
10891095 }
10901096 if (message.StartsWith("@infobot-off"))
10911097 {
@@ -1105,6 +1111,7 @@
11061112 else
11071113 {
11081114 Message("Permission denied", chan.name);
 1115+ return;
11091116 }
11101117 }
11111118 if (message.StartsWith("@infobot-on"))
@@ -1130,18 +1137,8 @@
11311138 }
11321139 if (message.StartsWith("@commands"))
11331140 {
1134 - Message("Commands: channellist, trusted, trustadd, trustdel, infobot-off, infobot-on, drop, add, flush, logon, logoff", chan.name);
 1141+ Message("Commands: channellist, trusted, trustadd, trustdel, infobot-off, infobot-on, drop, add, reload, logon, logoff", chan.name);
11351142 }
1136 -
1137 - if (message.StartsWith("@channellist"))
1138 - {
1139 - string channels = "";
1140 - foreach (config.channel a in config.channels)
1141 - {
1142 - channels = channels + a.name + ", ";
1143 - }
1144 - Message("I am now in following channels: " + channels, chan.name);
1145 - }
11461143 }
11471144
11481145 /// <summary>

Status & tagging log