Sfoglia il codice sorgente

new rotbot functions

tBKwtWS 6 anni fa
parent
commit
5f4eaf1cf3

+ 24 - 16
rotbot/commands/common.py

@@ -1,5 +1,5 @@
 import random
 import random
-from common import font, queries
+from common import font, queries, userstatus
 
 
 
 
 class CommandHelpers():
 class CommandHelpers():
@@ -118,16 +118,16 @@ class GameHelpers():
             rolls.append(random.randint(1, type))
             rolls.append(random.randint(1, type))
         return rolls
         return rolls
 
 
-    def get_info(self, user_id):
-        total_joins = queries.get_user_total_joins(self, user_id)
-        total_kicks = queries.get_user_total_kicks(self, user_id)
-        total_kicked = queries.get_user_total_kicked(self, user_id)
-        total_messages = queries.get_user_total_messages(self, user_id)
-        total_actions = queries.get_user_total_actions(self, user_id)
-        total_notices = queries.get_user_total_notices(self, user_id)
-        total_cursewords_added = queries.get_user_total_curseword_added(self, user_id)
-        total_curseadjectives_added = queries.get_user_total_curseadjective_added(self, user_id)
-        gamestats = queries.get_user_gamestats(self, user_id)
+    def get_info(self, user):
+        total_joins = queries.get_user_total_joins(self, user.id)
+        total_kicks = queries.get_user_total_kicks(self, user.id)
+        total_kicked = queries.get_user_total_kicked(self, user.id)
+        total_messages = queries.get_user_total_messages(self, user.id)
+        total_actions = queries.get_user_total_actions(self, user.id)
+        total_notices = queries.get_user_total_notices(self, user.id)
+        total_cursewords_added = queries.get_user_total_curseword_added(self, user.id)
+        total_curseadjectives_added = queries.get_user_total_curseadjective_added(self, user.id)
+        gamestats = queries.get_user_gamestats(self, user.id)
         xp_spent = gamestats[0]
         xp_spent = gamestats[0]
         level = gamestats[1]
         level = gamestats[1]
         coin = gamestats[2]
         coin = gamestats[2]
@@ -165,13 +165,21 @@ class GameHelpers():
         print('wealth_karma:' + str(wealth_karma) + ' = (coin:' + str(coin) + ' * 50) / total_xp:' + str(total_xp))
         print('wealth_karma:' + str(wealth_karma) + ' = (coin:' + str(coin) + ' * 50) / total_xp:' + str(total_xp))
         charity_karma = (coin_given * 10.1) / total_xp
         charity_karma = (coin_given * 10.1) / total_xp
         print('charity_karma:' + str(charity_karma) + ' = (coin_given:' + str(coin_given) + ' * 10) / total_xp:' + str(total_xp))
         print('charity_karma:' + str(charity_karma) + ' = (coin_given:' + str(coin_given) + ' * 10) / total_xp:' + str(total_xp))
-        karma =  float(karma_correction) + float(curse_add_karma) + float(charity_karma) - float(join_karma) - float(kick_karma) - float(shout_karma) - float(wealth_karma)
-        print('karma: ' + str(karma) + ' =  float(karma_correction:' + str(karma_correction) + ') + float(curse_karma:' + str(curse_add_karma) + ') + float(charity_karma:' + str(charity_karma) + ') - float(join_karma:' + str(join_karma) + ') - float(kick_karma:' + str(kick_karma) + ') - float(shout_karma:' + str(shout_karma) + ') - float(wealth_karma:' + str(wealth_karma) + ')')
+        elite_karma_bonus = 0
+        i = 0
+        for channel in self.channels:
+            if userstatus.atleast_voiced(self, user.name, channel[i]):
+                print(channel[i])
+                elite_karma_bonus += 1
+                print(elite_karma_bonus)
+            i += 1
+        karma =  float(karma_correction) + float(curse_add_karma) + float(charity_karma) + elite_karma_bonus - float(join_karma) - float(kick_karma) - float(shout_karma) - float(wealth_karma)
+        print('karma: ' + str(karma) + ' =  float(karma_correction:' + str(karma_correction) + ') + float(curse_karma:' + str(curse_add_karma) + ') + float(charity_karma:' + str(charity_karma) + ') + elite_karma_bonus:' + str(elite_karma_bonus) + ' - float(join_karma:' + str(join_karma) + ') - float(kick_karma:' + str(kick_karma) + ') - float(shout_karma:' + str(shout_karma) + ') - float(wealth_karma:' + str(wealth_karma) + ')')
 
 
         return level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent
         return level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent
 
 
-    def player_info(self, user_id):
-        level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, user_id)
+    def player_info(self, user):
+        level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, user)
         #return 'Level: ' + str(level) + font.grey + ", " + font.reset + "XP: " + str(int(xp)) + "/" + font.grey + str(round(total_xp, 4)) + ", " + font.reset + "AP: " + str(int(ap)) + font.grey + ", " + font.reset + "coin: " + str(coin) + font.grey + "[S " + str(coin_spent) + ", G " + str(coin_given) + "], " + font.reset + "karma: " + str(round(karma, 4))
         #return 'Level: ' + str(level) + font.grey + ", " + font.reset + "XP: " + str(int(xp)) + "/" + font.grey + str(round(total_xp, 4)) + ", " + font.reset + "AP: " + str(int(ap)) + font.grey + ", " + font.reset + "coin: " + str(coin) + font.grey + "[S " + str(coin_spent) + ", G " + str(coin_given) + "], " + font.reset + "karma: " + str(round(karma, 4))
         return 'Level: ' + str(level) + font.grey + ", " + font.reset + "XP: " + str(int(xp)) + "/" + font.grey + str(int(total_xp)) + ", " + font.reset + "AP: " + str(int(ap)) + font.grey + ", " + font.reset + "coin: " + str(coin) + font.grey + "[S " + str(coin_spent) + ", G " + str(coin_given) + "], " + font.reset + "karma: " + str(round(karma, 4))
         return 'Level: ' + str(level) + font.grey + ", " + font.reset + "XP: " + str(int(xp)) + "/" + font.grey + str(int(total_xp)) + ", " + font.reset + "AP: " + str(int(ap)) + font.grey + ", " + font.reset + "coin: " + str(coin) + font.grey + "[S " + str(coin_spent) + ", G " + str(coin_given) + "], " + font.reset + "karma: " + str(round(karma, 4))
 
 
@@ -186,6 +194,6 @@ class GameHelpers():
         message = ""
         message = ""
         for record in result:
         for record in result:
             if not int(record[column]) < 1:
             if not int(record[column]) < 1:
-                level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, record.id)
+                level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, record)
                 message += font.red + str(record[1]) + font.grey + " L " + font.green + str(level) + font.grey + ", XP " + font.green + str(int(xp)) + font.grey + "/" + str(int(total_xp)) + ", A " + font.green + str(int(ap)) + font.grey + ", C " + font.green + str(coin) + font.grey + ", K " + font.green + str(round(karma, 2)) + font.grey + ", "
                 message += font.red + str(record[1]) + font.grey + " L " + font.green + str(level) + font.grey + ", XP " + font.green + str(int(xp)) + font.grey + "/" + str(int(total_xp)) + ", A " + font.green + str(int(ap)) + font.grey + ", C " + font.green + str(coin) + font.grey + ", K " + font.green + str(round(karma, 2)) + font.grey + ", "
             return message[:-2]
             return message[:-2]

+ 5 - 5
rotbot/commands/games.py

@@ -57,11 +57,11 @@ def do_command(self, connection, event, user, channel):
             connection.privmsg(replyto, 'Too many arguments, For help type: %s%s%s' % (font.blue, self.network.help_character, one))
             connection.privmsg(replyto, 'Too many arguments, For help type: %s%s%s' % (font.blue, self.network.help_character, one))
             return
             return
 
 
-        info = GameHelpers.player_info(self, player.id)
+        info = GameHelpers.player_info(self, player)
         connection.privmsg(replyto, message + info)
         connection.privmsg(replyto, message + info)
 
 
     elif one == 'levelup':
     elif one == 'levelup':
-        level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, user.id)
+        level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, user)
         if cmdtype == 'help':    #Display help text.
         if cmdtype == 'help':    #Display help text.
             connection.privmsg(replyto, 'Spend %s XP to gain your next level. Levelup multiple levels by adding an amount.' %  str(int(level * 2.7)))
             connection.privmsg(replyto, 'Spend %s XP to gain your next level. Levelup multiple levels by adding an amount.' %  str(int(level * 2.7)))
             connection.privmsg(replyto, 'Example: %s%s%s 3' % (font.blue, self.network.command_character, one))
             connection.privmsg(replyto, 'Example: %s%s%s 3' % (font.blue, self.network.command_character, one))
@@ -89,11 +89,11 @@ def do_command(self, connection, event, user, channel):
 
 
             while xp > int(level * 2.7) and ap > 0 and upgrade_count > 0:
             while xp > int(level * 2.7) and ap > 0 and upgrade_count > 0:
                 queries.levelup_user(self, user.id, int(level * 2.7))
                 queries.levelup_user(self, user.id, int(level * 2.7))
-                level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, user.id)
+                level, xp, xp_spent, total_xp, karma, coin, coin_spent, coin_given, ap, ap_spent = GameHelpers.get_info(self, user)
 
 
             if upgrade_count < 0:
             if upgrade_count < 0:
                 connection.privmsg(replyto, 'Exhausted XP or AP before levelup was complete. You are only partially levelled up.')
                 connection.privmsg(replyto, 'Exhausted XP or AP before levelup was complete. You are only partially levelled up.')
-            info = GameHelpers.player_info(self, user.id)
+            info = GameHelpers.player_info(self, user)
             connection.privmsg(replyto, "Your new statistics: " + info)
             connection.privmsg(replyto, "Your new statistics: " + info)
 
 
     elif one == 'givecoin':
     elif one == 'givecoin':
@@ -162,7 +162,7 @@ def do_command(self, connection, event, user, channel):
                     connection.privmsg(replyto, "You do not have enough coin.")
                     connection.privmsg(replyto, "You do not have enough coin.")
                     return
                     return
                 queires.cointransfer(self, sender.id, receiver.id)
                 queires.cointransfer(self, sender.id, receiver.id)
-            info = GameHelpers.player_info(self, sender.id)
+            info = GameHelpers.player_info(self, sender)
             connection.notice(event.source.nick, "Your new statistics: " + info)
             connection.notice(event.source.nick, "Your new statistics: " + info)
 
 
     elif one == 'players':
     elif one == 'players':

+ 13 - 13
rotbot/common/userstatus.py

@@ -1,31 +1,31 @@
-def atleast_admin(self, user, channel):
-    if channel not in self.channels:
+def atleast_admin(self, user_name, channel_name):
+    if channel_name not in self.channels:
         return False
         return False
-    if self.channels[channel].is_owner(user) or self.channels[channel].is_admin(user):
+    if self.channels[channel_name].is_owner(user_name) or self.channels[channel_name].is_admin(user_name):
         return True
         return True
     else:
     else:
         return False
         return False
-        
-def atleast_oper(self, user, channel):
-    if channel not in self.channels:
+
+def atleast_oper(self, user_name, channel_name):
+    if channel_name not in self.channels:
         return False
         return False
-    if self.channels[channel].is_owner(user) or self.channels[channel].is_admin(user) or self.channels[channel].is_oper(user):
+    if self.channels[channel_name].is_owner(user_name) or self.channels[channel_name].is_admin(user_name) or self.channels[channel_name].is_oper(user_name):
         return True
         return True
     else:
     else:
         return False
         return False
 
 
-def atleast_halfop(self, user, channel):
-    if channel not in self.channels:
+def atleast_halfop(self, user_name, channel_name):
+    if channel_name not in self.channels:
         return False
         return False
-    if self.channels[channel].is_owner(user) or self.channels[channel].is_admin(user) or self.channels[channel].is_oper(user) or self.channels[channel].is_halfop(user):
+    if self.channels[channel_name].is_owner(user_name) or self.channels[channel_name].is_admin(user_name) or self.channels[channel_name].is_oper(user_name) or self.channels[channel_name].is_halfop(user_name):
         return True
         return True
     else:
     else:
         return False
         return False
 
 
-def atleast_voiced(self, user, channel):
-    if channel not in self.channels:
+def atleast_voiced(self, user_name, channel_name):
+    if channel_name not in self.channels:
         return False
         return False
-    if self.channels[channel].is_owner(user) or self.channels[channel].is_admin(user) or self.channels[channel].is_oper(user) or self.channels[channel].is_halfop(user) or self.channels[channel].is_voiced(user):
+    if self.channels[channel_name].is_owner(user_name) or self.channels[channel_name].is_admin(user_name) or self.channels[channel_name].is_oper(user_name) or self.channels[channel_name].is_halfop(user_name) or self.channels[channel_name].is_voiced(user_name):
         return True
         return True
     else:
     else:
         return False
         return False

+ 1 - 1
rotbot/events/on_kick.py

@@ -19,7 +19,7 @@ def process_event(self, connection, event):
         connection.privmsg(event.source.nick, 'Sorry you needed to kick me. Bot\'s should serve those who enjoy it, without annoying anyone. Any channelOP can use the !settings command to change my settings.')
         connection.privmsg(event.source.nick, 'Sorry you needed to kick me. Bot\'s should serve those who enjoy it, without annoying anyone. Any channelOP can use the !settings command to change my settings.')
         temp_key = queries.create_tempchannelkey(self, channel.id)
         temp_key = queries.create_tempchannelkey(self, channel.id)
         connection.privmsg(event.source.nick, 'Here is a temp 10 minute link for %s%s%s:%s %schannelsettings/%s' % (event.target, font.red, event.target, font.reset, self.webgui['base_ur'], temp_key))
         connection.privmsg(event.source.nick, 'Here is a temp 10 minute link for %s%s%s:%s %schannelsettings/%s' % (event.target, font.red, event.target, font.reset, self.webgui['base_ur'], temp_key))
-        connection.privmsg(event.source.nick, 'If you have any complaints, suggestions or want me back in %s%s%s contact an operator of: %s%s' % (font.red, event.target, font.reset, font.red, self.network.home_channel))
+        connection.privmsg(event.source.nick, 'Good bye. If you have any complaints, suggestions or want me back in %s%s%s contact an operator of: %s%s' % (font.red, event.target, font.reset, font.red, self.network.home_channel))
 
 
     # # Update protectees if needed.
     # # Update protectees if needed.
     # if channel == self.homechannel: # Kicked from home channel
     # if channel == self.homechannel: # Kicked from home channel