tBKwtWS 6 年之前
父節點
當前提交
58e1057bfe
共有 2 個文件被更改,包括 12 次插入3 次删除
  1. 1 1
      rotbot/common/queries.py
  2. 11 2
      rotbot/events/on_pubmsg.py

+ 1 - 1
rotbot/common/queries.py

@@ -158,7 +158,7 @@ def get_channel_last_lame(self, channel_id):
     return self.db.one('SELECT last_lame FROM rotbot_channel WHERE id=%(channel_id)s', channel_id=channel_id)
 
 def update_channel_last_lame(self, channel_id):
-    return self.db.run('UPDATE rotbot_channel SET last_greet=NOW() WHERE id=%(channel_id)s', channel_id=channel_id)
+    return self.db.run('UPDATE rotbot_channel SET last_lame=NOW() WHERE id=%(channel_id)s', channel_id=channel_id)
 
 def get_channel_key(self, channel_name):
     channel_id = get_channel_id(self, channel_name)     # Inperfect, make a index of the channel_name field.

+ 11 - 2
rotbot/events/on_pubmsg.py

@@ -30,12 +30,21 @@ def process_event(self, connection, event):
     # Character lame.
     elif event.arguments[0] == len(event.arguments[0]) * event.arguments[0][0]:   # Trigger exclusively same character.
 
+        # Stop if it's short and not a dot or exclematin mark,
+        if len(event.arguments[0]) < 3:
+            if event.arguments[0][0] not in ['.', '!']:
+                return
+
+        # Stop if it's long.
+        if len(event.arguments[0]) > 20:
+            return
+
         # Stop if lamed recently.
         timeout = 10    # Timeout in minutes.
         chan_lastlame = queries.get_channel_last_lame(self, channel.id)
         user_lastlame = queries.get_user_last_lame(self, user.id)
-        cet = pytz.timezone('Europe/Amsterdam')
-        if chan_lastlame and chan_lastlame > cet.localize(datetime.datetime.now()) - datetime.timedelta(minutes=timeout) or user_lastlame and user_lastlame > cet.localize(datetime.datetime.now()) - datetime.timedelta(minutes=timeout):  # Lamed channel or user recently.
+        timezone = pytz.timezone('Europe/Amsterdam')
+        if user_lastlame and user_lastlame > timezone.localize(datetime.datetime.now()) - datetime.timedelta(minutes=timeout):  # Lamed user recently.
             return
 
         # Do not say KKK.