Messages sent by the local user should appear blue, whilst from other users should be green.
Had left the check using a global though, so the deciding factor for blue was - is the upstream user called "ben2"?
@@ -70,7 +70,7 @@
color = "green"
upstruser = msgbody['user'] # Temporary placeholder
- if upstruser == USER:
+ if upstruser == self.user:
# One of our own, change the color
color = "blue"
@@ -81,6 +81,7 @@
CREATE TABLE users (
username TEXT NOT NULL,
room INTEGER NOT NULL,
+ active INTEGER DEFAULT 0,
PRIMARY KEY (username,room)
@@ -265,6 +266,10 @@
last = r
+ # Mark the user as active in the users table
+ self.cursor.execute("UPDATE users set active=1 where username=? and room=?", (reqjson['payload']['user'],room))
@@ -353,13 +358,28 @@
- ''' Placeholder for now. Auth will be handled later
- if "user" not in payload:
+ ''' Placeholder for now. Auth will be handled in more depth later
+ if "user" not in payload or "roomName" not in payload:
+ room = self.getRoomID(payload["roomName"])
+ if not room:
+ return 400
+ # Check whether the user has been marked as active
+ self.cursor.execute("SELECT username, room from users where username=? and room=? and active=1",(payload['user'],room))
+ r = self.cursor.fetchone()
+ if not r:
+ return False
''' Get a room's ID from its name