IRC-Bot

morphux IRC bot
Log | Files | Refs | README | LICENSE | git clone https://git.ne02ptzero.me/git/IRC-Bot

commit 5557855d5a3dfbb37bb382d0e97f005b065cf58b
parent 9c218c9ee4e8a26a082a8164295da2440109088d
Author: Ne02ptzero <l.solofrizzo@gmail.com>
Date:   Tue, 18 Nov 2014 16:47:13 +0100

User list Update, Admins

Diffstat:
Mmorphux.py | 41+++++++++++++++++++++++++++--------------
1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/morphux.py b/morphux.py @@ -57,11 +57,11 @@ class Morphux: elif (infos != False): if (infos["command"] in self.commands): self.commands[infos["command"]]["function"](self, infos) + print("New command:" + infos["command"]) else: self.sendMessage(self.config["errorMessage"], infos["nick"]) for name, function in self.after.items(): function(self, line) - pprint(self.currentUsers) # Send message # @param: string @@ -170,20 +170,24 @@ class Morphux: # Get Initial list of Users # @param: string def getHeadersLine(self, line): - users = line.split(":") + line = line.split("\n") + for value in line: + users = value.split(":") # :barjavel.freenode.net 353 Bot2fab4u = #morphux :Bot2fab4u abclive ryad Enerdhil[Phone] Valouche Noich @Ne02ptzero enerdhil @CL4P_TP Noich_root - - if (len(users) >= 2): - users = users[1] - details = line.split(":")[1].split(" ") - pprint(details) - if (len(details) >= 2): - if (details[1] == "353"): - users = users.split(" ") - pprint(users) - for nickName in users: - nickName = nickName.split("\r\n")[0] - self.currentUsers[nickName] = True + if (len(users) >= 2): + details = users[1].split(" ") + #print value + if (len(details) >= 2): + if (details[1] == "353"): + users = users[2].split(" ") + for nickName in users: + nickName = nickName.split("\r\n")[0] + nickName = nickName.split("\r")[0] + if (nickName[0] == '@'): + nickName = nickName[1:] + self.currentUsers[nickName] = {"isAdmin": 1} + else: + self.currentUsers[nickName] = True # On User Leave # @param: string @@ -213,6 +217,15 @@ class Morphux: else: return False + # If User is Admin + # @param: string + def isAdmin(self, nick): + if (userExists(nick)): + if ('isAdmin' in self.currentUsers[nick]): + if (self.currentUsers[nick] == 1): + return True + return False + # Show Help for a command # @param: list def showHelp(self, args):