Updates to variable names and whatnot.

This commit is contained in:
Jeremy Fincher 2003-04-24 17:36:25 +00:00
parent 4f094a2e83
commit 8d0d138850

View File

@ -54,7 +54,6 @@ import ircutils
dbfilename = os.path.join(conf.dataDir, 'Notes.db') dbfilename = os.path.join(conf.dataDir, 'Notes.db')
class Notes(callbacks.Privmsg): class Notes(callbacks.Privmsg):
def __init__(self): def __init__(self):
callbacks.Privmsg.__init__(self) callbacks.Privmsg.__init__(self)
self.makeDB(dbfilename) self.makeDB(dbfilename)
@ -88,7 +87,7 @@ class Notes(callbacks.Privmsg):
self.cursor.execute('INSERT INTO users VALUES (NULL, %s)', username) self.cursor.execute('INSERT INTO users VALUES (NULL, %s)', username)
self.db.commit() self.db.commit()
def getUserID(self, username): def getUserId(self, username):
"Returns the user id matching the given username from the users table." "Returns the user id matching the given username from the users table."
self.cursor.execute('SELECT id FROM users where name=%s', username) self.cursor.execute('SELECT id FROM users where name=%s', username)
if self.cursor.rowcount != 0: if self.cursor.rowcount != 0:
@ -157,15 +156,15 @@ class Notes(callbacks.Privmsg):
recipient = ircdb.users.getUserName(n) recipient = ircdb.users.getUserName(n)
self._addUser(sender) self._addUser(sender)
self._addUser(recipient) self._addUser(recipient)
senderID = self.getUserID(sender) senderId = self.getUserId(sender)
recipID = self.getUserID(recipient) recipId = self.getUserId(recipient)
if ircutils.isChannel(msg.args[0]): if ircutils.isChannel(msg.args[0]):
public = 1 public = 1
else: else:
public = 0 public = 0
self.cursor.execute("""INSERT INTO notes VALUES self.cursor.execute("""INSERT INTO notes VALUES
(NULL, %s, %s, %s, 0, 0, %s, %s)""", (NULL, %s, %s, %s, 0, 0, %s, %s)""",
senderID, recipID, int(time.time()), senderId, recipId, int(time.time()),
public, note) public, note)
self.db.commit() self.db.commit()
irc.reply(msg, conf.replySuccess) irc.reply(msg, conf.replySuccess)
@ -178,10 +177,11 @@ class Notes(callbacks.Privmsg):
noteid = privmsgs.getArgs(args) noteid = privmsgs.getArgs(args)
try: try:
sender = ircdb.users.getUserName(msg.prefix) sender = ircdb.users.getUserName(msg.prefix)
senderId = self.getUserId(sender)
except KeyError: except KeyError:
irc.error(msg, conf.replyNoUser) irc.error(msg, conf.replyNoUser)
return return
self.cursor.execute("""SELECT notes.note, notes.from_id, self.cursor.execute("""SELECT notes.note, notes.to_id, notes.from_id,
notes.added_at, notes.public notes.added_at, notes.public
FROM users, notes FROM users, notes
WHERE users.name=%s AND WHERE users.name=%s AND
@ -193,7 +193,7 @@ class Notes(callbacks.Privmsg):
return return
note, to_id, from_id, added_at, public = self.cursor.fetchone() note, to_id, from_id, added_at, public = self.cursor.fetchone()
author = self.getUserName(from_id) author = self.getUserName(from_id)
if senderID != to_id: if senderId != to_id:
irc.error(msg, 'You are not the recipient of note %s.' % noteid) irc.error(msg, 'You are not the recipient of note %s.' % noteid)
return return
public = int(public) public = int(public)