瀏覽代碼

Merge branch 'master' of /srv/git/h0v1n8-website

root 6 年之前
父節點
當前提交
296fd861e4

+ 142 - 56
rotbot/commands/chat.py

@@ -18,72 +18,158 @@ def do_command(self, connection, event, user, channel):
     except:
         return
 
-    # Do noting if the chat channel setting is off and it's a channel message.
+    # 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_chat:   # Games are turned off in channel settigns.
+        if not queries.get_channel_setting_chat(self, channel.id):   # Games are turned off in channel settigns.
             return  # Do nothing.
 
+    # Command list.
     if command == 'cmd' or command == 'cmds' or command == 'commands':
         if cmdtype == 'cmd':
-            connection.privmsg(replyto, '%sChat: %s' % (font.grey, CH.ccc(self, "curse")[:-2]))
+            connection.privmsg(replyto, '%sChat: %s' % (font.grey, CH.ccc(self, "vocabulary")[:-2]))
 
-    elif one == 'curse':
+    elif one == 'vocabulary' or one == 'vocab':
         curse = queries.random_curse(self)
-        if command.split() == 1:    # Command without arguments
+        categories = ['curseword', 'adjective', 'nickreply']
+        if len(command.split()) == 1:    # Command without arguments
             if cmdtype == 'help':
-                if curse:
-                    connection.privmsg(replyto, 'Add, lookup, or display a random %s curse word. The word argument is optional, to add a new word%s %s%s add%s %sword%s, or an adjective: %s%s%s adj' % (curse, font.blue, self.network.command_character, one, font.reset, font.italic, font.reset, font.blue, self.network.command_character, one))
-                else:
-                    connection.privmsg(replyto, 'Add, lookup, or display random curse word. The word argument is optional, to add a new word%s %s%s add%s %sword%s, or an adjective: %s%s%s add adj' % (font.blue, self.network.command_character, one, font.reset, font.italic, font.reset, font.blue, self.network.command_character, one))
-                connection.privmsg(replyto, '%sUsage:%s %s%s%s %sword' % (font.grey, font.blue, self.network.command_character, one, font.reset, font.italic))
+                connection.privmsg(replyto, 'Add, display or ban a vocabulary item. Option and item are optional arguments.')
+                connection.privmsg(replyto, '%sUsage:%s %s%s %scatagory option item' % (font.grey, font.blue, self.network.command_character, one, font.italic))
+                connection.privmsg(replyto, 'List categories: %s%s%slist categories%s List options: %s%s%slist options' % (font.blue, self.network.command_character, one, font.reset, font.blue, self.network.command_character, one))
             else:   # Actual command without arguments.
-                curseword = queries.random_curseword(self)
-                connection.privmsg(replyto, curseword)
-        elif command.split() == 2:   # Command with one argument.
-            if cmdtype == 'help':
-                if swear:
-                    connection.privmsg(replyto, 'Look up a %s swear word: %s%s' % (swear, font.italic, command.split()[1]))
+                connection.privmsg(replyto, 'Insuficcient arguments. For help type: %s%s%s' % (font.blue, self.network.help_character, one))
+        elif len(command.split()) == 2:   # Command with one argument.
+            if command.split()[1] == 'list':
+                connection.privmsg(replyto, 'List categories: %s%s%s list categories%s List options: %s%s%slist options' % (font.blue, self.network.command_character, one, font.reset, font.blue, self.network.command_character, one))
+            elif command.split()[1] in categories:
+                if cmdtype == 'help':
+                    connection.privmsg(replyto, 'Show a random %s' % command.split()[1])
                 else:
-                    connection.privmsg(replyto, 'Look up swear word: %s%s' % (font.italic, command.split()[1]))
-            else:   # Actual command with one argument.
-                curseword = quiries.get_curseword(self, command.split()[1])
-                if curseword.banned:
-                    if curse:
-                        connection.privmsg(replyto, 'Sorry, %s this word is banned!' % curse)
+                    connection.privmsg(replyto, queries.random_vocabulary_item(self, command.split()[1].lower()))
+            else:
+                connection.privmsg(replyto, 'Invalid argument, for help type: %s%s%s' % (font.blue, self.network.command_character, one))
+        elif len(command.split()) == 3:  # Command with two arguments.
+            if command.split()[1] == 'list':
+                if command.split()[2] == 'categories':
+                    if cmdtype == 'help':
+                        connection.privmsg(replyto, 'Lists available categories.')
+                    else:   # List categories
+                        connection.privmsg(replyto, ' ,'.join(categories))
+                elif command.split()[2] == 'options':
+                    if cmdtype == 'help':
+                        connection.privmsg(replyto, 'Lists available options.')
                     else:
-                        connection.privmsg(replyto, 'Sorry, this word is banned.')
-                elif curseword.irc_user:
-                    user_name = quiries.get_user_name(self, curseword.irc_user.id)
-                    connection.privmsg(replyto, 'Added %s by %s%s%s.' % (curseword.created, font.red, user_name, font.reset))
-                elif curseword.web_user:
-                    #user_name = quiries.get_user_name(self, curseword.irc_user.id)
-                    connection.privmsg(replyto, 'Added %s by %s%s%s.' % (curseword.created, font.red, 'a web user', font.reset))
-        elif command.split() == 3:  # Command with two arguments.
-            if command.split()[1] == 'add': # Add a curse word.
-                if cmdtype == 'help':
-                    connection.privmsg(replyto, 'Adds curse word %s to my vocabulary.' % (command.split()[2]))
-                else:   # Actual command.
-                    if command.split()[2] == 'adj':
-                        curse = queries.random_curse(self)
-                        if curse:
-                            connection.privmsg(replyto, '%sAdj%s is not a %s swearword!' % (font.italic, font.reset, curse))
+                        connection.privmsg(replyto, 'add, info, ban')
+                else:
+                    connection.privmsg(replyto, 'Unkown list, options are %scategories%s and %soptions%s.' % (font.blue, font.reset,font.blue, font.reset))
+            elif command.split()[1] in catagories:
+                if command.split()[2] in ['add', 'info', 'ban']:
+                    if cmdtype == 'help':
+                        connection.privmsg(replyto, 'Without specifiying add, display or ban, this displays a random %s' % command,split()[1])
+                    else:
+                        connection.privmsg(replyto, queries.random_vocabulary_item(self, commands.spit()[1]))
+                else:
+                    connection.privmsg(replyto, 'Invalid option. Options are: add info ban')
+            else:
+                connection.privmsg(replyto, 'Invalid catagory. To list valid categories use: %s%s%s list categories' % (font.blue, self.network.command_character, one))
+        elif len(command.split()) >= 4:  # Command with three or more arguments.
+            if command.split()[1] in catagories:
+                if command.split()[2] == 'add':
+                    if cmdtype == 'help':
+                        connection.privmsg(replyto, 'Adds %s to %s' % (command.split()[3:], command.split()[1]))
+                    else:
+                        queries.add_vocabulary_item(self, table_suffix, user.id, command.split()[3:])
+                        connection.privmsg(replyto, '%s added to %s' % (command.split()[3:]), commands.split()[1])
+                elif command.split()[2] == 'info':
+                    if cmdtype == 'help':
+                        connection.privmsg(replyto, 'Displays info on %s from %s' % (command.split()[3:], command.split()[1]))
+                    else:
+                        item = queries.get_vocabulary_item(self, command.split()[1], command.split()[3:])
+                        if not item:
+                            connection.privmsg(replyto, '%s is not in my vocabulary.' % command.split()[3:])
                         else:
-                            connection.privmsg(replyto, '%sAdj%s is not a swearword.' % (font.italic, font.reset))
-                        return
-                    queries.add_curseword(self, command.split()[2], user.id)
-                    if curse:
-                        connection.privmsg(replyto, '%s!' % curse)
-            elif command.split()[1] == 'adj':   # Add an adjective.
-                if cmdtype == 'help':
-                    connection.privmsg(replyto, 'Adds adjective %s to my vocabulary.' % (command.split()[2]))
-                else:   # Actual command.
-                    queries.add_adjective(self, command.split()[2], user.id)
-                    if curse:
-                        connection.privmsg(replyto, '%s!'curse)
-            else:   # Syntax error.
-                if curse:
-                    connection.privmsg(replyto, 'Invalid syntax, for %s help type: %s%s%s' % (curse, font.blue, self.network.command_character, one))
+                            if item.irc_user:
+                                item_user = item.irc_user
+                            else:
+                                item_user = item.web_user
+                            if item.banned:
+                                if item.banned_by_irc_user:
+                                    item_ban_user = queries.get_user_name(self, item.banned_by_irc_user)
+                                else:
+                                    item_ban_user = item.banned_by_web_user
+                                connection.privmsg(replyto, 'Created by %s on %s. Banned by %s on %s.' % (item_user, item.created, item_ban_user, item.ban_created))
+                elif command.split()[1] == 'ban':
+                    if cmdtype == 'help':
+                        connection.privmsg(replyto, 'Bans bot from uttering %s from %s' % (command.split()[3:], command.split()[1]))
+                    else:
+                        item = queries.get_vocabulary_item(self, table_suffix, command.split()[3:])
+                        if not item:
+                            connection.privmsg(replyto, '%s is not in my vocabulary.' % command.split()[3:])
+                        else:
+                            queries.ban_vocabulary_item(self, command.split()[1], user.id, item.id)
+                            connection.privmsg(replyto, '%s banned from %s' % (command.split()[3:]), commands.split()[1])
                 else:
-                    connection.privmsg(replyto, 'Invalid syntax, for help type: %s%s%s' % (font.blue, self.network.command_character, one))
-        elif command.split() >= 4:  # Too many arguments.
-            connection.privmsg(replyto, 'Too many arguments, for help type: %s%s%s' % (font.blue, self.network.command_character, one))
+                    connection.privmsg(replyto, 'Invalid catagory. To list valid categories use: %s%s%s list categories' % (font.blue, self.network.command_character, one))
+            else:
+                connection.privmsg(replyto, 'Invalid catagory. To list valid categories use: %s%s%s list categories' % (font.blue, self.network.command_character, one))
+
+    # elif one == 'curse':
+    #     curse = queries.random_curse(self)
+    #     if command.split() == 1:    # Command without arguments
+    #         if cmdtype == 'help':
+    #             if curse:
+    #                 connection.privmsg(replyto, 'Add, lookup, or display a random %s curse word. The word argument is optional, to add a new word%s %s%s add%s %sword%s, or an adjective: %s%s%s adj' % (curse, font.blue, self.network.command_character, one, font.reset, font.italic, font.reset, font.blue, self.network.command_character, one))
+    #             else:
+    #                 connection.privmsg(replyto, 'Add, lookup, or display random curse word. The word argument is optional, to add a new word%s %s%s add%s %sword%s, or an adjective: %s%s%s add adj' % (font.blue, self.network.command_character, one, font.reset, font.italic, font.reset, font.blue, self.network.command_character, one))
+    #             connection.privmsg(replyto, '%sUsage:%s %s%s%s %sword' % (font.grey, font.blue, self.network.command_character, one, font.reset, font.italic))
+    #         else:   # Actual command without arguments.
+    #             curseword = queries.random_curseword(self)
+    #             connection.privmsg(replyto, curseword)
+    #     elif command.split() == 2:   # Command with one argument.
+    #         if cmdtype == 'help':
+    #             if swear:
+    #                 connection.privmsg(replyto, 'Look up a %s swear word: %s%s' % (swear, font.italic, command.split()[1]))
+    #             else:
+    #                 connection.privmsg(replyto, 'Look up swear word: %s%s' % (font.italic, command.split()[1]))
+    #         else:   # Actual command with one argument.
+    #             curseword = quiries.get_curseword(self, command.split()[1])
+    #             if curseword.banned:
+    #                 if curse:
+    #                     connection.privmsg(replyto, 'Sorry, %s this word is banned!' % curse)
+    #                 else:
+    #                     connection.privmsg(replyto, 'Sorry, this word is banned.')
+    #             elif curseword.irc_user:
+    #                 user_name = quiries.get_user_name(self, curseword.irc_user.id)
+    #                 connection.privmsg(replyto, 'Added %s by %s%s%s.' % (curseword.created, font.red, user_name, font.reset))
+    #             elif curseword.web_user:
+    #                 #user_name = quiries.get_user_name(self, curseword.irc_user.id)
+    #                 connection.privmsg(replyto, 'Added %s by %s%s%s.' % (curseword.created, font.red, 'a web user', font.reset))
+    #     elif command.split() == 3:  # Command with two arguments.
+    #         if command.split()[1] == 'add': # Add a curse word.
+    #             if cmdtype == 'help':
+    #                 connection.privmsg(replyto, 'Adds curse word %s to my vocabulary.' % (command.split()[2]))
+    #             else:   # Actual command.
+    #                 if command.split()[2] == 'adj':
+    #                     curse = queries.random_curse(self)
+    #                     if curse:
+    #                         connection.privmsg(replyto, '%sAdj%s is not a %s swearword!' % (font.italic, font.reset, curse))
+    #                     else:
+    #                         connection.privmsg(replyto, '%sAdj%s is not a swearword.' % (font.italic, font.reset))
+    #                     return
+    #                 queries.add_curseword(self, command.split()[2], user.id)
+    #                 if curse:
+    #                     connection.privmsg(replyto, '%s!' % curse)
+    #         elif command.split()[1] == 'adj':   # Add an adjective.
+    #             if cmdtype == 'help':
+    #                 connection.privmsg(replyto, 'Adds adjective %s to my vocabulary.' % (command.split()[2]))
+    #             else:   # Actual command.
+    #                 queries.add_adjective(self, command.split()[2], user.id)
+    #                 if curse:
+    #                     connection.privmsg(replyto, '%s!'curse)
+    #         else:   # Syntax error.
+    #             if curse:
+    #                 connection.privmsg(replyto, 'Invalid syntax, for %s help type: %s%s%s' % (curse, font.blue, self.network.command_character, one))
+    #             else:
+    #                 connection.privmsg(replyto, 'Invalid syntax, for help type: %s%s%s' % (font.blue, self.network.command_character, one))
+    #     elif command.split() >= 4:  # Too many arguments.
+    #         connection.privmsg(replyto, 'Too many arguments, for help type: %s%s%s' % (font.blue, self.network.command_character, one))

+ 5 - 1
rotbot/commands/games.py

@@ -22,9 +22,10 @@ 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_games_commands(self, channel.id):   # Games are turned off in channel settigns.
+        if not queries.get_channel_setting_games(self, channel.id):   # Games are turned off in channel settigns.
             return  # Do nothing.
 
+    # Command list.
     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]))
@@ -133,6 +134,9 @@ def do_command(self, connection, event, user, channel):
                     return
             else:   # Channel message
                 if not command.split()[1] in self.channels[event.target].users():
+                    print('!!!!!!!!!!!!! people with weird characters (^[) are not seen as on the channel')
+                    print(command.split()[1])
+                    print(self.channels[event.target].users())
                     connection.privmsg(replyto, font.red + trigger.split()[1] + font.reset + " is not present on this channel.")
                     return
 

+ 1 - 0
rotbot/commands/public.py

@@ -29,6 +29,7 @@ def do_command(self, connection, event, user, channel):
     #         connection.privmsg(replyto, str(self.channels[self.homechannel].owners()))
     #         connection.privmsg(event.source.nick, self.channels[event.target].users())
 
+    # Command list.
     if command == 'cmd' or command == 'cmds' or command == 'commands':
         if len(command.split()) == 1:   # No arguments.
             if cmdtype == 'help':    #Display help text.

+ 1 - 0
rotbot/commands/statistics.py

@@ -25,6 +25,7 @@ def do_command(self, connection, event, user, channel):
         if not queries.get_channel_setting_statistic_commands(self, channel.id):
             return
 
+    # Command list.
     if command == 'cmd' or command == 'cmds' or command == 'commands':
         if cmdtype == 'cmd':
             connection.privmsg(replyto, '%sStatistics: %s' % (font.grey, CH.ccc(self, "stat")[:-2])) #CH.ccc(self, "seen") + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "messages") + CH.ccc(self, "actions") + CH.ccc(self, "notices")[:-2] + "."))

+ 38 - 15
rotbot/common/queries.py

@@ -51,7 +51,7 @@ def create_or_get_and_update_last_event(self, table, event_type, channel_name=No
 
         fields = 'name, network_id, slug, last_event_type, last_event_datetime'
         values = '%(name)s, %(network_id)s, %(slug)s, %(last_event_type)s, %(last_event_datetime)s'
-        event_datetime = datetime.datetime.now
+        #event_datetime = datetime.datetime.now
         event_channel_id = None
         event_user_id = None
         event_subject_id = None
@@ -139,7 +139,7 @@ def get_channel_slug(self, channel_name):
 def get_channel_setting_statistic_commands(self, channel_id):
     return self.db.one('SELECT statistic_commands FROM rotbot_channel WHERE id=%(channel_id)s', channel_id=channel_id)
 
-def get_channel_setting_games_commands(self, channel_id):
+def get_channel_setting_games(self, channel_id):
     return self.db.one('SELECT games FROM rotbot_channel WHERE id=%(channel_id)s', channel_id=channel_id)
 
 def get_channel_setting_chat(self, channel_id):
@@ -218,16 +218,16 @@ def get_user_total_cursewords_added(self, user_id):
     recordset = self.db.all('SELECT id FROM rotbot_curseword WHERE irc_user_id=%(user_id)s ', user_id=user_id)
     return recordset.count(recordset)
 
-def get_user_total_curseadjectives_added(self, user_id):
-    recordset = self.db.all('SELECT id FROM rotbot_curseadjective WHERE irc_user_id=%(user_id)s', user_id=user_id)
+def get_user_total_adjectives_added(self, user_id):
+    recordset = self.db.all('SELECT id FROM rotbot_adjective WHERE irc_user_id=%(user_id)s', user_id=user_id)
     return recordset.count(recordset)
 
 def get_user_total_cursewords_banned(self, user_id):
     recordset = self.db.all('SELECT id FROM rotbot_curseword WHERE banned=True AND irc_user_id=%(user_id)s ', user_id=user_id)
     return recordset.count(recordset)
 
-def get_user_total_curseadjectives_banned(self, user_id):
-    recordset = self.db.all('SELECT id FROM rotbot_curseadjective WHERE banned=True AND irc_user_id=%(user_id)s', user_id=user_id)
+def get_user_total_adjectives_banned(self, user_id):
+    recordset = self.db.all('SELECT id FROM rotbot_adjective WHERE banned=True AND irc_user_id=%(user_id)s', user_id=user_id)
     return recordset.count(recordset)
 
 def get_user_last_greet(self, user_id):
@@ -252,9 +252,21 @@ def get_user_channel_kicks(self, user_id, channel_id):
 
 
 # Chat
+def add_vocabulary_item(self, table_suffix, user_id, content):
+    self.db.one('INSERT INTO rotbot_' + talbe_suffix + ' (content, created, irc_user_id) VALUES (%(content)s, %(created)s, %(user_id)s)', content=content, created=datetime.datetime.now(), user_id=user_id)
+
+def get_vocabulary_item(self, talbe_suffix, content):
+    return self.db.one('SELECT * FROM rotbot_' + table_suffix + ' WHERE content=%(content)')
+
+def ban_vocabulary_item(self, table_suffix, user_id, item_id):
+    self.db.one('UPDATE rotbot_' + table_suffix + ' SET banned=True, ban_created=%(ban_created)s, banned_by_irc_user_id=%(user_id)s WHERE id=%(item_id)s', ban_created=datetime.datetime.now(), user_id=user_id, item_id=item_id)
+
+def random_vocabulary_item(self, table_suffix):
+    return self.db.one('SELECT content FROM rotbot_' + table_suffix + ' WHERE banned=False ORDER BY RANDOM() LIMIT 1')
+
 def random_curse(self):
-    adjective = self.db.one('SELECT word FROM rotbot_curseadjective WHERE banned=False ORDER BY RANDOM() LIMIT 1')
-    curse = self.db.one('SELECT word FROM rotbot_curseword WHERE banned=False ORDER BY RANDOM() LIMIT 1')
+    adjective = self.db.one('SELECT content FROM rotbot_adjective WHERE banned=False ORDER BY RANDOM() LIMIT 1')
+    curse = self.db.one('SELECT content FROM rotbot_curseword WHERE banned=False ORDER BY RANDOM() LIMIT 1')
 
     # Try to hint the user of my capabilities.
     if not adjective:
@@ -267,20 +279,31 @@ def random_curse(self):
     return '%s %s' % (adjective, curse)
 
 def random_adjective(self):
-    adjective = self.db.one('SELECT word FROM rotbot_curseadjective ORDER BY RANDOM() LIMIT 1')
+    adjective = self.db.one('SELECT content FROM rotbot_adjective ORDER BY RANDOM() LIMIT 1')
 
     # Try to hint the user of my capabilities.
     if not adjective:
         log.notice('No adjectives in database, please add some for more colourfull language.')
 
-    return self.db.one('SELECT word FROM rotbot_curseadjective ORDER BY RANDOM() LIMIT 1')
+    return adjective
+
+def random_curseword(self):
+    curseword = self.db.one('SELECT content FROM rotbot_nickresponse WHERE banned=False ORDER BY RANDOM() LIMIT 1')
+
+    # Try to hint the user of my capabilities.
+    if not curseword:
+        log.notice('No cursewords in database, please add some for more colourfull language.')
+
+    return curseword
+
+# Phasing out.
+# def get_curse(self, word):
+#     return self.db.one('SELECT * FROM rotbot_curseword WHERE LOWER(content)=LOWER(%(content)s)')
 
-def get_curse(self, word):
-    return self.db.one('SELECT * FROM rotbot_curseword WHERE LOWER(word)=LOWER(%(word)s)')
+# def add_curseword(self, word, user_id):
+#     user_id = get_user_id(self, user_name)
+#     return self.db.run('INSERT INTO rotbot_curseword (content, created, irc_user_id, banned) VALUES (%(content)s, %(created)s, %(irc_user_id)s, %(banned)s)', word=word, created=datetime.datetime.now(), irc_user_id=user_id, banned=False)
 
-def add_curseword(self, word, user_id):
-    user_id = get_user_id(self, user_name)
-    return self.db.run('INSERT INTO rotbot_curseword (word, created, irc_user_id, banned) VALUES (LOWER(%(word)s), %(created)s, %(irc_user_id)s, %(banned)s)', word=word, created=datetime.datetime.now, irc_user_id=user_id, banned=False)
 
 
 # Statistics

+ 2 - 2
rotbot/events/on_kick.py

@@ -1,5 +1,5 @@
 #from common.networkservices import ChanServ
-from common import log, queries, language, userstatus#, do_everything_to, log, font, queries
+from common import log, queries, language, userstatus, font#, do_everything_to
 #from events.common import Aggressiveness, Lastact
 
 def process_event(self, connection, event):
@@ -23,7 +23,7 @@ def process_event(self, connection, event):
         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))
         return
 
-    if self.channel[event.target].has_user(event.arguments[0]): # User resides in homechannel.
+    if self.channels[event.target].has_user(event.arguments[0]): # User resides in homechannel.
         if userstatus.is_owner(self, event.arguments[0], event.target) or queries.is_owner(self, hostmask) or event.arguments[0] == conntection.get_nickname():    # Owner or bot kicked.
             log.info('Kicking %s from %s for kicking %s.' % (event.sourcenick, event.target, event.arguments[0]))
             if reason:

+ 4 - 3
rotbot/events/on_privmsg.py

@@ -1,4 +1,4 @@
-import commands.public, commands.admin, commands.games, commands.statistics
+import commands.public, commands.admin, commands.games, commands.statistics, commands.chat
 from common import log, queries, font
 from events.common import Inform
 
@@ -14,6 +14,7 @@ def process_event(self, connection, event):
 
     # Respond to commands.
     commands.public.do_command(self, connection, event, user, channel)
-    commands.admin.do_command(self, connection, event, user, channel)
-    commands.statistics.do_command(self, connection, event, user, channel)
     commands.games.do_command(self, connection, event, user, channel)
+    commands.statistics.do_command(self, connection, event, user, channel)
+    commands.chat.do_command(self, connection, event, user, channel)
+    commands.admin.do_command(self, connection, event, user, channel)

+ 5 - 3
rotbot/events/on_privnotice.py

@@ -1,5 +1,5 @@
 import asyncio, time
-import commands.public, commands.admin, commands.games, commands.statistics
+import commands.public, commands.admin, commands.games, commands.statistics, commands.chat
 from common import log, queries, font
 from events.common import Inform
 
@@ -15,10 +15,12 @@ def process_event(self, connection, event):
     user = queries.create_or_get_and_update_last_event(self, 'user', 'pn', user_name=event.source.nick, event_subject_name=event.target)
     channel = None
 
+    # Respond to commands.
     commands.public.do_command(self, connection, event, user, channel)
-    commands.admin.do_command(self, connection, event, user, channel)
-    commands.statistics.do_command(self, connection, event, user, channel)
     commands.games.do_command(self, connection, event, user, channel)
+    commands.statistics.do_command(self, connection, event, user, channel)
+    commands.chat.do_command(self, connection, event, user, channel)
+    commands.admin.do_command(self, connection, event, user, channel)
 
     if event.source.nick == connection.get_nickname():  # Message came from myself.
         return

+ 5 - 3
rotbot/events/on_pubmsg.py

@@ -1,5 +1,5 @@
 import datetime, pytz
-import commands.public, commands.admin, commands.games, commands.statistics
+import commands.public, commands.admin, commands.games, commands.statistics, commands.chat
 from common import log, queries
 
 
@@ -11,10 +11,12 @@ def process_event(self, connection, event):
     user = queries.create_or_get_and_update_last_event(self, 'user', 'cm', channel_name=event.target, user_name=event.source.nick)
     queries.update_message_statistics(self, 'message', channel.id, user.id)   # Update message statistics
 
+    # Respond to commands.
     commands.public.do_command(self, connection, event, user, channel)
-    commands.admin.do_command(self, connection, event, user, channel)
-    commands.statistics.do_command(self, connection, event, user, channel)
     commands.games.do_command(self, connection, event, user, channel)
+    commands.statistics.do_command(self, connection, event, user, channel)
+    commands.chat.do_command(self, connection, event, user, channel)
+    commands.admin.do_command(self, connection, event, user, channel)
 
     # Stop if channelfunction chat if off.
     if not queries.get_channel_setting_chat(self, channel.id):

+ 0 - 4
rotbot/events/on_quit.py

@@ -5,7 +5,3 @@ def process_event(self, connection, event):
 
     # Get and update resources.
     user = queries.create_or_get_and_update_last_event(self, 'user', 'sq', user_name=event.source.nick)#, extra_content=event.)
-
-    # # Update protectees.
-    # if event.source.nick in self.protectees:    # Protectee parted home channel.
-    #     del self.protectees[event.source.nick] # Delete from protectees.

+ 2 - 2
rotbot/events/on_welcome.py

@@ -14,7 +14,7 @@ def process_event(self, connection, event):
         if self.network.password:   # Password saved.
             connection.privmsg(self.xbot, 'LOGIN %s %s' % (self.networkself.nickname, self.network.password))   # Identify with X.
 
-    connection.mode(connection.get_nickname(), "+x")
+    connection.mode(connection.get_nickname(), "-x")
 
     do_everything_to.join(self, connection, self.network.home_channel)  # Join home channel.
 
@@ -24,4 +24,4 @@ def process_event(self, connection, event):
     for channel in channels:
         connection.join(channel)    # Join channels with autojoin function.
 
-    connection.privmsg('NickServ', 'ACCESS LIST')   # Request access list from NickServ.
+    #connection.privmsg('NickServ', 'ACCESS LIST')   # Request access list from NickServ.

+ 9 - 9
website/rotbot/forms.py

@@ -2,7 +2,7 @@ from django import forms
 from django.forms import ModelForm, CharField, SlugField
 from django.core.validators import validate_unicode_slug
 
-from .models import Network, Host, Channel, Owner, CurseWord, CurseAdjective
+from .models import Network, Host, Channel, Owner, CurseWord, Adjective
 
 class NetworkForm(ModelForm):
     class Meta:
@@ -83,21 +83,21 @@ class ChannelForm(ModelForm):
 class CurseWordForm(ModelForm):
     class Meta:
         model=CurseWord
-        fields={'word'}
+        fields={'content'}
         labels={
-            'word': '<i class="book dead icon"></i>Curse word'
+            'content': '<i class="book dead icon"></i>Curse word'
         }
         widgets={
-            'word': forms.TextInput(attrs={'_no_required': 'True'}),
+            'content': forms.TextInput(attrs={'_no_required': 'True'}),
         }
 
-class CurseAdjectiveForm(ModelForm):
+class AdjectiveForm(ModelForm):
     class Meta:
-        model=CurseAdjective
-        fields={'word'}
+        model=Adjective
+        fields={'content'}
         labels={
-            'word': '<i class="book dead icon"></i>Adjective'
+            'content': '<i class="book dead icon"></i>Adjective'
         }
         widgets={
-            'word': forms.TextInput(attrs={'_no_required': 'True'}),
+            'content': forms.TextInput(attrs={'_no_required': 'True'}),
         }

+ 67 - 0
website/rotbot/migrations/0008_auto_20191123_0357.py

@@ -0,0 +1,67 @@
+# Generated by Django 2.2.6 on 2019-11-23 02:57
+
+from django.conf import settings
+from django.db import migrations, models
+import django.db.models.deletion
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        migrations.swappable_dependency(settings.AUTH_USER_MODEL),
+        ('rotbot', '0007_auto_20191121_2056'),
+    ]
+
+    operations = [
+        migrations.CreateModel(
+            name='Adjective',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('content', models.CharField(max_length=16, unique=True)),
+                ('created', models.DateField(auto_now_add=True)),
+                ('banned', models.BooleanField(default=False)),
+                ('ban_created', models.DateField(blank=True, null=True)),
+                ('banned_by_irc_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='adjective_banned_by_irc_user', to='rotbot.User')),
+                ('banned_by_web_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='adjective_banned_by_web_user', to=settings.AUTH_USER_MODEL)),
+                ('irc_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='rotbot.User')),
+                ('web_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
+            ],
+        ),
+        migrations.CreateModel(
+            name='NickReply',
+            fields=[
+                ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
+                ('content', models.CharField(max_length=200, unique=True)),
+                ('created', models.DateField(auto_now_add=True)),
+                ('banned', models.BooleanField(default=False)),
+                ('ban_created', models.DateField(blank=True, null=True)),
+                ('banned_by_irc_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='nickreply_banned_by_irc_user', to='rotbot.User')),
+                ('banned_by_web_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='nickreply_banned_by_web_user', to=settings.AUTH_USER_MODEL)),
+                ('irc_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='rotbot.User')),
+                ('web_user', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)),
+            ],
+        ),
+        migrations.RenameField(
+            model_name='curseword',
+            old_name='word',
+            new_name='content',
+        ),
+        migrations.AddField(
+            model_name='curseword',
+            name='ban_created',
+            field=models.DateField(blank=True, null=True),
+        ),
+        migrations.AddField(
+            model_name='curseword',
+            name='banned_by_irc_user',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='curseword_banned_by_irc_user', to='rotbot.User'),
+        ),
+        migrations.AddField(
+            model_name='curseword',
+            name='banned_by_web_user',
+            field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='curseword_banned_by_web_user', to=settings.AUTH_USER_MODEL),
+        ),
+        migrations.DeleteModel(
+            name='CurseAdjective',
+        ),
+    ]

+ 81 - 3
website/rotbot/models.py

@@ -440,7 +440,7 @@ class Kick(models.Model):
         unique_together = ['network', 'channel', 'kicker', 'kicked']
 
 class CurseWord(models.Model):
-    word = models.CharField(
+    content = models.CharField(
         max_length=16,
         unique=True,
     )
@@ -462,12 +462,30 @@ class CurseWord(models.Model):
     banned = models.BooleanField(
         default=False,
     )
+    ban_created = models.DateField(
+        null=True,
+        blank=True,
+    )
+    banned_by_irc_user = models.ForeignKey(
+        'User',
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+        related_name='curseword_banned_by_irc_user',
+    )
+    banned_by_web_user = models.ForeignKey(
+        WebUser,
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+        related_name='curseword_banned_by_web_user',
+    )
 
     def __str__(self):
         return self.word
 
-class CurseAdjective(models.Model):
-    word = models.CharField(
+class Adjective(models.Model):
+    content = models.CharField(
         max_length=16,
         unique=True,
     )
@@ -489,6 +507,66 @@ class CurseAdjective(models.Model):
     banned = models.BooleanField(
         default=False,
     )
+    ban_created = models.DateField(
+        null=True,
+        blank=True,
+    )
+    banned_by_irc_user = models.ForeignKey(
+        'User',
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+        related_name='adjective_banned_by_irc_user',
+    )
+    banned_by_web_user = models.ForeignKey(
+        WebUser,
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+        related_name='adjective_banned_by_web_user',
+    )
 
     def __str__(self):
         return self.word
+
+class NickReply(models.Model):
+    content = models.CharField(
+        max_length=200,
+        unique=True,
+    )
+    created = models.DateField(
+        auto_now_add=True,
+    )
+    irc_user = models.ForeignKey(
+        'User',
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+    )
+    web_user = models.ForeignKey(
+        WebUser,
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+    )
+    banned = models.BooleanField(
+        default=False,
+    )
+    ban_created = models.DateField(
+        null=True,
+        blank=True,
+    )
+    banned_by_irc_user = models.ForeignKey(
+        'User',
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+        related_name='nickreply_banned_by_irc_user',
+    )
+    banned_by_web_user = models.ForeignKey(
+        WebUser,
+        on_delete=models.PROTECT,
+        null=True,
+        blank=True,
+        related_name='nickreply_banned_by_web_user',
+    )

+ 3 - 0
website/rotbot/templates/rotbot/channel.html

@@ -58,4 +58,7 @@
   {% if channel.statistic_commands %}
     <i class="chart pie icon"></i>
   {% endif %}
+  {% if channel.games %}
+    <i class="gamepad icon"></i>
+  {% endif %}
 {% endblock content %}

+ 10 - 16
website/rotbot/views/general.py

@@ -6,8 +6,8 @@ from django.forms import modelformset_factory
 #from django.views import generic
 from django.contrib.auth.decorators import login_required, permission_required
 from website.settings import APPLICATION_NAME
-from rotbot.models import Network, Host, Channel, User, Message, Action, Notice, Join, Kick, CurseWord, CurseAdjective
-from rotbot.forms import CurseWordForm, CurseAdjectiveForm
+from rotbot.models import Network, Host, Channel, User, Message, Action, Notice, Join, Kick, CurseWord, Adjective
+from rotbot.forms import CurseWordForm, AdjectiveForm
 from rotbot.views.common import default_keywords, shorten_number, total_messages
 
 # Common
@@ -279,26 +279,20 @@ def RGB_to_hex(RGB):
 @permission_required('rotbot.add_curseword', raise_exception=True)
 def add_curseword(request):
     CurseWordFormSet = modelformset_factory(CurseWord, form=CurseWordForm, extra=4)
-    CurseAdjectiveFormSet = modelformset_factory(CurseAdjective, form=CurseAdjectiveForm, extra=4)
+    AdjectiveFormSet = modelformset_factory(Adjective, form=AdjectiveForm, extra=4)
     if request.method == 'POST':
         curseword_formset = CurseWordFormSet(request.POST)
-        curseadjective_formset = CurseAdjectiveFormSet(request.POST)
-        if curseword_formset.is_valid() and curseadjective_formset.is_valid():
-            new_cursewords = curseword_formset.save(commit=False)
-            new_curseadjectives = curseadjective_formset.save(commit=False)
-            for record in new_cursewords:
-                record.word = record.word.lower()
-                record.save()
-            for record in new_curseadjectives:
-                record.word = record.word.lower()
-                record.save()
+        Adjective_formset = AdjectiveFormSet(request.POST)
+        if curseword_formset.is_valid() and Adjective_formset.is_valid():
+            curseword_formset.save()
+            Adjective_formset.save()
             return HttpResponseRedirect(reverse('rotbot:networks'))
         else:
             curseword_formset = CurseWordFormSet(queryset=CurseWord.objects.none())
-            curseadjective_formset = CurseWordFormSet(queryset=CurseAdjective.objects.none())
+            Adjective_formset = CurseWordFormSet(queryset=Adjective.objects.none())
     else:   # Not a POST request.
         curseword_formset = CurseWordFormSet(queryset=CurseWord.objects.none())
-        curseadjective_formset = CurseAdjectiveFormSet(queryset=CurseAdjective.objects.none())
+        Adjective_formset = AdjectiveFormSet(queryset=Adjective.objects.none())
 
     context = {
         'parent_title': 'RotBot',
@@ -309,6 +303,6 @@ def add_curseword(request):
         'description': 'Add a curseword to RotBot\'s vocabulary.',
         'keywords': default_keywords(),
         'curseword_formset': curseword_formset,
-        'curseadjective_formset': curseadjective_formset,
+        'Adjective_formset': Adjective_formset,
     }
     return render(request, 'rotbot/add_curseword.html', context)