def warnListen(obj): if obj.nick in warns.keys(): if warns[obj.nick][1] != None: if time.time()-warns[obj.nick][1] >= 0: del warns[obj.nick] else: client.sendRaw('KICK %s %s :%s' % (obj.chan, obj.nick, 'You\'re warning has not expired! You have %s more seconds to go!' % abs(time.time()-warns[obj.nick][1])))
def cmdBan(obj): msg = obj.msg.split(' ', 1) if len(msg) == 2: if msg[1].startswith('*'): banmask = msg[1][1:] else: banmask = msg[1] client.sendRaw('MODE %s +b %s' % (obj.chan, banmask)) else: client.send(obj.chan, 'Usage: '+ cmdBan.usage)
def cmdKick(obj): msg = obj.msg.split(' ', 2) if len(msg) == 2 and obj.chan != client.nick: client.sendRaw('KICK %s %s' % (obj.chan, msg[1])) client.send(msg.chan, 'Kicked %s from %s.' % (msg[1], obj.chan)) elif len(msg) == 3 and obj.chan != client.nick: client.sendRaw('KICK %s %s :%s' % (obj.chan, msg[1], msg[2])) client.send(msg.chan, 'Kicked %s from %s for %s.' % (msg[1], obj.chan, msg[2])) else: client.send(msg.chan, 'Usage: '+ cmdKick.usage)
def cmdTopicTools(obj): global chan_topics #!tt topic lalalala #!tt +suffix prefix append #!tt -suffix suffix append #!tt lock def sep(inp): if inp == '' or inp == ' ': return '' else: return ' | ' msg = obj.msg.split(' ', 2) if obj.chan not in chan_topics: chan_topics[obj.chan] = { 'prefix':'', 'suffix':'', 'topic':'', 'format':'', 'locked':False} topic = chan_topics[obj.chan] if len(msg) == 3: if msg[1].startswith('-') or msg[1].startswith('+'): df = msg[1][:1] cd = msg[1][1:] else: df = '' cd = msg[1] if msg[2] == '*': msg[2] = '' if cd == 'prefix': if df == '': topic['prefix'] = msg[2] elif df == '-': topic['prefix'] = topic['prefix']+msg[2] elif df == '+': topic['prefix'] = msg[2]+topic['prefix'] elif cd == 'suffix': if df == '': topic['suffix'] = msg[2] elif df == '-': topic['suffix'] = topic['suffix']+msg[2] elif df == '+': topic['suffix'] = msg[2]+topic['suffix'] elif cd == 'topic': if df == '': topic['topic'] = msg[2] elif df == '-': topic['topic'] = topic['topic']+msg[2] elif df == '+': topic['topic'] = msg[2]+topic['topic'] # elif cd == 'format': # if msg[2].count('%s') == 3: # topic['foramt'] = msg[2] # else: # client.send(obj.chan, 'Format must have 3 %s\'s in it') else: return None #Unkown command top = '%s%s%s%s%s' % (topic['prefix'], sep(topic['topic']), topic['topic'], sep(topic['suffix']),topic['suffix']) client.sendRaw('TOPIC %s :%s' % (obj.chan, top)) elif len(msg) == 2: if msg[1] == 'help': client.send(obj.chan, 'Help, Lock (Toggle lock). Topic, Suffix, Prefix with modifiers +[Append] -[Suffixify]. Example: !tt +suffix Add To Front Of Suffix') elif msg[1] == 'lock': topic['locked'] = not topic['locked'] client.send(obj.chan, 'Topic is now %s' % trans[topic['locked']])
def cmdWarn(obj): msg = obj.msg.split(' ', 2) if len(msg) >= 2: if len(msg) == 2: reason = 'Your behavior is not respective to the desired environment.' elif len(msg) == 3: reason = msg[2] if msg[1] in warns and client.channels[obj.chan].hasUser(msg[1]): warns[msg[1]][0] += 1 if warns[msg[1]][0] >= maxwarn: client.send(msg[1], 'You\'ve been kicked for having too many warnings! Please rejoin after %s seconds!' % (warntime)) client.sendRaw('KICK %s %s :%s' % (obj.chan, msg[1], 'Too many warnings!')) warns[msg[1]][1] = time.time()+warntime else: client.send(obj.chan, '%s: Warning %s of %s: %s' % (msg[1], warns[msg[1]][0], maxwarn, reason)) elif client.channels[obj.chan].hasUser(msg[1]): warns[msg[1]] = [1, None] client.send(obj.chan, '%s: Warning %s of %s: %s' % (msg[1], warns[msg[1]][0], maxwarn, reason)) else: client.send(obj.chan, 'Usage: '+cmdWarn.usage)
def topicListen(obj): if obj.chan in chan_topics: if chan_topics[obj.chan]['locked'] is True: topic = chan_topics[obj.chan] top = '%s%s%s' % (topic['prefix'], topic['topic'], topic['suffix']) client.sendRaw('TOPIC %s :%s' % (obj.chan, top))
def cmdTopic(obj): msg = obj.msg.split(' ', 1) if len(msg) == 2: client.sendRaw('TOPIC %s :%s' % (obj.chan, msg[1])) else: client.send(obj.chan, 'Usage: '+ cmdTopic.usage)
def devoiceCmd(msg): msz = msg.msg.split(' ') if len(msz) == 2: client.sendRaw('MODE %s -v %s' % (msg.chan, msz[1])) else: client.send(msg.chan, 'Usage: '+ devoiceCmd.usage)