Parcourir la source

some website text

tBKwtWS il y a 6 ans
Parent
commit
084743f109

+ 36 - 27
rotbot/commands/chat.py

@@ -41,11 +41,11 @@ def do_command(self, connection, event, user, channel):
         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%s List definitions: %s%s%s list definitions' % (font.blue, self.network.command_character, one, font.reset, font.blue, self.network.command_character, one, font.reset, font.blue, self.network.command_character, one))
-            elif command.split()[1].lower() in categories:
+            elif command.split()[1].lower() in [category.lower() for category in categories]:
                 if cmdtype == 'help':
                     connection.privmsg(replyto, 'Show a random %s' % command.split()[1])
                 else:
-                    connection.privmsg(replyto, queries.random_vocabulary_item(self, command.split()[1].lower()))
+                    connection.privmsg(replyto, str(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.
@@ -54,7 +54,7 @@ def do_command(self, connection, event, user, channel):
                     if cmdtype == 'help':
                         connection.privmsg(replyto, 'Lists available categories.')
                     else:   # List categories
-                        connection.privmsg(replyto, ' ,'.join(categories))
+                        connection.privmsg(replyto, ', '.join(categories))
                 elif command.split()[2] == 'options':
                     if cmdtype == 'help':
                         connection.privmsg(replyto, 'Lists available options.')
@@ -62,59 +62,68 @@ def do_command(self, connection, event, user, channel):
                         connection.privmsg(replyto, 'add, info, ban')
                 elif command.split()[2] == 'definitions':
                     if cmdtype == 'help':
-                        connection.privmsg(replyto, 'Lists definitions of categories.')
+                        connection.privmsg(replyto, 'Lists definitions of definitions.')
                     else:
                         connection.privmsg(replyto, 'CurseWord: A not to harsh swear word, let\'s keep it funny, not vulgar. Adjective: Something you would put in front of a curse word. NickReplyMessage: A response to when my name is mentioned. NickReplyAction: An action (Also know as emote or /me) in responce to when my name is mentioned.')
                 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].lower() in categories:
+            elif command.split()[1].lower() in [category.lower() for category in categories]:
                 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])
+                        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]))
+                        connection.privmsg(replyto, queries.random_vocabulary_item(self, commands.spit()[1].lower()))
                 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].lower() in categories:
+            if command.split()[1].lower() in [category.lower() for category in categories]:
                 if command.split()[2] == 'add':
                     if cmdtype == 'help':
-                        connection.privmsg(replyto, 'Adds %s to %s' % (command.split()[3:], command.split()[1]))
+                        connection.privmsg(replyto, 'Adds %s as %s' % (command.split()[3:][0], 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])
+                        item = queries.get_vocabulary_item(self, command.split()[1].lower(), command.split()[3:][0])
+                        if item:
+                            connection.privmsg(replyto, '%s already present as %s.' % (command.split()[3:][0], command.split()[1]))
+                        else:
+                            queries.add_vocabulary_item(self, command.split()[1].lower(), user.id, command.split()[3:][0])
+                            connection.privmsg(replyto, '%s added as %s' % (command.split()[3:][0], command.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]))
+                        connection.privmsg(replyto, 'Displays info on %s from %s.' % (command.split()[3:][0], command.split()[1]))
                     else:
-                        item = queries.get_vocabulary_item(self, command.split()[1], command.split()[3:])
+                        item = queries.get_vocabulary_item(self, command.split()[1].lower(), command.split()[3:][0])
                         if not item:
-                            connection.privmsg(replyto, '%s is not in my vocabulary.' % command.split()[3:])
+                            connection.privmsg(replyto, '%s is not in my vocabulary.' % command.split()[3:][0])
                         else:
-                            if item.irc_user:
-                                item_user = item.irc_user
+                            if item.irc_user_id:
+                                item_user = item.irc_user_id
                             else:
-                                item_user = item.web_user
+                                item_user = item.web_user_id
                             if item.banned:
-                                if item.banned_by_irc_user:
-                                    item_ban_user = queries.get_user_name(self, item.banned_by_irc_user)
+                                if item.banned_by_irc_user_id:
+                                    item_ban_user = queries.get_user_name(self, item.banned_by_irc_user_id)
                                 else:
-                                    item_ban_user = item.banned_by_web_user
+                                    item_ban_user = item.banned_by_web_user_id
                                 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':
+                            else:
+                                connection.privmsg(replyto, 'Created by %s on %s.' % (item_user, item.created))
+                elif command.split()[2] == 'ban':
                     if cmdtype == 'help':
-                        connection.privmsg(replyto, 'Bans bot from uttering %s from %s' % (command.split()[3:], command.split()[1]))
+                        connection.privmsg(replyto, 'Bans bot from uttering %s from %s' % (command.split()[3:][0], command.split()[1]))
                     else:
-                        item = queries.get_vocabulary_item(self, table_suffix, command.split()[3:])
+                        item = queries.get_vocabulary_item(self, command.split()[1].lower(), command.split()[3:][0])
                         if not item:
-                            connection.privmsg(replyto, '%s is not in my vocabulary.' % command.split()[3:])
+                            connection.privmsg(replyto, '%s is not in my vocabulary.' % command.split()[3:][0])
                         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])
+                            if item.banned:
+                                connection.privmsg(replyto, '%s already banned as %s.' % (command.split()[3:][0], command.split()[1]))
+                            else:
+                                queries.ban_vocabulary_item(self, command.split()[1].lower(), user.id, item.id)
+                                connection.privmsg(replyto, '%s banned as %s.' % (command.split()[3:][0], command.split()[1]))
                 else:
-                    connection.privmsg(replyto, 'Invalid catagory. To list valid categories use: %s%s%s list categories' % (font.blue, self.network.command_character, one))
+                    connection.privmsg(replyto, 'Invalid option. Options are: list 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))
 

+ 0 - 3
rotbot/commands/games.py

@@ -134,9 +134,6 @@ 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
 

+ 4 - 4
rotbot/common/queries.py

@@ -248,13 +248,13 @@ 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)
+    self.db.run('INSERT INTO rotbot_' + table_suffix + ' (content, created, irc_user_id, banned) VALUES (%(content)s, %(created)s, %(user_id)s, False)', 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 get_vocabulary_item(self, table_suffix, content):
+    return self.db.one('SELECT * FROM rotbot_' + table_suffix + ' WHERE content=%(content)s', 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)
+    self.db.run('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')

+ 17 - 3
website/core/templates/core/index.html

@@ -1,12 +1,26 @@
 {% extends "base.html" %}
 {% block content %}
   {% if 'knowledgebase.apps.KnowledgebaseConfig' in settings.INSTALLED_APPS %}
-    <a href="{% url 'knowledgebase:index'  %}"><i class="newspaper outline icon"></i>Knowledgebase</a><br />
+    <a href="{% url 'knowledgebase:index'  %}">
+      <button class="ui basic inverted labeled icon button">
+        <i class="newspaper outline icon"></i>
+        Knowledgebase
+      </button>
+    </a><br />
   {% endif %}
   {% if 'dancecalendar.apps.DancecalendarConfig' in settings.INSTALLED_APPS %}
-    <a href="{% url 'dancecalendar:index'  %}"><i class="calendar alternate icon"></i>Dance calendar</a><br />
+    <a href="{% url 'dancecalendar:index'  %}">
+      <button class="ui basic inverted labeled icon button">
+        <i class="calendar alternate icon"></i>
+        Dance calendar
+      </button>
+    </a><br />
   {% endif %}
   {% if 'rotbot.apps.RotbotConfig' in settings.INSTALLED_APPS %}
-    <a href="{% url 'rotbot:networks' %}"><i class="robot icon"></i>RotBot</a><br />
+    <a href="{% url 'rotbot:networks' %}">
+      <button class="ui basic inverted labeled icon button">
+        <i class="robot icon"></i>RotBot
+      </button>
+    </a>
   {% endif %}
 {% endblock %}

+ 27 - 32
website/rotbot/templates/rotbot/index.html

@@ -1,14 +1,6 @@
 {% extends "base.html" %}
 {% block content %}
-  <div class="ui five inverted grey statistics">
-    <div class="statistic">
-      <div class="value">
-        <i class="book dead icon"></i> {{ total_cursewords }}
-      </div>
-      <div class="label">
-        Curse words
-      </div>
-    </div>
+  <div class="ui four inverted grey statistics">
     <div class="statistic">
       <div class="value">
         <i class="sitemap icon"></i> {{ total_networks }}
@@ -42,48 +34,51 @@
       </div>
     </div>
   </div>
-  <div class="ui five tiny inverted grey statistics">
-    <div class="statistic">
-      <div class="value">
-        <i class="comments  icon"></i> {{ total_messages }}
-      </div>
-      <div class="label">
-        Messages
-      </div>
-    </div>
-    <div class="statistic">
-      <div class="value">
-        <i class="theater masks icon"></i> {{ total_actions }}
-      </div>
-      <div class="label">
-        Actions
-      </div>
-    </div>
+  <div class="ui three tiny inverted grey statistics">
     <div class="statistic">
       <div class="value">
-        <i class="bullhorn icon"></i> {{ total_notices }}
+        <i class="book dead icon"></i> {{ total_cursewords }}
       </div>
       <div class="label">
-        Notices
+        Curse words
       </div>
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="user plus icon"></i> {{ total_joins }}
+        <i class="book icon"></i> {{ total_adjectives }}
       </div>
       <div class="label">
-        Joins
+        Adjectives
       </div>
     </div>
     <div class="statistic">
       <div class="value">
-        <i class="user slash icon"></i> {{ total_kicks }}
+        <i class="bullhorn icon"></i> {{ total_nickreplies }}
       </div>
       <div class="label">
-        Kicks
+        Nick replies
       </div>
     </div>
   </div>
+  <div class="ui inverted compact segment">
+    <p>
+      After <i>WinRot</i> and <i>JavaRot</i> now there is <i>pyRot</i>.<br />
+      A python version of <b>RotBot</b>, the rotten IRC robot.
+    </p>
+    <p>
+      I was originally intended to piss off my creators friends, by teasing them with their habits.<br />
+      The project evolved into developting a <b>game</b> based on IRC <b>statistics</b>.<br />
+      Sparsly, as <u>not</u> to spam, I still try to cleverly respond to a person or event on IRC sometimes.
+    </p>
+    <p>
+      This site shows these statistics and allows alteration of my settings and vocabulary.
+    </p>
+  </div>
+  <div class="ui inverted compact segment">
+    I have seen {{ total_users }} users and {{ total_channels }} channels on {{ total_networks }} networks with {{ total_hosts }} host servers.<br />
+    Who have sent {{ total_messages }} messages, {{ total_actions }} actions, {{ total_notices }} notices, have joined channels {{ total_joins }} times and been kicked from them {{ total_kicks }} times.<br />
+    I have been taught {{ total_cursewords }} curse words, {{ total_adjectives }} adjectives to use with them and {{ total_nickreplies }} responses to my name.
+  </div>
   {#% if perms.rotbot.add_curseword %#}
     <a href="{% url 'rotbot:add_curseword' %}" class="ui inverted right floated button"><i class="book dead icon"></i>Add curseword</a>
   {#% endif %#}

+ 1 - 0
website/rotbot/templates/rotbot/network_form.html

@@ -40,6 +40,7 @@
     {% endfor %}
     {% render_field form.enabled %}
     <button class="ui right floated inverted positive button" type="submit" value="Submit"><i class="save icon"></i>Save</button>
+    {% block buttons %}{% endblock buttons %}
   </form>
 
 

+ 21 - 11
website/rotbot/templates/rotbot/user.html

@@ -123,18 +123,28 @@
       </div>
     </div>
   </div>
+  <div class ="ui inverted compact segment">
+    <p>
+      <i class="user icon"></i>{{ user.name }} is a user on the {{ network.name }} network.<br />
+    </p>
+    <p>
+      <i class="comment icon"></i>Sent {{ total_messages }} messages, {{ total_actions }} actions, {{ total_notices }} notices and {{ total_kicks }} kicks.<br />
+      <i class="open door icon"></i>Joined a channel {{ total_joins }} times and has been kicked {{ total_kicked }} times.<br />
+
+      <i class="history icon"></i>Last seen {{ last_event_type }}
+      {% if user.last_event_subject %}
+        <i class="icons"><i class="heading icon"></i><i class="corner history icon"></i></i>{{ user.last_event_subject }}
+      {% endif %}
+      {% if user.last_event_channel %}
+        in <i class="icons"><i class="hashtag icon"></i><i class="corner history icon"></i></i>{{ user.last_event_channel }}
+      {% endif %}
+      {% if user.last_event_content %}
+        for <i class="icons"><i class="envelope icon"></i><i class="corner history icon"></i></i>{{ user.last_event_content }}
+      {% endif %}
+      at {{ user.last_event_datetime }}
+    </p>
+  </div>
 
-  <i class="history icon"></i>Last seen {{ last_event_type }}
-  {% if user.last_event_subject %}
-    <i class="icons"><i class="heading icon"></i><i class="corner history icon"></i></i>{{ user.last_event_subject }}
-  {% endif %}
-  {% if user.last_event_channel %}
-    in <i class="icons"><i class="hashtag icon"></i><i class="corner history icon"></i></i>{{ user.last_event_channel }}
-  {% endif %}
-  {% if user.last_event_content %}
-    for <i class="icons"><i class="envelope icon"></i><i class="corner history icon"></i></i>{{ user.last_event_content }}
-  {% endif %}
-  at {{ user.last_event_datetime }}
 
   <i class="microphone alternate slash icon"></i>{{ user.no_chat }}
 

+ 8 - 3
website/rotbot/views/general.py

@@ -6,7 +6,7 @@ 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, Adjective
+from rotbot.models import Network, Host, Channel, User, Message, Action, Notice, Join, Kick, CurseWord, Adjective, NickReplyMessage, NickReplyAction
 from rotbot.forms import CurseWordForm, AdjectiveForm
 from rotbot.views.common import default_keywords, shorten_number, total_messages
 
@@ -36,10 +36,13 @@ def index(request):
     actions = Action.objects.all()
     notices = Notice.objects.all()
     cursewords = CurseWord.objects.all()
+    adjectives = Adjective.objects.all()
+    nickreplymessages = NickReplyMessage.objects.all()
+    nickreplyactions = NickReplyAction.objects.all()
 
     context = {
         'title': 'RotBot',
-        'icon': 'hashtag',
+        'icon': 'robot',
         'description': 'Index of RotBot',
         'keywords': default_keywords('index'),
         'total_networks':shorten_number(networks.count()),
@@ -52,6 +55,8 @@ def index(request):
         'total_actions':shorten_number(actions.count()),
         'total_notices':shorten_number(notices.count()),
         'total_cursewords':shorten_number(cursewords.count()),
+        'total_adjectives':shorten_number(adjectives.count()),
+        'total_nickreplies':shorten_number(nickreplymessages.count() + nickreplyactions.count()),
     }
     return render(request, 'rotbot/index.html', context)
 
@@ -156,7 +161,7 @@ def user(request, user_slug):
         'parent_url': reverse('rotbot:network', args=(network.slug,)),
         'parent_icon': 'sitemap',
         'title': user.name,
-        'icon': 'hashtag',
+        'icon': 'user',
         'description': 'Details of user %s on network %s' % (user.name, network.name),
         'keywords': default_keywords() + '%s, %s' % (network.name, user.name),
         'user': user,