|
|
@@ -22,12 +22,12 @@ def do_command(self, connection, event, user, channel):
|
|
|
|
|
|
# Do noting if the games channel function is off and it's a channel message.
|
|
|
if event.target != connection.get_nickname(): # Command issued to channel.
|
|
|
- if not queries.get_channel_setting_game_commands: # Games are turned off in channel settigns.
|
|
|
+ if not queries.get_channel_setting_game_commands(self, channel.id): # Games are turned off in channel settigns.
|
|
|
return # Do nothing.
|
|
|
|
|
|
if command == 'cmd' or command == 'cmds' or command == 'commands':
|
|
|
if cmdtype == 'cmd':
|
|
|
- connection.privmsg(replyto, '%sGames: %s %s %s %s %s %s' % (font.grey, CH.ccc(self, "player"), CH.ccc(self, "players"), CH.ccc(self, "levelup") ,CH.ccc(self, "givecoin"), CH.ccc(self, "8ball"), CH.ccc(self, "dice")[:-2]))
|
|
|
+ connection.privmsg(replyto, '%sGames: %s%s%s%s%s%s' % (font.grey, CH.ccc(self, "player"), CH.ccc(self, "players"), CH.ccc(self, "levelup") ,CH.ccc(self, "givecoin"), CH.ccc(self, "8ball"), CH.ccc(self, "dice")[:-2]))
|
|
|
connection.privmsg(replyto, font.grey + "Game help: " + font.blue + self.network.help_character + "level" + font.grey + ", " + font.blue + self.network.help_character + "xp" + font.grey + ", " + font.blue + self.network.help_character + "ap" + font.grey + ", " + font.blue + self.network.help_character + "coin" + font.grey + ", " + font.blue + self.network.help_character + "karma" + font.grey + ".")
|
|
|
|
|
|
|
|
|
@@ -37,7 +37,7 @@ def do_command(self, connection, event, user, channel):
|
|
|
connection.privmsg(replyto, 'Displays a users game statistics. User optional.')
|
|
|
connection.privmsg(replyto, 'Usage: %s%s%s%s %snickname' % (font.blue, self.network.command_character, one, font.reset, font.italic))
|
|
|
return
|
|
|
- message = '%s Your player stats: ' % font.grey
|
|
|
+ message = '%sYour player stats: ' % font.grey
|
|
|
player_name = event.source.nick
|
|
|
player = queries.get_user(self, player_name)
|
|
|
elif len(command.split()) == 2:
|
|
|
@@ -70,7 +70,7 @@ def do_command(self, connection, event, user, channel):
|
|
|
if xp < int(level * 2.7):
|
|
|
connection.privmsg(replyto, "Insufficient XP, you need at least " + str(int(level * 2.7)) + ".")
|
|
|
return
|
|
|
- elif ap <= 0:
|
|
|
+ elif ap < 1:
|
|
|
connection.privmsg(replyto, "Insufficient AP, you need at least 1.")
|
|
|
return
|
|
|
elif len(command.split()) == 2: # Command with one argument.
|
|
|
@@ -96,12 +96,11 @@ def do_command(self, connection, event, user, channel):
|
|
|
info = GameHelpers.player_info(self, user)
|
|
|
connection.privmsg(replyto, "Your new statistics: " + info)
|
|
|
|
|
|
- elif command.split()[0] == "givecoin":
|
|
|
- if cmdtype == "help": #Display help text.
|
|
|
+ elif one == 'givecoin':
|
|
|
+ if cmdtype == 'help': #Display help text.
|
|
|
connection.privmsg(replyto, "Give coins to another player. Amount optional.")
|
|
|
connection.privmsg(replyto, font.grey + "Usage: " + font.blue + self.network.command_character + "givecoin " + font.reset + font.italic + "user amount")
|
|
|
elif cmdtype == "cmd":
|
|
|
-
|
|
|
if len(command.split()) == 1:
|
|
|
connection.privmsg(replyto, "Insufficient arguments. For help type " + font.blue + self.network.help_character + "givecoin" + font.reset + ".")
|
|
|
return
|
|
|
@@ -111,67 +110,76 @@ def do_command(self, connection, event, user, channel):
|
|
|
elif command.split()[1] == event.source.nick.lower():
|
|
|
connection.privmsg(replyto, "You already have your own coin. For help type " + font.blue + self.network.help_character + "givecoin" + font.reset + ".")
|
|
|
return
|
|
|
+ elif command.split()[1] == connection.get_nickname() or command.split()[1] == self.network.nickname:
|
|
|
+ connection.privmsg(replyto, "I don't need that. If I wanted I could take all your coin and there would be nothing for you to do to stop me....")
|
|
|
+ return
|
|
|
elif len(command.split()) == 3:
|
|
|
- stop = False
|
|
|
try:
|
|
|
if float(command.split()[2]) < 0:
|
|
|
connection.privmsg(replyto, "You clever abuser! The " + font.red + self.network.command_character + font.bold + "give" + font.bold + "coin" + font.reset + " command is not designed for robbing. There will be consequences...")
|
|
|
- self.db.run("UPDATE users SET coin=coin-3, karma_correction=karma_correction-0.5 WHERE name=%s AND network=%s", (event.source.nick, self.network))
|
|
|
- stop = True
|
|
|
+ queries.punish_user(self, user, -3, -1)
|
|
|
+ return
|
|
|
except TypeError:
|
|
|
connection.privmsg(replyto, "Invalid amount. For help type " + font.blue + self.network.help_character + "givecoin" + font.reset + ".")
|
|
|
return
|
|
|
- if stop:
|
|
|
+ elif event.target == connection.get_nickname(): # Private message
|
|
|
+ for channel in self.channels:
|
|
|
+ user_present = False
|
|
|
+ if command.split()[1] in self.channels[channel].users(): # User is on a channel the bot inhabits.
|
|
|
+ user_present = True
|
|
|
+ if not user_present:
|
|
|
+ connection.privmsg(replyto, font.red + trigger.split()[1] + font.reset + " is not present on any channel I inhabit.")
|
|
|
return
|
|
|
- elif not event.target == connection.get_nickname():
|
|
|
+ else: # Channel message
|
|
|
if not command.split()[1] in self.channels[event.target].users():
|
|
|
- connection.privmsg(replyto, font.red + trigger.split()[1] + font.reset + " is not present.")
|
|
|
+ connection.privmsg(replyto, font.red + trigger.split()[1] + font.reset + " is not present on this channel.")
|
|
|
return
|
|
|
|
|
|
- level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, event.source.nick)
|
|
|
- receivingrecord = self.db.one("SELECT level, away FROM users WHERE LOWER(name)=%s AND network=%s", (command.split()[1], self.network, ))
|
|
|
+ level, xp, xpspent, totalxp, karma, coin, coinspent, coingiven, ap, apspent = GameHelpers.get_info(self, user)
|
|
|
+ receiver = queries.get_user(self, command.split()[1])
|
|
|
if level < 1:
|
|
|
connection.privmsg(replyto, "You need to " + font.blue + self.network.command_character + "levelup " + font.reset + "to be able to give coin.")
|
|
|
return
|
|
|
elif coin < 1:
|
|
|
connection.privmsg(replyto, "You have no coin to give.")
|
|
|
return
|
|
|
- elif not receivingrecord:
|
|
|
+ elif not receiver:
|
|
|
connection.action(replyto, "does not know of any \"" + font.red + trigger.split()[1] + font.reset + "\".")
|
|
|
return
|
|
|
- elif receivingrecord[0] == 0:
|
|
|
+ elif receiver.level <= 0:
|
|
|
connection.privmsg(replyto, font.red + trigger.split()[1] + font.reset + " is not playing the game.")
|
|
|
return
|
|
|
- elif receivingrecord[1] == True:
|
|
|
- connection.privmsg(replyto, font.red + trigger.split()[1] + font.reset + "is not here right now.")
|
|
|
- return
|
|
|
+ #elif receiver.away == True:
|
|
|
+ # connection.privmsg(replyto, font.red + trigger.split()[1] + font.reset + "is not here right now.")
|
|
|
+ # return
|
|
|
elif ap < 1:
|
|
|
- connection.privmsg(replyto, "You have no action points, go use IRC some more...")
|
|
|
+ connection.privmsg(replyto, "You have no action points.")
|
|
|
return
|
|
|
if len(command.split()) == 2:
|
|
|
- self.db.run("UPDATE users SET coin=coin-1, coin_spent=coin_spent+1, coin_given=coin_given+1, ap_spent=ap_spent+1 WHERE name=%s AND network=%s", (event.source.nick, self.network, ))
|
|
|
- self.db.run("UPDATE users SET coin=coin+1 WHERE LOWER(name)=%s AND network=%s", (command.split()[1], self.network, ))
|
|
|
+ queires.cointransfer(self, event.source.nick, command.split()[1])
|
|
|
elif len(command.split()) == 3:
|
|
|
- self.db.run("UPDATE users SET coin=coin-%s, coin_spent=coin_spent+%s, coin_given=coin_given+%s, ap_spent=ap_spent+1 WHERE name=%s AND network=%s", (command.split()[2], command.split()[2], command.split()[2], event.source.nick, self.network, ))
|
|
|
- self.db.run("UPDATE users SET coin=coin+%s WHERE LOWER(name)=%s AND network=%s", (command.split()[2], command.split()[1], self.network))
|
|
|
+ if coin < command.split()[2]:
|
|
|
+ connection.privmsg(replyto, "You do not have enough coin.")
|
|
|
+ return
|
|
|
+ queires.cointransfer(self, event.source.nick, command.split()[2])
|
|
|
info = GameHelpers.player_info(self, event.source.nick)
|
|
|
connection.notice(event.source.nick, "Your new statistics: " + info)
|
|
|
|
|
|
- elif command.split()[0] == "players":
|
|
|
- if cmdtype == "help": #Display help text.
|
|
|
- connection.privmsg(replyto, "Display top player rankings.")
|
|
|
+ elif one == 'players':
|
|
|
+ if cmdtype == 'help': #Display help text.
|
|
|
+ connection.privmsg(replyto, 'Display top player rankings.')
|
|
|
elif cmdtype == "cmd":
|
|
|
-
|
|
|
toplevel = GameHelpers.list_top_players(self, "level")
|
|
|
+ topxp = GameHelpers.list_top_players(self, "xp_spent")
|
|
|
+ topcoin = GameHelpers.list_top_players(self, "coin")
|
|
|
if toplevel:
|
|
|
connection.notice(event.source.nick, "Ranking level: " + toplevel)
|
|
|
- topxp = GameHelpers.list_top_players(self, "xp_spent")
|
|
|
- if topxp:
|
|
|
+ elif topxp:
|
|
|
connection.notice(event.source.nick, "Ranking experience: " + topxp)
|
|
|
- topcoin = GameHelpers.list_top_players(self, "coin")
|
|
|
- if topcoin:
|
|
|
+
|
|
|
+ elif topcoin:
|
|
|
connection.notice(event.source.nick, "Ranking wealth: " + topcoin)
|
|
|
- if not toplevel and not topxp and not topcoin:
|
|
|
+ else:
|
|
|
connection.privmsg(replyto, "Nobody is playing the game.")
|
|
|
|
|
|
|