Libraryless. Click here for Pure Java version (1467L/9K/31K).
1 | !752 |
2 | |
3 | static O mainBot; |
4 | |
5 | p {
|
6 | load("UserPostCounts");
|
7 | } |
8 | |
9 | public static new Map<String, Long> UserPostCounts; |
10 | |
11 | public static String LevelUp() |
12 | {
|
13 | String username = cast callOpt(mainBot, "getUserName"); |
14 | if (empty(username)) ret null; |
15 | |
16 | if (UserPostCounts.containsKey(username)) |
17 | {
|
18 | UserPostCounts.put(username, UserPostCounts.get(username)+1); |
19 | save("UserPostCounts");
|
20 | |
21 | S word = "coder maniac"; |
22 | |
23 | switch (UserPostCounts.get(username).intValue()) |
24 | {
|
25 | case 10: |
26 | return "Level up! " + username + " is now a level 2 " + word +"!"; |
27 | case 100: |
28 | return "Level up! " + username + " is now a level 3 " + word +"!"; |
29 | case 500: |
30 | return "Level up! " + username + " is now a level 4 " + word +"!"; |
31 | case 1000: |
32 | return "Level up! " + username + " is now a level 5 " + word +"!"; |
33 | case 5000: |
34 | return "Level up! " + username + " is now a level 6 " + word +"!"; |
35 | } |
36 | } |
37 | else |
38 | {
|
39 | UserPostCounts.put(username, 1L); |
40 | save("UserPostCounts");
|
41 | } |
42 | |
43 | return ""; |
44 | } |
45 | |
46 | public static String ViewLevel(S s) |
47 | {
|
48 | new Matches m; |
49 | String returnString = ""; |
50 | if (match("!level *", s, m))
|
51 | {
|
52 | String username = m.unq(0); |
53 | long postCount = 0; |
54 | |
55 | if (UserPostCounts.containsKey(username)) |
56 | {
|
57 | postCount = UserPostCounts.get(username); |
58 | } |
59 | else |
60 | {
|
61 | return username + " has no posts"; |
62 | } |
63 | |
64 | returnString = username + " is level "; |
65 | if (postCount < 10) |
66 | {
|
67 | returnString += "1"; |
68 | } |
69 | else if (postCount >= 10 && postCount < 100) |
70 | {
|
71 | returnString += "2"; |
72 | } |
73 | else if (postCount >= 100 && postCount < 500) |
74 | {
|
75 | returnString += "3"; |
76 | } |
77 | else if (postCount >= 500 && postCount < 1000) |
78 | {
|
79 | returnString += "4"; |
80 | } |
81 | else if (postCount >= 1000 && postCount < 5000) |
82 | {
|
83 | returnString += "5"; |
84 | } |
85 | else |
86 | {
|
87 | returnString += "6"; |
88 | } |
89 | returnString += " with " + postCount + " posts."; |
90 | } |
91 | |
92 | return returnString; |
93 | } |
94 | |
95 | static synchronized S answer(S s) {
|
96 | S a = ViewLevel(s); |
97 | if (!empty(a)) ret a; |
98 | ret LevelUp(); |
99 | } |
download show line numbers debug dex old transpilations
Travelled to 14 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
| ID | Author/Program | Comment | Date |
|---|---|---|---|
| 1198 | stefan | C# originally by @relevant | 2015-12-23 01:04:35 |
| Snippet ID: | #1002168 |
| Snippet name: | User Level Bot (translated to JavaX) |
| Eternal ID of this version: | #1002168/1 |
| Text MD5: | a49b5334967bbad7fe01458f3ad8dc3a |
| Transpilation MD5: | e9b800ace8a1c97e351d0ccf96d1b304 |
| Author: | stefan |
| Category: | javax |
| Type: | JavaX source code |
| Public (visible to everyone): | Yes |
| Archived (hidden from active list): | No |
| Created/modified: | 2015-12-27 18:42:47 |
| Source code size: | 2042 bytes / 99 lines |
| Pitched / IR pitched: | No / Yes |
| Views / Downloads: | 1204 / 2325 |
| Referenced in: | [show references] |