Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

99
LINES

< > BotCompany Repo | #1002168 // User Level Bot (translated to JavaX)

JavaX source code [tags: use-pretranspiled] - run with: x30.jar

Libraryless. Click here for Pure Java version (1467L/9K/31K).

!752

static O mainBot;

p {
  load("UserPostCounts");
}

public static new Map<String, Long> UserPostCounts; 

public static String LevelUp()
{
	String username = cast callOpt(mainBot, "getUserName");
	if (empty(username)) ret null;

	if (UserPostCounts.containsKey(username))
	{
		UserPostCounts.put(username, UserPostCounts.get(username)+1);
    save("UserPostCounts");
    
    S word = "coder maniac";
    
		switch (UserPostCounts.get(username).intValue())
		{
			case 10:
				return "Level up! " + username + " is now a level 2 " + word +"!";
			case 100:
				return "Level up! " + username + " is now a level 3 " + word +"!";
			case 500:
				return "Level up! " + username + " is now a level 4 " + word +"!";
			case 1000:
				return "Level up! " + username + " is now a level 5 " + word +"!";
			case 5000:
				return "Level up! " + username + " is now a level 6 " + word +"!";
		}
	}
	else
	{
		UserPostCounts.put(username, 1L);
    save("UserPostCounts");
	}

	return "";
}

public static String ViewLevel(S s)
{
  new Matches m;
	String returnString = "";
	if (match("!level *", s, m))
	{
		String username = m.unq(0);
		long postCount = 0;

		if (UserPostCounts.containsKey(username))
		{
			postCount = UserPostCounts.get(username);
		}
		else
		{
			return username + " has no posts";
		}

		returnString = username + " is level ";
		if (postCount < 10)
		{
			returnString += "1";
		}
		else if (postCount >= 10 && postCount < 100)
		{
			returnString += "2";
		}
		else if (postCount >= 100 && postCount < 500)
		{
			returnString += "3";
		}
		else if (postCount >= 500 && postCount < 1000)
		{
			returnString += "4";
		}
		else if (postCount >= 1000 && postCount < 5000)
		{
			returnString += "5";
		}
		else
		{
			returnString += "6";
		}
		returnString += " with " + postCount + " posts.";
	}

	return returnString;
}

static synchronized S answer(S s) {
  S a = ViewLevel(s);
  if (!empty(a)) ret a;
  ret LevelUp();
}

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

Comments [hide]

ID Author/Program Comment Date
1198 stefan C# originally by @relevant 2015-12-23 01:04:35

add comment

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: 943 / 2022
Referenced in: #3000169 - Answer for stefanreich
#3000174 - Answer for stefanreich
#3000175 - Answer for stefanreich
#3000176 - Answer for stefanreich
#3000177 - Answer for stefanreich
#3000179 - Answer for stefanreich
#3000180 - Answer for stefanreich
#3000181 - Answer for stefanreich
#3000182 - Answer for stefanreich
#3000184 - Answer for stefanreich
#3000185 - Answer for stefanreich
#3000195 - Answer for stefanreich (>> y)
#3000196 - Answer for stefanreich (>> y)
#3000197 - Answer for stefanreich (>> program data sizes)
#3000198 - Answer for stefanreich (>> program data sizes)
#3000199 - Answer for stefanreich (>> program data sizes)
#3000200 - Answer for stefanreich (>> program data sizes)
#3000201 - Answer for stefanreich (>> list all files)
#3000202 - Answer for stefanreich (>> T conversion bot)
#3000203 - Answer for stefanreich (>> timing hello bot)
#3000208 - Answer for bgrgndz (>> list sub bots)
#3000209 - Answer for bgrgndz (>> list sub bots)
#3000238 - Answer for stefanreich (>> t power bot)
#3000369 - Answer for Stefan (>> list sub bots)
#3000376 - Answer for stefanreich (>> list sub bots)
#3000377 - Answer for stefanreich (>> timing eleu?)
#3000380 - Answer for stefanreich (>> list sub bots)
#3000381 - Answer for speedforce (>> list sub bots)
#3000382 - Answer for ferdie (>> t = 1, f = 0)
#3000383 - Answer for funkoverflow (>> t=1, f=0 okay)