Index: trunk/tools/wmib/Core.cs |
— | — | @@ -125,10 +125,10 @@ |
126 | 126 | } |
127 | 127 | |
128 | 128 | /// <summary> |
129 | | - /// |
| 129 | + /// Delete user |
130 | 130 | /// </summary> |
131 | 131 | /// <param name="user">Regex</param> |
132 | | - /// <returns></returns> |
| 132 | + /// <returns>bool</returns> |
133 | 133 | public bool delUser(string user) |
134 | 134 | { |
135 | 135 | foreach (user u in Users) |
— | — | @@ -153,8 +153,8 @@ |
154 | 154 | /// <summary> |
155 | 155 | /// Return level |
156 | 156 | /// </summary> |
157 | | - /// <param name="level"></param> |
158 | | - /// <returns></returns> |
| 157 | + /// <param name="level">User level</param> |
| 158 | + /// <returns>0</returns> |
159 | 159 | private int getLevel(string level) |
160 | 160 | { |
161 | 161 | if (level == "admin") |
— | — | @@ -208,8 +208,8 @@ |
209 | 209 | /// <summary> |
210 | 210 | /// Check if user match the necessary level |
211 | 211 | /// </summary> |
212 | | - /// <param name="level"></param> |
213 | | - /// <param name="rights"></param> |
| 212 | + /// <param name="level">Permission level</param> |
| 213 | + /// <param name="rights">Userrights</param> |
214 | 214 | /// <returns></returns> |
215 | 215 | public bool matchLevel(int level, string rights) |
216 | 216 | { |
— | — | @@ -227,8 +227,8 @@ |
228 | 228 | /// <summary> |
229 | 229 | /// Check if user is approved to do operation requested |
230 | 230 | /// </summary> |
231 | | - /// <param name="User"></param> |
232 | | - /// <param name="Host"></param> |
| 231 | + /// <param name="User">Username</param> |
| 232 | + /// <param name="Host">Hostname</param> |
233 | 233 | /// <param name="command"></param> |
234 | 234 | /// <returns></returns> |
235 | 235 | public bool isApproved(string User, string Host, string command) |
— | — | @@ -282,10 +282,10 @@ |
283 | 283 | /// <summary> |
284 | 284 | /// Constructor |
285 | 285 | /// </summary> |
286 | | - /// <param name="Key"></param> |
287 | | - /// <param name="Text"></param> |
288 | | - /// <param name="User"></param> |
289 | | - /// <param name="Lock"></param> |
| 286 | + /// <param name="Key">Key</param> |
| 287 | + /// <param name="Text">Text of the key</param> |
| 288 | + /// <param name="User">User who created the key</param> |
| 289 | + /// <param name="Lock">If key is locked or not</param> |
290 | 290 | public item(string Key, string Text, string User, string Lock = "false") |
291 | 291 | { |
292 | 292 | text = Text; |
— | — | @@ -307,8 +307,8 @@ |
308 | 308 | /// <summary> |
309 | 309 | /// Constructor |
310 | 310 | /// </summary> |
311 | | - /// <param name="name"></param> |
312 | | - /// <param name="key"></param> |
| 311 | + /// <param name="name">Alias</param> |
| 312 | + /// <param name="key">Key</param> |
313 | 313 | public staticalias(string name, string key) |
314 | 314 | { |
315 | 315 | Name = name; |
— | — | @@ -350,7 +350,8 @@ |
351 | 351 | string name = info[0]; |
352 | 352 | if (type == "key") |
353 | 353 | { |
354 | | - text.Add(new item(name, value, "")); |
| 354 | + string locked = info[3]; |
| 355 | + text.Add(new item(name, value, "", locked)); |
355 | 356 | } |
356 | 357 | else |
357 | 358 | { |
— | — | @@ -399,7 +400,7 @@ |
400 | 401 | /// <summary> |
401 | 402 | /// Get value of key |
402 | 403 | /// </summary> |
403 | | - /// <param name="key"></param> |
| 404 | + /// <param name="key">Key</param> |
404 | 405 | /// <returns></returns> |
405 | 406 | public string getValue(string key) |
406 | 407 | { |
— | — | @@ -416,10 +417,10 @@ |
417 | 418 | /// <summary> |
418 | 419 | /// Print a value to channel if found this message doesn't need to be a valid command |
419 | 420 | /// </summary> |
420 | | - /// <param name="name"></param> |
421 | | - /// <param name="user"></param> |
422 | | - /// <param name="chan"></param> |
423 | | - /// <param name="host"></param> |
| 421 | + /// <param name="name">Name</param> |
| 422 | + /// <param name="user">User</param> |
| 423 | + /// <param name="chan">Channel</param> |
| 424 | + /// <param name="host">Host name</param> |
424 | 425 | /// <returns></returns> |
425 | 426 | public bool print(string name, string user, config.channel chan, string host) |
426 | 427 | { |
— | — | @@ -513,15 +514,19 @@ |
514 | 515 | name = name.Substring(0, name.IndexOf("|")); |
515 | 516 | } |
516 | 517 | string[] p = name.Split(' '); |
517 | | - string p1 = ""; |
518 | | - if (p.Length > 1) |
519 | | - { |
520 | | - p1 = p[1]; |
521 | | - } |
| 518 | + int parameters = p.Length; |
522 | 519 | string keyv = getValue(p[0]); |
523 | 520 | if (!(keyv == "")) |
524 | 521 | { |
525 | | - keyv = keyv.Replace("$1", p1); |
| 522 | + if ( parameters > 1) |
| 523 | + { |
| 524 | + int curr = 0; |
| 525 | + while ( parameters >= curr ) |
| 526 | + { |
| 527 | + curr++; |
| 528 | + keyv = keyv.Replace("$" + curr.ToString(), p[curr]); |
| 529 | + } |
| 530 | + } |
526 | 531 | if (User == "") |
527 | 532 | { |
528 | 533 | Message(keyv, Channel); |
— | — | @@ -538,7 +543,15 @@ |
539 | 544 | keyv = getValue(b.Key); |
540 | 545 | if (keyv != "") |
541 | 546 | { |
542 | | - keyv = keyv.Replace("$1", p1); |
| 547 | + if ( parameters > 1) |
| 548 | + { |
| 549 | + int curr = 0; |
| 550 | + while ( parameters >= curr ) |
| 551 | + { |
| 552 | + curr++; |
| 553 | + keyv = keyv.Replace("$" + curr.ToString(), p[curr]); |
| 554 | + } |
| 555 | + } |
543 | 556 | if (User == "") |
544 | 557 | { |
545 | 558 | Message(keyv, Channel); |
— | — | @@ -557,7 +570,7 @@ |
558 | 571 | /// <summary> |
559 | 572 | /// Search |
560 | 573 | /// </summary> |
561 | | - /// <param name="key"></param> |
| 574 | + /// <param name="key">Key</param> |
562 | 575 | /// <param name="Chan"></param> |
563 | 576 | public void RSearch(string key, config.channel Chan) |
564 | 577 | { |
— | — | @@ -623,9 +636,9 @@ |
624 | 637 | /// <summary> |
625 | 638 | /// Save a new key |
626 | 639 | /// </summary> |
627 | | - /// <param name="Text"></param> |
628 | | - /// <param name="key"></param> |
629 | | - /// <param name="user"></param> |
| 640 | + /// <param name="Text">Text</param> |
| 641 | + /// <param name="key">Key</param> |
| 642 | + /// <param name="user">User who created it</param> |
630 | 643 | public void setKey(string Text, string key, string user) |
631 | 644 | { |
632 | 645 | while (locked) |
— | — | @@ -655,9 +668,9 @@ |
656 | 669 | /// <summary> |
657 | 670 | /// Alias |
658 | 671 | /// </summary> |
659 | | - /// <param name="key"></param> |
660 | | - /// <param name="al"></param> |
661 | | - /// <param name="user"></param> |
| 672 | + /// <param name="key">Key</param> |
| 673 | + /// <param name="al">Alias</param> |
| 674 | + /// <param name="user">User</param> |
662 | 675 | public void aliasKey(string key, string al, string user) |
663 | 676 | { |
664 | 677 | foreach(staticalias stakey in this.Alias) |
— | — | @@ -709,7 +722,7 @@ |
710 | 723 | /// <summary> |
711 | 724 | /// Encode a data before saving it to a file |
712 | 725 | /// </summary> |
713 | | - /// <param name="text"></param> |
| 726 | + /// <param name="text">Text</param> |
714 | 727 | /// <returns></returns> |
715 | 728 | public static string encode(string text) |
716 | 729 | { |
— | — | @@ -734,7 +747,7 @@ |
735 | 748 | /// <summary> |
736 | 749 | /// Decode |
737 | 750 | /// </summary> |
738 | | - /// <param name="text"></param> |
| 751 | + /// <param name="text">String</param> |
739 | 752 | /// <returns></returns> |
740 | 753 | public static string decode(string text) |
741 | 754 | { |
— | — | @@ -744,8 +757,8 @@ |
745 | 758 | /// <summary> |
746 | 759 | /// Exceptions :o |
747 | 760 | /// </summary> |
748 | | - /// <param name="ex"></param> |
749 | | - /// <param name="chan"></param> |
| 761 | + /// <param name="ex">Exception pointer</param> |
| 762 | + /// <param name="chan">Channel name</param> |
750 | 763 | public static void handleException(Exception ex, string chan) |
751 | 764 | { |
752 | 765 | Message("DEBUG Exception: " + ex.Message + " I feel crushed, uh :|", chan); |
— | — | @@ -754,7 +767,7 @@ |
755 | 768 | /// <summary> |
756 | 769 | /// Get a channel object |
757 | 770 | /// </summary> |
758 | | - /// <param name="name"></param> |
| 771 | + /// <param name="name">Name</param> |
759 | 772 | /// <returns></returns> |
760 | 773 | public static config.channel getChannel(string name) |
761 | 774 | { |
— | — | @@ -768,6 +781,9 @@ |
769 | 782 | return null; |
770 | 783 | } |
771 | 784 | |
| 785 | + /// <summary> |
| 786 | + /// Convert the number to format we want to have in log |
| 787 | + /// </summary> |
772 | 788 | public static string timedateToString(int number) |
773 | 789 | { |
774 | 790 | if (number <= 9 && number >= 0) |
— | — | @@ -780,8 +796,8 @@ |
781 | 797 | /// <summary> |
782 | 798 | /// Send a message to channel |
783 | 799 | /// </summary> |
784 | | - /// <param name="message"></param> |
785 | | - /// <param name="channel"></param> |
| 800 | + /// <param name="message">Message</param> |
| 801 | + /// <param name="channel">Channel</param> |
786 | 802 | /// <returns></returns> |
787 | 803 | public static bool Message(string message, string channel) |
788 | 804 | { |
— | — | @@ -795,10 +811,10 @@ |
796 | 812 | /// <summary> |
797 | 813 | /// Change rights of user |
798 | 814 | /// </summary> |
799 | | - /// <param name="message"></param> |
800 | | - /// <param name="channel"></param> |
801 | | - /// <param name="user"></param> |
802 | | - /// <param name="host"></param> |
| 815 | + /// <param name="message">Message</param> |
| 816 | + /// <param name="channel">Channel</param> |
| 817 | + /// <param name="user">User</param> |
| 818 | + /// <param name="host">Host</param> |
803 | 819 | /// <returns></returns> |
804 | 820 | public static int modifyRights(string message, config.channel channel, string user, string host) |
805 | 821 | { |
— | — | @@ -871,11 +887,11 @@ |
872 | 888 | /// <summary> |
873 | 889 | /// Log file |
874 | 890 | /// </summary> |
875 | | - /// <param name="message"></param> |
876 | | - /// <param name="channel"></param> |
877 | | - /// <param name="user"></param> |
878 | | - /// <param name="host"></param> |
879 | | - /// <param name="noac"></param> |
| 891 | + /// <param name="message">Message</param> |
| 892 | + /// <param name="channel">Channel</param> |
| 893 | + /// <param name="user">User</param> |
| 894 | + /// <param name="host">Host</param> |
| 895 | + /// <param name="noac">Action (if true it's logged as message, if false it's action)</param> |
880 | 896 | public static void chanLog(string message, config.channel channel, string user, string host, bool noac = true) |
881 | 897 | { |
882 | 898 | try |
— | — | @@ -904,10 +920,10 @@ |
905 | 921 | /// <summary> |
906 | 922 | /// Called on action |
907 | 923 | /// </summary> |
908 | | - /// <param name="message"></param> |
909 | | - /// <param name="Channel"></param> |
910 | | - /// <param name="host"></param> |
911 | | - /// <param name="nick"></param> |
| 924 | + /// <param name="message">Message</param> |
| 925 | + /// <param name="Channel">Channel</param> |
| 926 | + /// <param name="host">Host</param> |
| 927 | + /// <param name="nick">Nick</param> |
912 | 928 | /// <returns></returns> |
913 | 929 | public static bool getAction(string message, string Channel, string host, string nick) |
914 | 930 | { |
— | — | @@ -919,10 +935,10 @@ |
920 | 936 | /// <summary> |
921 | 937 | /// |
922 | 938 | /// </summary> |
923 | | - /// <param name="chan"></param> |
924 | | - /// <param name="user"></param> |
925 | | - /// <param name="host"></param> |
926 | | - /// <param name="message"></param> |
| 939 | + /// <param name="chan">Channel</param> |
| 940 | + /// <param name="user">User</param> |
| 941 | + /// <param name="host">Host</param> |
| 942 | + /// <param name="message">Message</param> |
927 | 943 | public static void addChannel(config.channel chan, string user, string host, string message) |
928 | 944 | { |
929 | 945 | if (message.StartsWith("@add")) |
— | — | @@ -1131,10 +1147,10 @@ |
1132 | 1148 | /// <summary> |
1133 | 1149 | /// Called when someone post a message to server |
1134 | 1150 | /// </summary> |
1135 | | - /// <param name="channel"></param> |
1136 | | - /// <param name="nick"></param> |
1137 | | - /// <param name="host"></param> |
1138 | | - /// <param name="message"></param> |
| 1151 | + /// <param name="channel">Channel</param> |
| 1152 | + /// <param name="nick">Nick</param> |
| 1153 | + /// <param name="host">Host</param> |
| 1154 | + /// <param name="message">Message</param> |
1139 | 1155 | /// <returns></returns> |
1140 | 1156 | public static bool getMessage(string channel, string nick, string host, string message) |
1141 | 1157 | { |