-
Notifications
You must be signed in to change notification settings - Fork 5
/
IRC_registration.py
80 lines (63 loc) · 2.45 KB
/
IRC_registration.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import random
import logging
class NameAlreadyExists(Exception):
def __init__(self, eventName):
self.name = eventName
def __str__(self):
return self.name
class trackVerification():
def __init__(self, userlist):
self.users = {}
for item in userlist:
self.users[item.lower()] = False
print self.users
self.userQueue = []
self.__verify_log__ = logging.getLogger("UserVerification")
self.__verify_log__.info("Verification Module initialized; Current users: %s", self.users.keys())
def doesExist(self, user):
return user.lower() in self.users
def isQueued(self, user):
return user.lower() in self.userQueue
def queueUser(self, user):
user = user.lower()
if user not in self.userQueue:
self.userQueue.append(user.lower())
self.__verify_log__.debug("Queueing user: %s", user)
return True
else:
self.__verify_log__.debug("Didn't queue user; Already queued: %s", user)
return False
def unqueueUser(self, user):
user = user.lower()
if user in self.userQueue:
self.userQueue.remove(user)
self.__verify_log__.debug("Removing user from queue: %s", user)
return True
else:
self.__verify_log__.debug("Didn't remove user from queue; Wasn't queued: %s", user)
return False
def isRegistered(self, user):
user = user.lower()
if user in self.users and self.users[user] == True:
return True
else:
return False
def unregisterUser(self, user):
user = user.lower()
self.users[user] = False
self.__verify_log__.debug("Unregistered user: %s", user)
def registerUser(self, user):
user = user.lower()
self.users[user] = True
self.__verify_log__.debug("Registered user: %s", user)
def addUser(self, user):
user = user.lower()
self.users[user] = False
self.__verify_log__.debug("Added new user: %s", user)
def remUser(self, user):
user = user.lower()
if user in self.users:
del self.users[user]
self.__verify_log__.debug("Removed user: %s", user)
else:
self.__verify_log__.warning("Tried to remove user %s, but no such user exists", user)