r106358 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r106357‎ | r106358 | r106359 >
Date:19:08, 15 December 2011
Author:petrb
Status:deferred (Comments)
Tags:
Comment:
implemented some new stuff
Modified paths:
  • /trunk/tools/wmib/Config.cs (modified) (history)
  • /trunk/tools/wmib/Core.cs (modified) (history)
  • /trunk/tools/wmib/DumpHtm.cs (modified) (history)

Diff [purge]

Index: trunk/tools/wmib/DumpHtm.cs
@@ -18,9 +18,15 @@
1919
2020 namespace wmib
2121 {
22 -public class HtmlDump
 22+ public class HtmlDump
2323 {
 24+ /// <summary>
 25+ /// Channel name
 26+ /// </summary>
2427 public config.channel Channel;
 28+ /// <summary>
 29+ /// Dump
 30+ /// </summary>
2531 public string dumpname;
2632 // This function is called on start of bot
2733 public static void Start()
@@ -39,29 +45,60 @@
4046 System.Threading.Thread.Sleep(320000);
4147 }
4248 }
 49+ /// <summary>
 50+ /// Constructor
 51+ /// </summary>
 52+ /// <param name="channel"></param>
4353 public HtmlDump(config.channel channel)
4454 {
4555 dumpname = config.DumpDir + "/" + channel.name + ".htm";
4656 Channel = channel;
4757 }
 58+
 59+ /// <summary>
 60+ /// Html code
 61+ /// </summary>
 62+ /// <returns></returns>
4863 public string CreateFooter()
4964 {
5065 return "</body></html>\n";
5166 }
 67+
 68+ /// <summary>
 69+ /// Html
 70+ /// </summary>
 71+ /// <returns></returns>
5272 public string CreateHeader()
5373 {
54 - return "<html><head></head><body>\n";
 74+ return "<html><head><title>"+ Channel.name +"</title></head><body>\n";
5575 }
 76+
 77+ /// <summary>
 78+ /// Remove html
 79+ /// </summary>
 80+ /// <param name="text"></param>
 81+ /// <returns></returns>
5682 public string Encode(string text)
5783 {
5884 text = text.Replace("<", "&lt;");
5985 text = text.Replace(">", "&gt;");
6086 return text;
6187 }
 88+
 89+ /// <summary>
 90+ /// Insert another table row
 91+ /// </summary>
 92+ /// <param name="name"></param>
 93+ /// <param name="value"></param>
 94+ /// <returns></returns>
6295 public string AddLine(string name, string value)
6396 {
6497 return "<tr><td>" + Encode(name) + "</td><td>" + Encode(value) + "</td></tr>\n";
6598 }
 99+
 100+ /// <summary>
 101+ /// Generate a dump file
 102+ /// </summary>
66103 public void Make()
67104 {
68105 try
@@ -81,7 +118,8 @@
82119 text = text + "<table>\n";
83120 text = text + CreateFooter();
84121 System.IO.File.WriteAllText(dumpname, text);
85 - } catch (Exception b)
 122+ }
 123+ catch (Exception b)
86124 {
87125 Channel.Keys.locked = false;
88126 Console.WriteLine(b.Message);
Index: trunk/tools/wmib/Config.cs
@@ -20,39 +20,48 @@
2121 {
2222 public static class config
2323 {
24 - public static string text;
25 - private static void AddConfig(string a, string b)
26 - {
27 - text = text + "\n" + a + "=" + b + ";";
28 - }
29 - public static void Save()
30 - {
31 - text ="";
32 - AddConfig("username", username);
33 - AddConfig("password", password);
34 - AddConfig("network", network);
35 - AddConfig("nick", login);
36 - text = text + "\nchannels=";
37 - foreach (channel current in channels)
38 - {
39 - text = text + current.name + ",\n";
40 - }
41 - text = text + ";";
42 - System.IO.File.WriteAllText("wmib", text);
43 - }
4424 public class channel
4525 {
 26+ /// <summary>
 27+ /// Channel name
 28+ /// </summary>
4629 public string name;
4730 public bool logged;
 31+ /// <summary>
 32+ /// Log
 33+ /// </summary>
4834 public string log;
 35+ public bool info;
 36+ /// <summary>
 37+ /// Keys
 38+ /// </summary>
4939 public irc.dictionary Keys;
 40+ /// <summary>
 41+ /// Configuration text
 42+ /// </summary>
5043 private string conf;
 44+ /// <summary>
 45+ /// Users
 46+ /// </summary>
5147 public irc.IRCTrust Users;
 48+ /// <summary>
 49+ /// Path of db
 50+ /// </summary>
5251 public string keydb = "";
 52+
 53+ /// <summary>
 54+ /// Add a line to config
 55+ /// </summary>
 56+ /// <param name="a">Name of key</param>
 57+ /// <param name="b">Value</param>
5358 private void AddConfig(string a, string b)
5459 {
5560 conf = conf + "\n" + a + "=" + b + ";";
5661 }
 62+
 63+ /// <summary>
 64+ /// Load config of channel :)
 65+ /// </summary>
5766 public void LoadConfig()
5867 {
5968 string conf_file = name + ".setting";
@@ -71,19 +80,33 @@
7281 {
7382 logged = bool.Parse(config.parseConfig(conf, "logged"));
7483 }
 84+ if (config.parseConfig(conf, "infodb") != "")
 85+ {
 86+ info = bool.Parse(config.parseConfig(conf, "infodb"));
 87+ }
7588 }
7689
 90+ /// <summary>
 91+ /// Save config
 92+ /// </summary>
7793 public void SaveConfig()
7894 {
7995 conf = "";
 96+ AddConfig("infodb", info.ToString());
 97+ AddConfig("logged", logged.ToString());
8098 AddConfig("keysdb", keydb);
81 - AddConfig("logged", logged.ToString());
8299 System.IO.File.WriteAllText(name + ".setting", conf);
83100 }
 101+
 102+ /// <summary>
 103+ /// Constructor
 104+ /// </summary>
 105+ /// <param name="Name">Channel</param>
84106 public channel(string Name)
85107 {
86108 conf = "";
87109 keydb = Name + ".db";
 110+ info = true;
88111 logged = true;
89112 name = Name;
90113 LoadConfig();
@@ -101,6 +124,38 @@
102125 }
103126 }
104127
 128+ /// <summary>
 129+ /// Add line to the config file
 130+ /// </summary>
 131+ /// <param name="a"></param>
 132+ /// <param name="b"></param>
 133+ private static void AddConfig(string a, string b)
 134+ {
 135+ text = text + "\n" + a + "=" + b + ";";
 136+ }
 137+
 138+ public static void Save()
 139+ {
 140+ text = "";
 141+ AddConfig("username", username);
 142+ AddConfig("password", password);
 143+ AddConfig("network", network);
 144+ AddConfig("nick", login);
 145+ text = text + "\nchannels=";
 146+ foreach (channel current in channels)
 147+ {
 148+ text = text + current.name + ",\n";
 149+ }
 150+ text = text + ";";
 151+ System.IO.File.WriteAllText("wmib", text);
 152+ }
 153+
 154+ /// <summary>
 155+ /// Parse config data text
 156+ /// </summary>
 157+ /// <param name="text"></param>
 158+ /// <param name="name"></param>
 159+ /// <returns></returns>
105160 public static string parseConfig(string text, string name)
106161 {
107162 if (text.Contains(name))
@@ -113,6 +168,9 @@
114169 return "";
115170 }
116171
 172+ /// <summary>
 173+ /// Load config of bot
 174+ /// </summary>
117175 public static void Load()
118176 {
119177 text = System.IO.File.ReadAllText("wmib");
@@ -133,6 +191,7 @@
134192 System.IO.Directory.CreateDirectory(config.DumpDir);
135193 }
136194 }
 195+ public static string text;
137196 /// <summary>
138197 /// Network
139198 /// </summary>
@@ -141,13 +200,25 @@
142201 /// Nick name
143202 /// </summary>
144203 public static string username = "wm-bot";
 204+ /// <summary>
 205+ /// Login name
 206+ /// </summary>
145207 public static string login = "";
 208+ /// <summary>
 209+ /// Login pw
 210+ /// </summary>
146211 public static string password = "";
 212+ /// <summary>
 213+ /// Dump
 214+ /// </summary>
147215 public static string DumpDir = "dump";
148216 /// <summary>
149217 /// Version
150218 /// </summary>
151219 public static string version = "wikimedia bot v. 1.1.4";
 220+ /// <summary>
 221+ /// Separator
 222+ /// </summary>
152223 public static string separator = "|";
153224 /// <summary>
154225 /// User name
Index: trunk/tools/wmib/Core.cs
@@ -25,53 +25,47 @@
2626 private static System.IO.StreamWriter wd;
2727 private static List<user> User = new List<user>();
2828
29 - public static void Ping()
30 - {
31 - while (true)
32 - {
33 - System.Threading.Thread.Sleep(20000);
34 - wd.WriteLine("PING :" + config.network);
35 - wd.Flush();
36 - }
37 - }
38 -
39 - public static string encode(string text)
40 - {
41 - return text.Replace(config.separator, "<separator>");
42 - }
43 -
44 - public static bool Authenticate()
45 - {
46 - if (config.login != "")
47 - {
48 - wd.WriteLine("PRIVMSG nickserv :identify " + config.login + " " + config.password);
49 - wd.Flush();
50 - System.Threading.Thread.Sleep(4000);
51 - }
52 - return true;
53 - }
54 -
55 - public static string decode(string text)
56 - {
57 - return text.Replace("<separator>", config.separator);
58 - }
59 -
6029 public class user
6130 {
 31+ /// <summary>
 32+ /// Regex
 33+ /// </summary>
 34+ public string name;
 35+ /// <summary>
 36+ /// Level
 37+ /// </summary>
 38+ public string level;
 39+ /// <summary>
 40+ /// Constructor
 41+ /// </summary>
 42+ /// <param name="level"></param>
 43+ /// <param name="name"></param>
6244 public user(string level, string name)
6345 {
6446 this.level = level;
6547 this.name = name;
6648 }
67 - public string name;
68 - public string level;
6949 }
7050
7151 public class IRCTrust
7252 {
 53+ /// <summary>
 54+ /// List of all users in a channel
 55+ /// </summary>
7356 private List<user> Users = new List<user>();
 57+ /// <summary>
 58+ /// Channel this class belong to
 59+ /// </summary>
7460 public string _Channel;
 61+ /// <summary>
 62+ /// File where data are stored
 63+ /// </summary>
7564 public string File;
 65+
 66+ /// <summary>
 67+ /// Constructor
 68+ /// </summary>
 69+ /// <param name="channel"></param>
7670 public IRCTrust(string channel)
7771 {
7872 // Load
@@ -95,6 +89,11 @@
9690 }
9791 }
9892 }
 93+
 94+ /// <summary>
 95+ /// Save
 96+ /// </summary>
 97+ /// <returns></returns>
9998 public bool Save()
10099 {
101100 System.IO.File.WriteAllText(File, "");
@@ -105,6 +104,12 @@
106105 return true;
107106 }
108107
 108+ /// <summary>
 109+ /// New
 110+ /// </summary>
 111+ /// <param name="level">Level</param>
 112+ /// <param name="user">Regex</param>
 113+ /// <returns></returns>
109114 public bool addUser(string level, string user)
110115 {
111116 foreach (user u in Users)
@@ -119,6 +124,11 @@
120125 return true;
121126 }
122127
 128+ /// <summary>
 129+ ///
 130+ /// </summary>
 131+ /// <param name="user">Regex</param>
 132+ /// <returns></returns>
123133 public bool delUser(string user)
124134 {
125135 foreach (user u in Users)
@@ -140,6 +150,11 @@
141151 return true;
142152 }
143153
 154+ /// <summary>
 155+ /// Return level
 156+ /// </summary>
 157+ /// <param name="level"></param>
 158+ /// <returns></returns>
144159 private int getLevel(string level)
145160 {
146161 if (level == "admin")
@@ -153,6 +168,11 @@
154169 return 0;
155170 }
156171
 172+ /// <summary>
 173+ /// Return user object from a name
 174+ /// </summary>
 175+ /// <param name="user"></param>
 176+ /// <returns></returns>
157177 public user getUser(string user)
158178 {
159179 user lv = new user("null", "");
@@ -172,6 +192,9 @@
173193 return lv;
174194 }
175195
 196+ /// <summary>
 197+ /// List all users to a channel
 198+ /// </summary>
176199 public void listAll()
177200 {
178201 string users_ok = "";
@@ -182,6 +205,12 @@
183206 Message("I trust: " + users_ok, _Channel);
184207 }
185208
 209+ /// <summary>
 210+ /// Check if user match the necessary level
 211+ /// </summary>
 212+ /// <param name="level"></param>
 213+ /// <param name="rights"></param>
 214+ /// <returns></returns>
186215 public bool matchLevel(int level, string rights)
187216 {
188217 if (level == 2)
@@ -195,6 +224,13 @@
196225 return false;
197226 }
198227
 228+ /// <summary>
 229+ /// Check if user is approved to do operation requested
 230+ /// </summary>
 231+ /// <param name="User"></param>
 232+ /// <param name="Host"></param>
 233+ /// <param name="command"></param>
 234+ /// <returns></returns>
199235 public bool isApproved(string User, string Host, string command)
200236 {
201237 user current = getUser(User + "!@" + Host);
@@ -221,12 +257,35 @@
222258
223259 public class dictionary
224260 {
 261+ /// <summary>
 262+ /// Data file
 263+ /// </summary>
225264 public string datafile = "";
226265 // if we need to update dump
227266 public bool update = true;
 267+ /// <summary>
 268+ /// Locked
 269+ /// </summary>
228270 public bool locked = false;
229271 public class item
230272 {
 273+ /// <summary>
 274+ /// Text
 275+ /// </summary>
 276+ public string text;
 277+ /// <summary>
 278+ /// Key
 279+ /// </summary>
 280+ public string key;
 281+ public string user;
 282+ public string locked;
 283+ /// <summary>
 284+ /// Constructor
 285+ /// </summary>
 286+ /// <param name="Key"></param>
 287+ /// <param name="Text"></param>
 288+ /// <param name="User"></param>
 289+ /// <param name="Lock"></param>
231290 public item(string Key, string Text, string User, string Lock = "false")
232291 {
233292 text = Text;
@@ -234,24 +293,43 @@
235294 locked = Lock;
236295 user = User;
237296 }
238 - public string text;
239 - public string key;
240 - public string user;
241 - public string locked;
242297 }
243298 public class staticalias
244299 {
 300+ /// <summary>
 301+ /// Name
 302+ /// </summary>
245303 public string Name;
 304+ /// <summary>
 305+ /// Key
 306+ /// </summary>
246307 public string Key;
 308+ /// <summary>
 309+ /// Constructor
 310+ /// </summary>
 311+ /// <param name="name"></param>
 312+ /// <param name="key"></param>
247313 public staticalias(string name, string key)
248314 {
249315 Name = name;
250316 Key = key;
251317 }
252318 }
 319+ /// <summary>
 320+ /// List of all items in class
 321+ /// </summary>
253322 public List<item> text = new List<item>();
 323+ /// <summary>
 324+ /// List of all aliases we want to use
 325+ /// </summary>
254326 public List<staticalias> Alias = new List<staticalias>();
 327+ /// <summary>
 328+ /// Channel name
 329+ /// </summary>
255330 public string Channel;
 331+ /// <summary>
 332+ /// Load it
 333+ /// </summary>
256334 public void Load()
257335 {
258336 text.Clear();
@@ -282,6 +360,11 @@
283361 }
284362 }
285363
 364+ /// <summary>
 365+ /// Constructor
 366+ /// </summary>
 367+ /// <param name="database"></param>
 368+ /// <param name="channel"></param>
286369 public dictionary(string database, string channel)
287370 {
288371 datafile = database;
@@ -289,6 +372,9 @@
290373 Load();
291374 }
292375
 376+ /// <summary>
 377+ /// Save to a file
 378+ /// </summary>
293379 public void Save()
294380 {
295381 update = true;
@@ -310,6 +396,11 @@
311397 }
312398 }
313399
 400+ /// <summary>
 401+ /// Get value of key
 402+ /// </summary>
 403+ /// <param name="key"></param>
 404+ /// <returns></returns>
314405 public string getValue(string key)
315406 {
316407 foreach (item data in text)
@@ -322,6 +413,14 @@
323414 return "";
324415 }
325416
 417+ /// <summary>
 418+ /// Print a value to channel if found this message doesn't need to be a valid command
 419+ /// </summary>
 420+ /// <param name="name"></param>
 421+ /// <param name="user"></param>
 422+ /// <param name="chan"></param>
 423+ /// <param name="host"></param>
 424+ /// <returns></returns>
326425 public bool print(string name, string user, config.channel chan, string host)
327426 {
328427 if (!name.StartsWith("!"))
@@ -356,7 +455,12 @@
357456 config.channel _Chan = getChannel(Channel);
358457 if (chan.Users.isApproved(user, host, "info"))
359458 {
360 - this.aliasKey(name.Substring(name.IndexOf("alias") + 6), parm[0], "");
 459+ if (parm.Length < 3)
 460+ {
 461+ Message("It would be cool to give me also a name of key", Channel);
 462+ return true;
 463+ }
 464+ this.aliasKey(name.Substring(name.IndexOf(" alias") + 7), parm[0], "");
361465 }
362466 else
363467 {
@@ -379,6 +483,7 @@
380484 return false;
381485 }
382486 }
 487+ return false;
383488 }
384489 else
385490 {
@@ -449,6 +554,11 @@
450555 return true;
451556 }
452557
 558+ /// <summary>
 559+ /// Search
 560+ /// </summary>
 561+ /// <param name="key"></param>
 562+ /// <param name="Chan"></param>
453563 public void RSearch(string key, config.channel Chan)
454564 {
455565 if (!key.StartsWith("@regsearch"))
@@ -510,6 +620,12 @@
511621 }
512622 }
513623
 624+ /// <summary>
 625+ /// Save a new key
 626+ /// </summary>
 627+ /// <param name="Text"></param>
 628+ /// <param name="key"></param>
 629+ /// <param name="user"></param>
514630 public void setKey(string Text, string key, string user)
515631 {
516632 while (locked)
@@ -535,6 +651,13 @@
536652 handleException(b, Channel);
537653 }
538654 }
 655+
 656+ /// <summary>
 657+ /// Alias
 658+ /// </summary>
 659+ /// <param name="key"></param>
 660+ /// <param name="al"></param>
 661+ /// <param name="user"></param>
539662 public void aliasKey(string key, string al, string user)
540663 {
541664 foreach(staticalias stakey in this.Alias)
@@ -549,6 +672,7 @@
550673 Message("Successfully created", Channel);
551674 Save();
552675 }
 676+
553677 public void rmKey(string key, string user)
554678 {
555679 while (locked)
@@ -569,11 +693,69 @@
570694 }
571695 }
572696
 697+ /// <summary>
 698+ /// Ping
 699+ /// </summary>
 700+ public static void Ping()
 701+ {
 702+ while (true)
 703+ {
 704+ System.Threading.Thread.Sleep(20000);
 705+ wd.WriteLine("PING :" + config.network);
 706+ wd.Flush();
 707+ }
 708+ }
 709+
 710+ /// <summary>
 711+ /// Encode a data before saving it to a file
 712+ /// </summary>
 713+ /// <param name="text"></param>
 714+ /// <returns></returns>
 715+ public static string encode(string text)
 716+ {
 717+ return text.Replace(config.separator, "<separator>");
 718+ }
 719+
 720+ /// <summary>
 721+ /// Nickserv
 722+ /// </summary>
 723+ /// <returns></returns>
 724+ public static bool Authenticate()
 725+ {
 726+ if (config.login != "")
 727+ {
 728+ wd.WriteLine("PRIVMSG nickserv :identify " + config.login + " " + config.password);
 729+ wd.Flush();
 730+ System.Threading.Thread.Sleep(4000);
 731+ }
 732+ return true;
 733+ }
 734+
 735+ /// <summary>
 736+ /// Decode
 737+ /// </summary>
 738+ /// <param name="text"></param>
 739+ /// <returns></returns>
 740+ public static string decode(string text)
 741+ {
 742+ return text.Replace("<separator>", config.separator);
 743+ }
 744+
 745+ /// <summary>
 746+ /// Exceptions :o
 747+ /// </summary>
 748+ /// <param name="ex"></param>
 749+ /// <param name="chan"></param>
573750 public static void handleException(Exception ex, string chan)
574751 {
575752 Message("DEBUG Exception: " + ex.Message + " I feel crushed, uh :|", chan);
576753 }
577754
 755+ /// <summary>
 756+ /// Get a channel object
 757+ /// </summary>
 758+ /// <param name="name"></param>
 759+ /// <returns></returns>
578760 public static config.channel getChannel(string name)
579761 {
580762 foreach (config.channel current in config.channels)
@@ -586,6 +768,12 @@
587769 return null;
588770 }
589771
 772+ /// <summary>
 773+ /// Send a message to channel
 774+ /// </summary>
 775+ /// <param name="message"></param>
 776+ /// <param name="channel"></param>
 777+ /// <returns></returns>
590778 public static bool Message(string message, string channel)
591779 {
592780 wd.WriteLine("PRIVMSG " + channel + " :" + message);
@@ -593,6 +781,14 @@
594782 return true;
595783 }
596784
 785+ /// <summary>
 786+ /// Change rights of user
 787+ /// </summary>
 788+ /// <param name="message"></param>
 789+ /// <param name="channel"></param>
 790+ /// <param name="user"></param>
 791+ /// <param name="host"></param>
 792+ /// <returns></returns>
597793 public static int modifyRights(string message, config.channel channel, string user, string host)
598794 {
599795 try
@@ -661,6 +857,14 @@
662858 return 0;
663859 }
664860
 861+ /// <summary>
 862+ /// Log file
 863+ /// </summary>
 864+ /// <param name="message"></param>
 865+ /// <param name="channel"></param>
 866+ /// <param name="user"></param>
 867+ /// <param name="host"></param>
 868+ /// <param name="noac"></param>
665869 public static void chanLog(string message, config.channel channel, string user, string host, bool noac = true)
666870 {
667871 try
@@ -686,6 +890,14 @@
687891 }
688892 }
689893
 894+ /// <summary>
 895+ /// Called on action
 896+ /// </summary>
 897+ /// <param name="message"></param>
 898+ /// <param name="Channel"></param>
 899+ /// <param name="host"></param>
 900+ /// <param name="nick"></param>
 901+ /// <returns></returns>
690902 public static bool getAction(string message, string Channel, string host, string nick)
691903 {
692904 config.channel curr = getChannel(Channel);
@@ -693,6 +905,13 @@
694906 return false;
695907 }
696908
 909+ /// <summary>
 910+ ///
 911+ /// </summary>
 912+ /// <param name="chan"></param>
 913+ /// <param name="user"></param>
 914+ /// <param name="host"></param>
 915+ /// <param name="message"></param>
697916 public static void addChannel(config.channel chan, string user, string host, string message)
698917 {
699918 if (message.StartsWith("@add"))
@@ -720,7 +939,7 @@
721940 wd.Flush();
722941 System.Threading.Thread.Sleep(100);
723942 config.channel Chan = getChannel(channel);
724 - Chan.Users.addUser("admin", user + ".*" + host );
 943+ Chan.Users.addUser("admin", user + "!.*@" + host );
725944 } else
726945 {
727946 Message("Invalid name", chan.name);
@@ -732,8 +951,32 @@
733952 }
734953 }
735954
 955+ /// <summary>
 956+ /// Part a channel
 957+ /// </summary>
 958+ /// <param name="chan">Channel object</param>
 959+ /// <param name="user">User</param>
 960+ /// <param name="host">Host</param>
 961+ /// <param name="message">Message</param>
736962 public static void partChannel(config.channel chan, string user, string host, string message)
737963 {
 964+ if (message.StartsWith("@drop"))
 965+ {
 966+ if (chan.Users.isApproved(user, host, "admin"))
 967+ {
 968+ wd.WriteLine("PART " + chan.name);
 969+ System.Threading.Thread.Sleep(100);
 970+ System.IO.File.Delete(chan.Users.File);
 971+ wd.Flush();
 972+ System.IO.File.Delete(chan.name + ".setting");
 973+ config.channels.Remove(chan);
 974+ config.Save();
 975+ }
 976+ else
 977+ {
 978+ Message("Permission denied", chan.name);
 979+ }
 980+ }
738981 if (message.StartsWith("@part"))
739982 {
740983 if (chan.Users.isApproved(user, host, "admin"))
@@ -816,15 +1059,79 @@
8171060 }
8181061 Message("I am now in following channels: " + channels, chan.name);
8191062 }
 1063+ if (message.StartsWith("@infobot-off"))
 1064+ {
 1065+ if (chan.Users.isApproved(user, host, "admin"))
 1066+ {
 1067+ if (!chan.info)
 1068+ {
 1069+ Message("Channel had infobot disabled", chan.name);
 1070+ }
 1071+ else
 1072+ {
 1073+ Message("Infobot disabled", chan.name);
 1074+ chan.info = false;
 1075+ chan.SaveConfig();
 1076+ config.Save();
 1077+ }
 1078+ }
 1079+ else
 1080+ {
 1081+ Message("Permission denied", chan.name);
 1082+ }
 1083+ }
 1084+ if (message.StartsWith("@infobot-on"))
 1085+ {
 1086+ if (chan.Users.isApproved(user, host, "admin"))
 1087+ {
 1088+ if (!chan.logged)
 1089+ {
 1090+ Message("Infobot was already enabled :O", chan.name);
 1091+ }
 1092+ else
 1093+ {
 1094+ chan.info = true;
 1095+ config.Save();
 1096+ chan.SaveConfig();
 1097+ Message("Infobot enabled", chan.name);
 1098+ }
 1099+ }
 1100+ else
 1101+ {
 1102+ Message("Permission denied", chan.name);
 1103+ }
 1104+ }
 1105+ if (message.StartsWith("@commands"))
 1106+ {
 1107+ Message("Commands: channellist, trusted, trustadd, trustdel, infobot-off, infobot-on, drop, add, flush, logon, logoff", chan.name);
 1108+ }
 1109+
 1110+ if (message.StartsWith("@channellist"))
 1111+ {
 1112+ string channels = "";
 1113+ foreach (config.channel a in config.channels)
 1114+ {
 1115+ channels = channels + a.name + ", ";
 1116+ }
 1117+ Message("I am now in following channels: " + channels, chan.name);
 1118+ }
8201119 }
8211120
 1121+ /// <summary>
 1122+ /// Called when someone post a message to server
 1123+ /// </summary>
 1124+ /// <param name="channel"></param>
 1125+ /// <param name="nick"></param>
 1126+ /// <param name="host"></param>
 1127+ /// <param name="message"></param>
 1128+ /// <returns></returns>
8221129 public static bool getMessage(string channel, string nick, string host, string message)
8231130 {
8241131 config.channel curr = getChannel(channel);
8251132 if (curr != null)
8261133 {
8271134 chanLog(message, curr, nick, host);
828 - if (message.StartsWith("!"))
 1135+ if (message.StartsWith("!") && curr.info)
8291136 {
8301137 curr.Keys.print(message, nick, curr, host);
8311138 }
@@ -839,12 +1146,13 @@
8401147 }
8411148 }
8421149
843 -
844 -
845 -
8461150 return false;
8471151 }
8481152
 1153+ /// <summary>
 1154+ /// Connection
 1155+ /// </summary>
 1156+ /// <returns></returns>
8491157 public static bool Reconnect()
8501158 {
8511159 data = new System.Net.Sockets.TcpClient(config.network, 6667).GetStream();
@@ -862,6 +1170,10 @@
8631171 return false;
8641172 }
8651173
 1174+ /// <summary>
 1175+ /// Connection
 1176+ /// </summary>
 1177+ /// <returns></returns>
8661178 public static int Connect()
8671179 {
8681180 data = new System.Net.Sockets.TcpClient(config.network, 6667).GetStream();
@@ -932,7 +1244,7 @@
9331245 message = message.Substring(message.IndexOf(":") + 1);
9341246 if (message.Contains(delimiter.ToString() + "ACTION"))
9351247 {
936 - getAction(message.Replace("", "").Replace(delimiter.ToString() +"ACTION ", ""), channel, host, nick);
 1248+ getAction(message.Replace(delimiter.ToString() +"ACTION", ""), channel, host, nick);
9371249 continue;
9381250 }
9391251 else

Comments

#Comment by Nikerabbit (talk | contribs)   10:38, 16 December 2011

Lol XML for method documentation? So we are wasting programmers time for something that machines could do for us.

#Comment by Petrb (talk | contribs)   12:45, 16 December 2011

this is cool feature of visual studio

#Comment by 😂 (talk | contribs)   15:04, 16 December 2011

XML is hard to read :(

#Comment by Petrb (talk | contribs)   15:06, 16 December 2011

actually it's easy to read for IDE :) it generates on the fly documentation of functions based on this which is displayed when you roll over any function or variable

#Comment by Reedy (talk | contribs)   15:07, 16 December 2011
+        /// <returns></returns>
         public static bool getMessage(string channel, string nick, string host, string message)

Considering it's a typed language, you think it could pick up from the method definition what it was returning...

Status & tagging log