ソースを参照

bot stability

tBKwtWS 6 年 前
コミット
d0807c19c7
4 ファイル変更5 行追加6 行削除
  1. 3 1
      README.md
  2. 1 1
      rotbot/bot.py
  3. 1 1
      rotbot/common/queries.py
  4. 0 3
      rotbot/events/on_join.py

+ 3 - 1
README.md

@@ -35,7 +35,9 @@ Fill in the passwords, don't change the database name, it's hardcoded in pyRot,
 1. `CREATE DATABASE website WITH OWNER = website;`
 1. `CREATE ROLE pyrot WITH LOGIN PASSWORD '';`
 1. `GRANT ALL ON DATABASE website TO pyrot;`
-1. `GRANT ALL PRIVILEGES ON ALL TABLES ON DATABASE website IN SCHEMA public TO pyrot;``
+1. Connect to database website
+1. `GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO pyrot;`
+1. `GRANT ALL PRIVILEGES ON ALL SEQUENCES IN SCHEMA public TO pyrot;`
 
 ## DB authentication
 

+ 1 - 1
rotbot/bot.py

@@ -149,7 +149,7 @@ class PyRot(irc.bot.SingleServerIRCBot):
                 return
 
                 # Nick \x02RotBot\x02 isn't registered.
-            if event.arguments[0].startswith(self.network.username + " is not a registered nickname.") or event.arguments[0].startswith('Nick ') and event.arguments[0].endswith(' isn\'t registered.'): # Username from database is not registered.
+            if event.arguments[0].endswith(' is not a registered nickname.') or event.arguments[0].startswith('Nick ') and event.arguments[0].endswith(' isn\'t registered.'): # Username from database is not registered.
                 connection.privmsg('NickServ', 'register %s spamtBK@xs4all.nl' % (self.network.password)) # Register with NickServ.
                 log.info('Registerring with NickServ.')
             if event.arguments[0].startswith('Nickname ') and event.arguments[0].endswith(' registered.'):

+ 1 - 1
rotbot/common/queries.py

@@ -6,6 +6,6 @@ def create_ifnot_onrecord(self, table, name):
             self.db.run('UPDATE rotbot_' + table + ' SET name=%(name)r WHERE LOWER(name)=LOWER(%(name)s) AND network_id=%(network_id)s', name=name, network_id=self.network.id)  # Correct capitalisation
     else:   # Record created.
         self.db.run('INSERT INTO rotbot_' + table + ' (name, network_id) VALUES (%(name)s, %(network_id)s)', name=name, network_id=self.network.id)  # Create record.
-        record = self.db.one('SELECT name FROM rotbot_' + table + ' WHERE LOWER(name)=LOWER(%(name)s) AND network_id=%(network_id)s', name=name, network_id=self.network.id)
+        record = self.db.one('SELECT * FROM rotbot_' + table + ' WHERE LOWER(name)=LOWER(%(name)s) AND network_id=%(network_id)s', name=name, network_id=self.network.id)
 
     return record

+ 0 - 3
rotbot/events/on_join.py

@@ -20,9 +20,6 @@ def process_event(self, connection, event):
     channel = queries.create_ifnot_onrecord(self, 'channel', event.target)
     user = queries.create_ifnot_onrecord(self, 'user', event.source.nick)
 
-    print(self.network.id)
-    print(channel.id)
-    print(user.id)
     # Save to join event database.
     if not self.db.one('SELECT id FROM rotbot_join WHERE network_id=%(network_id)s AND channel_id=%(channel_id)s AND "user_id"=%(user_id)s', network_id=self.network.id, channel_id=channel.id, user_id=user.id):   # No record yet
         self.db.run('INSERT INTO rotbot_join (network_id, channel_id, user_id, amount) VALUES (%(network_id)s, %(channel_id)s, %(user_id)s, 1)', network_id=self.network.id, channel_id=channel.id, user_id=user.id)   # Create record.