1 | static O mainBot; |
2 | |
3 | public static Dictionary<string, int> UserPostCounts = new Dictionary<string, int>(); |
4 | |
5 | public static string LevelUp() |
6 | { |
7 | string username = cast callOpt(mainBot, "getUserName"); |
8 | |
9 | if (UserPostCounts.ContainsKey(username)) |
10 | { |
11 | UserPostCounts[username]++; |
12 | switch (UserPostCounts[username]) |
13 | { |
14 | case 10: |
15 | return "Level up! " + username + " is now level 2!"; |
16 | break; |
17 | case 100: |
18 | return "Level up! " + username + " is now level 3!"; |
19 | break; |
20 | case 500: |
21 | return "Level up! " + username + " is now level 4!"; |
22 | break; |
23 | case 1000: |
24 | return "Level up! " + username + " is now level 5!"; |
25 | break; |
26 | case 5000: |
27 | return "Level up! " + username + " is now level 6!"; |
28 | break; |
29 | } |
30 | } |
31 | else |
32 | { |
33 | UserPostCounts.Add(username, 1); |
34 | } |
35 | |
36 | return string.Empty; |
37 | } |
38 | |
39 | public static string ViewLevel(S s) |
40 | { |
41 | string returnString = string.Empty; |
42 | if (match("!level *", s)) |
43 | { |
44 | string username = cast callOpt(mainBot, "getUserName"); |
45 | int postCount = 0; |
46 | |
47 | if (UserPostCounts.ContainsKey(username)) |
48 | { |
49 | postCount = UserPostCounts[username]; |
50 | } |
51 | else |
52 | { |
53 | return username + " has no posts"; |
54 | } |
55 | |
56 | returnString = username + " is level "; |
57 | if (postCount < 10) |
58 | { |
59 | returnString += "1"; |
60 | } |
61 | else if (postCount >= 10 && postCount < 100) |
62 | { |
63 | returnString += "2"; |
64 | } |
65 | else if (postCount >= 100 && postCount < 500) |
66 | { |
67 | returnString += "3"; |
68 | } |
69 | else if (postCount >= 500 && postCount < 1000) |
70 | { |
71 | returnString += "4"; |
72 | } |
73 | else if (postCount >= 1000 && postCount < 5000) |
74 | { |
75 | returnString += "5"; |
76 | } |
77 | else |
78 | { |
79 | returnString += "6"; |
80 | } |
81 | returnString += " with " + postCount + " posts."; |
82 | } |
83 | |
84 | return returnString; |
85 | } |
86 | |
87 | static synchronized S answer(S s) { |
88 | S a = ViewLevel(); |
89 | if (!empty(a)) ret a; |
90 | ret LevelUp(); |
91 | } |
Travelled to 12 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1002166 |
Snippet name: | User Level Bot (C#) |
Eternal ID of this version: | #1002166/1 |
Text MD5: | 649721dc0fa17b7e4bf9f4f2c3a7886e |
Author: | stefan |
Category: | |
Type: | Document |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2015-12-23 00:41:45 |
Source code size: | 1859 bytes / 91 lines |
Pitched / IR pitched: | No / Yes |
Views / Downloads: | 631 / 389 |
Referenced in: | [show references] |