Typo.
authorCMDR furrycat <elite@furrycat.net>
Mon, 3 Oct 2016 18:01:03 +0000 (19:01 +0100)
committerCMDR furrycat <elite@furrycat.net>
Mon, 3 Oct 2016 18:01:03 +0000 (19:01 +0100)
bot.py
db.py

diff --git a/bot.py b/bot.py
index 5ed24b0..d43c0af 100755 (executable)
--- a/bot.py
+++ b/bot.py
@@ -467,7 +467,7 @@ def set_unassigned(member):
 
 @asyncio.coroutine
 def greet(channel, member, sound = True):
-  for greeting in get_bot_variable(greetings, []):
+  for greeting in get_bot_variable('greetings', []):
     if greeting['channel'] != int(channel.id):
       continue
     message = ' '.join([member.mention, greeting['message']])
diff --git a/db.py b/db.py
index 64515e2..b07c62f 100644 (file)
--- a/db.py
+++ b/db.py
@@ -1,6 +1,7 @@
 import discord
 import logging
 import sqlite3
+import uuid
 
 log = logging.getLogger('db')
 
@@ -11,12 +12,15 @@ class DBConnection(object):
     self.open_db(filename)
     self.create_tables()
 
+  def uuid():
+    return str(uuid.uuid4())
+
   def open_db(self, filename):
     self.dbh = sqlite3.connect(filename)
     self.dbh.row_factory = sqlite3.Row
 
   def create_tables(self):
-    cursor = self.query('create table if not exists state (bot_id varchar(32) not null, avatar varchar(128), idle boolean not null default false, last_spoke datetime)')
+    cursor = self.query('create table if not exists state (id char(36) not null, bot_id varchar(32) not null, avatar varchar(128), idle boolean not null default false, last_spoke datetime)')
     self.dbh.commit()
 
   def close(self):
@@ -46,6 +50,6 @@ class DBConnection(object):
     sql = 'update state set {} where bot_id=?'.format(', '.join(['{}=?'.format(v) for v in values]))
     cursor = self.query(sql, params)
     if not cursor.rowcount:
-      cursor = self.query('insert into state (bot_id) values (?)', [client.user.id])
+      cursor = self.query('insert into state (id, bot_id) values (?, ?)', [self.uuid(), client.user.id])
       cursor = self.query(sql, params)
     self.dbh.commit()