Stephen Tanner avatar Stephen Tanner committed 8e6840c

Added concept of IGNORE to bot. People in IGNORE list can not vote

Comments (0)

Files changed (4)

 
         self.ADMINS = admins
 
+        self.IGNORE = []
+
 
     def getAdmins(self):
         return self.ADMINS
             return 0
         elif nick in self.ADMINS:
             return 1
+        elif nick in self.IGNORE:
+            return 9
         else:
             return 2
+
+    def addIgnore(self, user):
+        return self.IGNORE.append(user)
+
+    def delIgnore(self, user):
+        return self.IGNORE.remove(user)
+
+    def getIgnore(self):
+        return self.IGNORE
             if message.message[0] == ':,add_admin' :
                 self.ACL.addAdmin(message.message[1])
                 #print("Admins: " + self.ACL.getAdmins())
-                self.SERVER.sendMessage('PRIVMSG ' + message.chan + " :" + message.nick + " " + message.message[1] + " added to admins")
+                self.SERVER.sendMessage('PRIVMSG ' + message.nick + " :" + message.nick + " " + message.message[1] + " added to admins")
             elif message.message[0] == ':,del_admin' :
                 self.ACL.delAdmin(message.message[1])
-                self.SERVER.sendMessage('PRIVMSG ' + message.chan + " :" + message.nick + " " + message.message[1] + " removed from admins")
+                self.SERVER.sendMessage('PRIVMSG ' + message.nick + " :" + message.nick + " " + message.message[1] + " removed from admins")
             elif message.message[0] == ':,die' :
                 print('Master commanded me to quit')
                 self.SERVER.unMute()
         if self.ACL.getPermLvl(message.nick) <= 1 :
             if message.message[0] == ':,mute':
                 #Not sure how to mute the parser class
-                self.SERVER.sendPRIVMessage(message.chan + ' :' + 'Cutting communications...')
+                self.SERVER.sendPRIVMessage(message.nick + ' :' + 'Cutting communications...')
                 self.SERVER.mute()
             elif message.message[0] == ':,unmute':
                 self.SERVER.unMute()
-                self.SERVER.sendPRIVMessage(message.chan + ' :' + 'Establishing link...')
+                self.SERVER.sendPRIVMessage(message.nick + ' :' + 'Establishing link...')
                 #self.SERVER.getUsers( message.chan )
+            elif message.message[0] == ':,ignore' and len(message.message) > 1:
+                self.__addIgnore(message.message[1])
+            elif message.message[0] == ':,unignore' and len(message.message) > 1:
+                self.__delIgnore(message.message[1])
             else:
                 pass
+
         '''You are neither'''
         if message.message[0] == ':,list_admin':
             #print("Sending list of admins")
-            self.SERVER.sendMessage('PRIVMSG ' + message.nick + " :" + " admins: " + str(self.ACL.getAdmins()))
+            self.SERVER.sendMessage('PRIVMSG ' + message.nick + " :admins: " + str(self.ACL.getAdmins()))
         elif message.message[0] == ':,help' and len(message.message) == 1:
-            self.mainHelp(message)
+            self.mainHelp(message.nick)
         elif message.message[0] == ':,help' and len(message.message) > 1 and message.message[1] == 'admin':
-            self.help(message)
+            self.help(message.nick)
+        elif message.message[0] == ':,list_ignore':
+            self.SERVER.sendPRIVMessage(message.nick + ' :ignored: ' + str(self.ACL.getIgnore()))
         else:
             pass
 
+    def __addIgnore(self, nick):
+        self.ACL.addIgnore(nick)
+        self.SERVER.sendPRIVMessage(nick + ' :' + 'You have been added to the ignore list. Probably because you are annoying...')
 
-    def mainHelp(self, message):
+    def __delIgnore(self, nick):
+        self.ACL.delIgnore(nick)
+        self.SERVER.sendPRIVMessage(nick + ' :' + 'You have been removed from the ignore list, for now...')
+
+    def mainHelp(self, nick):
         helpstr = ['Meow Meow I am Karma Kat! ',
                   '  Owner     = ' + str(self.ACL.OWNER),
                   '  Admins    = ' + str(self.ACL.ADMINS),
+                  '  Ignored   = ' + str(self.ACL.IGNORE),
                   '  Plugins   = admin, karma, url',
                   '  More help - ,help <plugin name> to get the help page for a plugin']
         for hlp in helpstr:
-            self.SERVER.sendPRIVMessage(message.nick + ' :' + hlp)
+            self.SERVER.sendPRIVMessage(nick + ' :' + hlp)
 
-    def help(self, message):
+    def help(self, nick):
 
         helpstr = ['Admin Help Commands: add_admin, del_admin, die, list_admin, mute, and unmute',
                '  add_admin  - Add and admin',
                '  unmute     - Down-votes a user or word', ]
 
         for hlp in helpstr:
-            self.SERVER.sendPRIVMessage(message.nick + ' :' + hlp)
+            self.SERVER.sendPRIVMessage(nick + ' :' + hlp)
 
     def __upVote(self, message):
         '''This method will handle the logic for trying to upvote'''
+        if self.ACL.getPermLvl(message.nick) == 9:
+            self.SERVER.sendPRIVMessage(message.nick + ' :' + 'Sorry but you are on the naughty list...')
+            return None
         self.curs.execute('SELECT * FROM vote WHERE uname = ?', [message.nick])
         if len(self.curs.fetchall()) == 1 :
             if self.__nickCheck(message) :
 
     def __downVote(self, message):
         '''This method will handle the logic for trying to downvote'''
+        if self.ACL.getPermLvl(message.nick) == 9:
+            self.SERVER.sendPRIVMessage(message.nick + ' :' + 'Sorry but you are on the naughty list...')
+            return None
         self.curs.execute('SELECT * FROM vote WHERE uname = ?', [message.nick])
         if len(self.curs.fetchall()) == 1 :
             if self.__nickCheck(message):
     def connectToServer(self):
         '''Now we need to connect to the server'''
         #Make the connection to the server on the specified port
-        print("Connecting to the server " + self.HOST + ":" + self.PORT.__str__())
+        #print("Connecting to the server " + self.HOST + ":" + self.PORT.__str__())
         self.aSocket.connect((self.HOST, self.PORT))
         #Send the Bot nick to the server
-        print('Using ' + self.NICK + ' Nickname')
+        #print('Using ' + self.NICK + ' Nickname')
         self.aSocket.send(bytes('NICK ' + self.NICK + '\r\n', 'UTF-8'))
         #Identify yourself to the server
-        print("Connecting with Identity: " + self.IDENT + " and RealName: " + self.REALNAME)
+        #print("Connecting with Identity: " + self.IDENT + " and RealName: " + self.REALNAME)
         self.aSocket.send(bytes('USER ' + self.IDENT + ' ' + self.HOST + ' bla :' + self.REALNAME + '\r\n', 'UTF-8'))
 
         self.__chanAutoJoin()
         '''
         Use this to join to a channel
         '''
-        print("Joining channel: " + self.CHANNELINIT)
+        #print("Joining channel: " + chan)
         self.sendMessage('JOIN ' + chan)
 
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.