Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def handlePubmsg (connection, event):
- opcmd = {'op':server.op,'deop':server.deop,'kick':server.kick,'ban':server.ban,'unban':server.unban} #dictionary with couples key:value where key=command and value = bound method of the object server
- if event.arguments()[0][0] == "!": #if first char in the command is !
- command = event.arguments()[0] #set some usefull vars
- ident = irclib.nm_to_u(event.source()).lower()
- chantarget = event.target()
- nicktarget = command.split(" ")[1].lower()
- key = command.split(" ")[0][1:].lower()
- if len(command.split(" ")) == 2: #check if the command has the right sintax: !cmd target (where target is a valid target for the given command)
- if opcmd.has_key(key): #chek if the given command is present in my dictionary as a key
- ops = open("ops.txt", "r") #if so, open a file to check if the user is actually an operator, this will be improved another day
- while True:
- line = ops.readline().split('\n')[0].lower()
- if line == ident:
- opcmd[key](chantarget, nicktarget) #if the user is actually an operator i call the bound method passing the two needed arguments
- break
- elif line == "":
- server.privmsg(chan, "%s: you don't have enough power." % (event.source().split('!')[0]))
- break
- ops.close()
- else:
- server.privmsg(chan, "%s: %s command not recognized" % (event.source().split('!')[0], command.split(" ")[0][1:]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement