def message_cb(word, word_eol, userdata): global first_turn global guess global used_letters global patt if word[0] == '[-KriStaL-]': if 'Puzzle' in word[1]: if first_turn: first_turn = False used_letters = '' patt = word[1][10:] r = requests.post('http://nmichaels.org/hangsolve.py', data = { 'pattern' : patt, 'guessed' : '', 'game' : 'hangman', 'action' : 'display' }) guess = str(BeautifulSoup(r.content).find('span', {'class':'guess'}).text[0]) XC.hook_timer(random.randint(2000, 5000), guess_letter) used_letters += guess else: patt = word[1][10:] request_letter() elif 'Sorry, there is no' in word[1]: request_letter() elif 'Congratulations' in word[1]: game.prnt('-= we won! =-') endgame() elif 'No one guessed' in word[1]: game.prnt('-= we lose! =-') endgame()
def since_cb(word, word_eol, userdata): global lastStreamTime global filename global cooldown global monitoring if cooldown: return xchat.EAT_NONE command = word[1].split(' ')[0].lower() if command == "!since": #Command not particularly useful if stream is live if monitoring["monotonetim"][0] is Status.online: xchat.command("say MonotoneTim is live right now!") timer = xchat.hook_timer(60000, cooldown_cb) cooldown = True return xchat.EAT_NONE if lastStreamTime == -1: file = open(filename, "r") lastStreamTime = float(file.read()) file.close() delta = TimeDelta(time.time() - lastStreamTime) xchat.command("say " + delta.readableTime()) timer = xchat.hook_timer(60000, cooldown_cb) cooldown = True return xchat.EAT_NONE
def done(self): """Finaliazation and cleanup""" # Done! if debug: xchat.emit_print('Server Text', "Done " + str(self)) pending.remove(self) # Deop? if not self.am_op or not self.needs_op: return for p in pending: if p.channel == self.channel and p.needs_op or not p.deop: self.deop = False break if self.deop: self.context.command("chanserv deop %s" % self.channel) # Schedule removal? if self.timer and (self.channel not in can_do_akick or self.banmode == 'q'): action = Action(self.channel, self.me, self.context) action.deop = self.deop action.actions = [x.replace('+','-',1) for x in self.actions] action.target = self.target action.target_nick = self.target_nick action.target_ident = self.target_ident action.target_host = self.target_host action.target_name = self.target_name action.target_name_bannable = self.target_name_bannable action.target_account = self.target_account action.resolved = True action.banmode = self.banmode action.needs_op = True xchat.hook_timer(self.timer * 1000, lambda act: act.schedule(update_stamp=True) and False, action)
def initialize(): print "initialize" global original_nick, timer_begins, timer_ends global uppercase_hook, action_hook, nick_hook, heretic_hook global ACF_BEGIN_TIME, ACF_END_TIME, has_joined has_joined = True hooks = [timer_begins, timer_ends, uppercase_hook, action_hook, nick_hook, heretic_hook] for h in hooks: if h is not None: xchat.unhook(h) h = None timer_begins = xchat.hook_timer(time_to(ACF_BEGIN_TIME), ACF_begin) timer_ends = xchat.hook_timer(time_to(ACF_END_TIME), ACF_end) uppercase_hook = xchat.hook_command("", to_uppercase) action_hook = xchat.hook_command("me", to_uppercase_action) nick_hook = xchat.hook_command("nick", change_nick) heretic_hook = xchat.hook_server("PRIVMSG", heretic_patrol) xchat.hook_command("leave", leave_dc801) original_nick = xchat.get_info("nick") if all_caps_friday() and original_nick.islower(): new_nick = original_nick.upper() cmd = "nick %s" % new_nick xchat.command(cmd) return xchat.EAT_ALL return xchat.EAT_NONE
def weapon_activate(ctx): context = ctx['context'] if ctx["wasop"]: weapon_continue(ctx) else: xchat.command("msg ChanServ OP %s %s" % (context.get_info('channel'), context.get_info('nick'))) xchat.hook_timer(500, weapon_timer, userdata=ctx)
def run(): """This is the logic on what packs actually get added to the queue. It's run just about any time there is an interaction with the queue (get, delete, dcc events, etc).""" global CommandQueue, Active, Watchdog if not MULTIQUEUE: # If there's an active transfer, we return if Active: return if not CommandQueue: return # If not, we start one and start a watchdog timer cmd = CommandQueue.get() Active.append(cmd) cmd.execute() if not Watchdog: Watchdog = xchat.hook_timer(45000, transferCheck) return # We are in MULTIQUEUE mode ... aps = sorted(Active.getBotSet()) cps = sorted(CommandQueue.getBotSet()) missing = [bot for bot in cps if bot not in aps] print_debug('multiq: a: %s, q: %s, missing: %s' % (aps, cps, missing)) # if we have the same bots in each, we are already transfering at full.. if not missing: return for bot in missing: cmd = CommandQueue.getBotPackSet(bot) if not cmd: return cmd = cmd[0] Active.append(cmd) CommandQueue.remove(cmd) print_debug("/%s on %s@%s" % (cmd.s, cmd.channel, cmd.network)) cmd.execute() # set up a watchdog every 45 seconds if Active and not Watchdog: Watchdog = xchat.hook_timer(45000, transferCheck)
def sellout_cb(word, word_eol, userdata): global valid global link global enabled #chan = xchat.find_context(channel="#not_tim") #if chan is None: # return xchat.EAT_NONE words = word[1].split(' ') # Will always have at least one element of words if not words[0] == "!sellout": return xchat.EAT_NONE if len(words) > 1: if len(word) >= 3 and word[2] == "@": if words[1] == "on": if not enabled: xchat.command("say Selling out turned on") enabled = True elif words[1] == "off": if enabled: xchat.command("say Selling out turned off") enabled = False elif "amazon.com" in words[1]: the_link = ' '.join(words[1:]) xchat.command("say Associates link changed to: " + the_link) file = open(link, "w") file.write(the_link) file.close() elif valid and enabled: file = open(link, "r") the_link = file.readline() file.close() xchat.command("say Amazon Associates Link: " + the_link) valid = False timer = xchat.hook_timer(60000, timer_cb) else: if valid and enabled: file = open(link, "r") the_link = file.readline() file.close() xchat.command("say Amazon Associates Link: " + the_link) valid = False timer = xchat.hook_timer(60000, timer_cb) else: if valid and enabled: file = open(link, "r") the_link = file.readline() file.close() xchat.command("say Amazon Associates Link: " + the_link) valid = False timer = xchat.hook_timer(60000, timer_cb) return xchat.EAT_NONE
def init_cb(arg): global game game = XC.find_context(channel='#gridcoin-games') if game is not None: game.prnt('-= scrambler bot loaded =-') else: XC.hook_timer(4000, init_cb)
def init_cb(arg): global game game = XC.find_context(channel='#gridcoin-games') if game is not None: game.prnt('-= hangman bot loaded =-') else: XC.hook_timer(4000, init_cb)
def weapon_timer(ctx): ctx['times'] = ctx['times'] + 1 if isop(): weapon_continue(ctx) else: if ctx['times'] > 10: print "Failed to OP within 5 seconds, giving up" else: xchat.hook_timer(500, weapon_timer, userdata=ctx)
def say_next_line(ud): global hsay if len(hsay) > 0: xchat.command("CTCP {0} TROLLCHAT say {1}".format(hsay[0][0],hsay[0][1])) # did we send this to ourself? if hsay[0][0] == xchat.get_info('nick'): del hsay[0] xchat.hook_timer(100, say_next_line) return False
def say_cb(word, word_eol, userdata): global list_ #If the list exists, we append the current message to it, if not we create a new list and set a timer. if list_: list_.append(word_eol[0]) else: #Create the list and set a timer when the list should be dealt with list_ = [] list_.append(word_eol[0]) xchat.hook_timer(settings['timeout'], messagebuffer, ) return xchat.EAT_ALL
def say_next_line(ud): global hsay if len(hsay) > 0: xchat.command("CTCP {0} TROLLCHAT say {1}".format( hsay[0][0], hsay[0][1])) # did we send this to ourself? if hsay[0][0] == xchat.get_info('nick'): del hsay[0] xchat.hook_timer(100, say_next_line) return False
def message_cb(word, word_eol, userdata): global hunt_wait global fish_wait if word[0] == '[-KriStaL-]': if 'hunt again' in word[1]: hunt_wait = [int(s) for s in word[1].split() if s.isdigit()][0] hunt_wait += random.randint(0, 60000) XC.hook_timer(hunt_wait, hunt_cb) elif 'fish again' in word[1]: fish_wait = [int(s) for s in word[1].split() if s.isdigit()][0] fish_wait += random.randint(0, 60000) XC.hook_timer(fish_wait, fish_cb)
def request_letter(): global used_letters global guess global patt args = {'pattern' + str(i) : patt[i].lower() if patt[i] != '_' else '' for i in range(0,len(patt))} args['guessed'] = used_letters args['game'] = 'hangman' args['action'] = 'display' r = requests.post('http://nmichaels.org/hangsolve.py', data = args) guess = str(BeautifulSoup(r.content).find('span', {'class':'guess'}).text[0]) XC.hook_timer(random.randint(2000, 5000), guess_letter) used_letters += guess
def on_join(word, word_eol, userdata): global troll_master, peons, trolls, hook, hsay user, channel, host = word if channel != '#newvce': return None # temporary if troll_master is None: update_troll_master() if troll_master != xchat.get_info('nick'): return None update_peons() # is our joining user a peon? if user in peons or hook != None: return None # troll the shit out of them # how many trolls do we have? gtrolls = filter(lambda x: len(x) <= len(peons) + 1, trolls) if len(gtrolls) == 0: return None # troll them troll = random.choice(gtrolls) # now make the troll 'good' troll = map(lambda x: x.replace('{$USER}', user), troll) # our trollers trollers = [troll_master] + peons[:] random.shuffle(trollers) hsay = [] i = 0 for line in troll: hsay.append([trollers[i], line]) i += 1 # hook dat shit xchat.hook_timer(100, say_next_line) return None
def on_join(word, word_eol, userdata): global troll_master, peons, trolls, hook, hsay user, channel, host = word if channel != '#newvce': return None # temporary if troll_master is None: update_troll_master() if troll_master != xchat.get_info('nick'): return None update_peons() # is our joining user a peon? if user in peons or hook != None: return None # troll the shit out of them # how many trolls do we have? gtrolls = filter(lambda x: len(x) <= len(peons) + 1, trolls) if len(gtrolls) == 0: return None # troll them troll = random.choice(gtrolls) # now make the troll 'good' troll = map(lambda x: x.replace('{$USER}', user), troll) # our trollers trollers = [troll_master] + peons[:] random.shuffle(trollers) hsay = [] i = 0 for line in troll: hsay.append([trollers[i],line]) i += 1 # hook dat shit xchat.hook_timer(100, say_next_line) return None
def launch_dl(userdata): global queue, my_hook if None == xchat.get_info("server"): xchat.unhook(my_hook) my_hook = xchat.hook_timer(10000, server_check) else: for bot in getattr(queue, 'bots'): if len(bot) == 0: queue.del_bot(bot) if not bot.isActive(): delqueue() save() bot_context = xchat.find_context(getattr(bot, 'serv'), getattr(bot, 'chan')) if bot_context is None: if xchat.find_context(getattr(bot, 'serv')) is not None: xchat.command("join " + getattr(bot, 'chan')) else: xchat.command("servchan " + getattr(bot, 'serv') + " 6667 " + getattr(bot, 'chan')) bot_context = xchat.find_context(getattr(bot, 'serv'), getattr(bot, 'chan')) try: bot_context.command('msg ' + getattr(bot, 'name') + ' xdcc send #' + str(bot.pop())) except AttributeError: pass return 1
def cap_cb(word, word_eol, userdata): subcmd = word[3] caps = word[4:] caps[0] = caps[0][1:] if subcmd == 'LS': toSet = [] # Parse the list of capabilities received from the server if 'multi-prefix' in caps: toSet.append('multi-prefix') # Ask for the SASL capability only if there is a configuration for this network if 'sasl' in caps and conf.has_section(xchat.get_info('network')): toSet.append('sasl') if toSet: # Actually set capabilities xchat.command('CAP REQ :%s' % ' '.join(toSet)) else: # Sorry, nothing useful found, or we don't support these xchat.command('CAP END') elif subcmd == 'ACK': if 'sasl' in caps: xchat.command('AUTHENTICATE PLAIN') print("SASL authenticating") saslTimers[xchat.get_info('network')] = xchat.hook_timer(15000, sasl_timeout_cb) # Timeout after 15 seconds # In this case CAP END is delayed until authentication ends else: xchat.command('CAP END') elif subcmd == 'NAK': xchat.command('CAP END') elif subcmd == 'LIST': if not caps: caps = 'none' print('CAP(s) currently enabled: %s') % ', '.join(caps) return xchat.EAT_XCHAT
def BanTimerGo(newInfo=None,newTime=None,onYouJoin=False): global banTimer,nextBanInfo,nextBanTime if onYouJoin: newInfo = None newTime = None #endif curTime = time() if not newTime: for servChan in banTimes: serv,chan = tuple(servChan.split("/",1)) if xchat.find_context(serv,chan): remove = [] for mask in banTimes[servChan]: thTime = banTimes[servChan][mask] if thTime <= curTime: remove.append((servChan,mask,thTime)) elif not nextBanTime or thTime < nextBanTime: newInfo = (servChan,mask) newTime = thTime #endif #endfor for x in remove: BanTimerTick(x) #endif #endfor #endif if newInfo and newTime and (not nextBanTime or newTime < nextBanTime): nextBanInfo = newInfo nextBanTime = newTime if banTimer: xchat.unhook(banTimer) banTimer = xchat.hook_timer((newTime-int(time()))*1000, BanTimerTick)
def add_activity(self, server, channel): key = server + ":" + channel if key not in self.activity: self.activity[key] = 0 self.activity[key] = self.activity[key] + 1 if not self.timerhook: self.timerhook = xchat.hook_timer(250, self.enumerate_cb)
def runcommand_cb(word, word_eol, userdata): global conn global ran_commands global global_commands words = word[1].split(' ') command = words[0].lower() if command in ran_commands or command in global_commands: return xchat.EAT_NONE safe_command = (command,) c = conn.cursor() c.execute('SELECT * FROM commands WHERE command=?', safe_command) result = c.fetchone() if result is None: return xchat.EAT_NONE ran_commands += [command] #Normal text if result[1] == 0: xchat.command('say ' + result[2]) timer = xchat.hook_timer(result[3], timer_cb, command) return xchat.EAT_ALL #Special command elif result[1] == 1: return xchat.EAT_NONE return xchat.EAT_NONE
def endgame(): global counter global h_timer global timeless if counter > 0 or timeless: h_timer = XC.hook_timer(random.randint(10000, 20000), fire)
def toggle_cb(self, word, word_eol, userdata): if len(word) < 2 or word[1].lower() not in ['on', 'off', 'status']: self.notice("Please provide a command: 'on', 'off', or 'status'") return xchat.EAT_ALL command = word[1].lower() if command == "on": if self.hooks: self.notice("Hush is already on") return xchat.EAT_ALL for event in ["Join", "Part", "Part with Reason", "Quit", "Change Nick"]: self.hooks.append(xchat.hook_print(event, self.selective_hush_cb)) for event in ["Private Message", "Private Action", "Channel Message", "Channel Action"]: self.hooks.append(xchat.hook_print(event, self.record_cb)) self.hooks.append(xchat.hook_timer(5 * 60 * 1000, self.reaper_cb)) self.notice("Loaded Hush") return xchat.EAT_ALL elif command == "off": if self.hooks: map(xchat.unhook, self.hooks) self.hooks = [] self.active_users = [] self.notice("Unloaded Hush") else: self.notice("Hush is already off") return xchat.EAT_ALL elif command == "status": status = {True: "on", False: "off"} self.notice("Hush is %s" % status[bool(self.hooks)]) return xchat.EAT_ALL
def BanTimerGo(newInfo=None, newTime=None, onYouJoin=False): global banTimer, nextBanInfo, nextBanTime if onYouJoin: newInfo = None newTime = None #endif curTime = time() if not newTime: for servChan in banTimes: serv, chan = tuple(servChan.split("/", 1)) if xchat.find_context(serv, chan): remove = [] for mask in banTimes[servChan]: thTime = banTimes[servChan][mask] if thTime <= curTime: remove.append((servChan, mask, thTime)) elif not nextBanTime or thTime < nextBanTime: newInfo = (servChan, mask) newTime = thTime #endif #endfor for x in remove: BanTimerTick(x) #endif #endfor #endif if newInfo and newTime and (not nextBanTime or newTime < nextBanTime): nextBanInfo = newInfo nextBanTime = newTime if banTimer: xchat.unhook(banTimer) banTimer = xchat.hook_timer((newTime - int(time())) * 1000, BanTimerTick)
def start(): global my_hook if my_hook is None: my_hook = xchat.hook_timer(10000, launch_dl) print "EasyXdcc started" launch_dl(None) return xchat.EAT_ALL
def cap_cb(word, word_eol, userdata): subcmd = word[3] caps = word[4:] caps[0] = caps[0][1:] if subcmd == 'LS': toSet = [] # Parse the list of capabilities received from the server if 'multi-prefix' in caps: toSet.append('multi-prefix') # Ask for the SASL capability only if there is a configuration for this network if 'sasl' in caps and conf.has_section(xchat.get_info('network')): toSet.append('sasl') if toSet: # Actually set capabilities xchat.command('CAP REQ :%s' % ' '.join(toSet)) else: # Sorry, nothing useful found, or we don't support these xchat.command('CAP END') elif subcmd == 'ACK': if 'sasl' in caps: xchat.command('AUTHENTICATE PLAIN') print("SASL authenticating") saslTimers[xchat.get_info('network')] = xchat.hook_timer( 5000, sasl_timeout_cb) # Timeout after 5 seconds # In this case CAP END is delayed until authentication ends else: xchat.command('CAP END') elif subcmd == 'NAK': xchat.command('CAP END') elif subcmd == 'LIST': if not caps: caps = 'none' print('CAP(s) currently enabled: %s') % ', '.join(caps) return xchat.EAT_XCHAT
def start(self, userdata): chan = userdata[0].get_info('channel') if not chan in self.scrobblers: self.scrobblers[chan] = xchat.hook_timer(30 * 1000, self.scrobble, userdata) print "scrobbling started on " + chan else: print "already scrobbling on " + chan
def steiner(text, text_eol, userdata): ignore = ['swim', 'seventyNexus', 'SeventyTwo', 'Noxialis', 'ChanServ', 'cocaine', 'Ultimation_', 'roofletrain', 'Serpentine', 'hachimitsu-boy', 'whatapath', 'YourImaginaryFriend', 'RocketLauncher', 'Onee-chan', 'Fijou', 'DarkAceLaptop', 'GayServ', 'zingas', 'rpk', 'qb', 'mkillebrew', 'whoapath', 'guymann', 'Doomfag', 'maws', 'cunnelatio', 'DenSaakalte', 'martian', 'irc', 'cyberdynesystems', 'net', 'somberlain', 'PhilKenSebben', 'kyokugen', 'Erotica', 'mechanicalTurk', 'ed', 'anon__', 'E-Pain', 'thenoize', 'skew', 'StoneColdSteveAustin', 'frussif', 'Ultimation', 'charles', 'i7MUSHROOM', 'slamm', 'h**o', 'Hypnotized', 'Dr_Venture', 'AoC', 'Porygon', 'axujen', 'Jax', 'Special-G', 'peopleschampion', 'LtSerge', 'Dwarf', 'pinetreegator', 'Cap', '[^_^]', 'swam', 'Clear', 'takoyaki', 'keret', 'MeanPocket', 'keref', 'hachi', 'vortmax', 'War', 'Hachi-chan', 'JediDachshund', 'BillGates', 'BTDT', 'kk', 'guy9000', 'Erzengel', 'Revived', 'BradPitt', 'Colink', 'ekOz', 'Jynweythek'] steiner = "" nick = xchat.strip(text[0]).translate(str.maketrans("", "", "+%@&~")) if nick in ignore or "ScottSteiner" not in xchat.get_info("nick"): return if text[1] == "nothing gayer": steiner = "than {}".format(nick) elif re.search("nothin(?:g(?:'s|)|)gayer", text[1]): steiner = "{} is a f****t".format(nick) elif re.search("nothin(?:g(?:'s|)|) finer than", text[1]) or text[1] == "no one kinder than": steiner = "Scott Steiner" elif re.search("nothin(?:g(?:'s|)|) finer", text[1]) or text[1] == "no one kinder": steiner = "than Scott Steiner" elif text[1] == "nothing is finer": steiner = "than {} being a dumbfuck inbred retard who still can't into a simple script".format(nick) elif text[1] == "big poppa pump": steiner = "IS YOUR HOOKUP. HOLLER IF YA HEAR ME" if steiner: print("{0}<{1}{0}> {2}".format("\x0307", text[0],text[1])) xchat.get_context().command("say {}".format(steiner)) global steinerhook, steinertimer xchat.unhook(steinerhook) steinertimer = xchat.hook_timer(60000, steinertoggle) steinerhook = None return xchat.EAT_XCHAT
def ReadySend(word,word_eol,userdata): global dTimers if GetOpt(0) != "none" and GetOpt(2): #xchat.prnt("%s joined channel..prepping for message." % word[0]) dTimers[word[0]] = xchat.hook_timer(GetOpt(1), SendMessage, [word[0],xchat.get_context()]) #endif return xchat.EAT_NONE
def hookShowMenus(*args): if hasattr(hookShowMenus, 'handler'): xchat.unhook(hookShowMenus.handler) next, meal_type = min((secondsToTime(hour, minute), meal_type) for hour, minute, meal_type in ((8, 0, 'Breakfast'), (11, 45, 'Lunch'), (17, 0, 'Happy Hour'), (17, 45, 'Dinner'))) hookShowMenus.handler = xchat.hook_timer( next * 1000, onTimer, args[:2] + (meal_type,))
def server_check(userdata = None): global my_hook, no_server if 0 == no_server: print "EasyXdcc : waiting for connection" no_server = 1 if None != xchat.get_info("server"): xchat.unhook(my_hook) my_hook = xchat.hook_timer(10000,launch_dl) no_server = 0 return 1
def on_part(word, word_eol, userdata): global jointimer if jointimer: xchat.unhook(jointimer) jointimer = None triggerchannel = word[2].lower() thecontext = xchat.find_context(channel=triggerchannel) if triggerchannel in option["opin"]: if triggerchannel in option["limitchannels"] and option["limitjoins"] == True: jointimer = xchat.hook_timer(option["limittime"], part_limit, userdata=thecontext)
def message_cb(word, word_eol, userdata): global game global res global playing global cur_letter global answer if word[0] == '[-KriStaL-]': if 'Unscramble' in word[1]: playing = True cur_letter = -1 r = requests.get( 'http://www.vocabula.com/feature/unscrambler.aspx?word=' + word[1][17:]) soup = BeautifulSoup(r.content) res = soup.find(id='lblResults').contents game.prnt(str([res[i].lower() for i in xrange(0, len(res), 2)])) if len(res) == 2: XC.hook_timer(random.randint(1000, 3000), give_answer) answer = res[0] elif 'First' in word[1]: if playing: matching = [ res[i] for i in xrange(0, len(res), 2) if res[i].startswith(word[1][cur_letter:]) ] game.prnt(str(matching)) cur_letter -= 1 if len(matching) == 1 or (cur_letter == -4 and len(matching) > 0): XC.hook_timer(random.randint(1000, 3000), give_answer) answer = matching[0] elif 'Woohoo' in word[1]: playing = False game.prnt('-= we won! =-') elif 'Nobody got it...' in word[1]: playing = False game.prnt('-= we are loosers :( =-')
def flood_start(word, word_eol, userdata): global flood_message flood_message = word_eol[2] global myflooder global flood_context flood_context = flood_context + [xchat.get_context()] print("Starting the flooder...") if len(flood_context) == 1: myflooder = xchat.hook_timer(int(float(word[1]) * 1000), flooding) return xchat.EAT_ALL
def on_join(word, word_eol, userdata): global thecontext global jointimer triggernick = word[0].lower() triggerchannel = word[1].lower() triggerhost = word[2].lower() thecontext = xchat.get_context() if triggerchannel in option["opin"]: xchat.command("whois " + triggernick) if option["clonescan"] == True: clonescan() if triggerchannel in option["limitchannels"] and option[ "limitjoins"] == True: if jointimer: xchat.unhook(jointimer) jointimer = None jointimer = xchat.hook_timer(option["limittime"], join_limit, userdata=thecontext) if option["antiflood"] == False and option[ "autovoice"] == True and triggerchannel in option["voicein"]: thecontext.command("voice " + triggernick) elif option["antiflood"] == True: #Check if the user is in the dictionary if not check if their host matches any if not add it if triggernick not in users[triggerchannel]: for user in users[triggerchannel]: if users[triggerchannel][user].host == triggerhost: users[triggerchannel][triggernick] = users[ triggerchannel][user] break #check the dictionary again as we may have added during the host check if triggernick not in users[triggerchannel]: users[triggerchannel][triggernick] = User(host=triggerhost) else: users[triggerchannel][triggernick].joined += 1 if users[triggerchannel][triggernick].joined >= option[ "antifloodlimit"]: thecontext.command("ban " + "*!" + triggerhost) thecontext.command("kick " + triggernick + " " + option["msgjoinflood"]) if triggerchannel in option["voicein"] and option[ "autovoice"] == True: for user in users[triggerchannel]: if users[triggerchannel][ user].host == triggerhost and users[ triggerchannel][user].devoiced == False: thecontext.command("voice " + triggernick) break
def matixgen(word, word_eol, userdata): try: speed = int(word[1]) letters = word_eol[2].upper() check = [i for i in letters if i not in string.letters] if check: error("Only letters allowed!") return xchat.EAT_ALL except: error("Invalid arguments!") else: border_char = 'h' text = [] placeholder = '' border_one = ''+border_char+'' border_two = border_char+'' for x in range(16): color_one = color() color_two = color() placeholder += color_one+border_one placeholder += color_two+border_two first_line = placeholder+color_one+border_one+color_two+border_two xchat.command("say "+first_line) inner_fg = color(solid=True)+border_char inner_bg = color(solid=True) border_color = '1,1' for letter in letters: big_letter = big_letters.get(letter) for i in big_letter: line = color()+border_one+i.replace(':', inner_fg) line = line.replace(letter, border_color+letter+'') line = line.replace(' ', inner_bg+border_char+'') line = line+color()+border_two text.append(line) text.append(first_line) ctx = xchat.get_context() def on_timer(userdata): for txt in text: ctx.command("say %s" % txt.rstrip('\n')) return text.pop(0) xchat.hook_timer(speed, on_timer) return xchat.EAT_ALL
def on_chan_msg(word, word_eol, userdata): global hsay if xchat.get_info('nick') != troll_master: return None if xchat.get_context().get_info('channel') != '#newvce': return None user = word[0] text = word[1] # have we seen the first line? if len(hsay) > 0 and text == hsay[0][1]: del hsay[0] if len(hsay) > 0: xchat.hook_timer(100, say_next_line) return None
def fire(arg): global counter global h_timer game.command('say !scramble') if counter > 0: counter -= 1 if counter > 0 or timeless: h_timer = XC.hook_timer(5 * 60000 + random.randint(10000, 30000), fire)
def request_letter(): global used_letters global guess global patt args = { 'pattern' + str(i): patt[i].lower() if patt[i] != '_' else '' for i in range(0, len(patt)) } args['guessed'] = used_letters args['game'] = 'hangman' args['action'] = 'display' r = requests.post('http://nmichaels.org/hangsolve.py', data=args) guess = str( BeautifulSoup(r.content).find('span', { 'class': 'guess' }).text[0]) XC.hook_timer(random.randint(2000, 5000), guess_letter) used_letters += guess
def addTranslationJob(text, targetLang, srcLang, channel, user, echo = False, outgoing = False): global TIMEOUT_HOOK global TIMER global ACTIVE_JOBS ACTIVE_JOBS += 1 Translator.translate(channel, user, text, targetLang, echo, outgoing, srcLang) if TIMEOUT_HOOK is None: TIMEOUT_HOOK = xchat.hook_timer(TIMER, Translator.readResults) return None
def getquestion(channel, user): global answer, xchat_timer question, answer = getrandom() if question: send_message(channel, user, '\002' + question) if len(answer) == 1: mask = re.sub(r'[a-zA-Z0-9]', '-', answer[0]) send_message(channel, user, "Answer: %s" % mask ) else: send_message(channel, user, "Multiple answers available.") xchat_timer = xchat.hook_timer(10000, timer, (channel, user))
def check_and_send(config_name): config_path = os.path.join(config_dir, config_name + ".conf") if not os.path.isfile(config_path): print("Cannot find " + config_path) return config = parse_config(config_path) if config is None: print(config_path + " has an invalid format") return chan = xchat.get_info("channel") if chan is None or chan != config.get('irc', 'channel'): print("Wrong channel. Expected " + config.get('irc', 'channel') + ", currently in " + str(chan)) return bot = config.get('irc', 'bot') found_bot = False for user in xchat.get_list('users'): if xchat.nickcmp(bot, user.nick) == 0: found_bot = True break if not found_bot: print("Failed to find " + bot + " in current channel") return history = parse_downloads() matched_files = get_packlist_matches(config) # Remove files we've already downloaded before matched_files = [file for file in matched_files if not file[0] in history] if len(matched_files) == 0: print("No new files to download") for idx, file in enumerate(matched_files): xchat.hook_timer(idx * 5000, xdcc_send, userdata=(config, file)) history.append(file[0]) save_downloads(history)
def load_vars(): global option, versions, vcolor, bcolor try: config = ConfigParser.ConfigParser() infile = open(inifile) config.readfp(infile) infile.close() #Parse main for item in config.items("main"): option[item[0]] = item[1] #bools and ints option["service"] = config.getboolean("main", "service") option["advertise"] = config.getboolean("main", "advertise") option["verselimit"] = config.getint("main", "verselimit") option["searchlimit"] = config.getint("main", "searchlimit") option["locallimit"] = config.getint("main", "locallimit") option["cleanup"] = config.getboolean("main", "cleanup") option["cleanuptime"] = config.getint("main", "cleanuptime") bcolor = color[option["bookcolor"]] vcolor = color[option["versecolor"]] if option["cleanup"]: option["cleanuptime"] = option["cleanuptime"] * 60000 xchat.hook_timer(option["cleanuptime"], cleanup) print color["dgreen"], "CancelBot Biblebot biblebot.ini Load Success" except EnvironmentError: print color[ "red"], "Could not open biblebot.ini put it in your " + xchatdir try: versions = os.listdir(option["bibleroot"]) print color["dgreen"], "CancelBot Biblebot Versions Load Success" except EnvironmentError: print color[ "red"], "Could not get directory list. Check permisions or biblebot.ini"
def on_part(word, word_eol, userdata): global jointimer if jointimer: xchat.unhook(jointimer) jointimer = None triggerchannel = word[2].lower() thecontext = xchat.find_context(channel=triggerchannel) if triggerchannel in option["opin"]: if triggerchannel in option["limitchannels"] and option[ "limitjoins"] == True: jointimer = xchat.hook_timer(option["limittime"], part_limit, userdata=thecontext)
def message_cb(word, word_eol, userdata): global first_turn global guess global used_letters global patt if word[0] == '[-KriStaL-]': if 'Puzzle' in word[1]: if first_turn: first_turn = False used_letters = '' patt = word[1][10:] r = requests.post('http://nmichaels.org/hangsolve.py', data={ 'pattern': patt, 'guessed': '', 'game': 'hangman', 'action': 'display' }) guess = str( BeautifulSoup(r.content).find('span', { 'class': 'guess' }).text[0]) XC.hook_timer(random.randint(2000, 5000), guess_letter) used_letters += guess else: patt = word[1][10:] request_letter() elif 'Sorry, there is no' in word[1]: request_letter() elif 'Congratulations' in word[1]: game.prnt('-= we won! =-') endgame() elif 'No one guessed' in word[1]: game.prnt('-= we lose! =-') endgame()
def done(self): """Finaliazation and cleanup""" # Done! if debug: xchat.emit_print('Server Text', "Done " + str(self)) pending.remove(self) # Deop? if not self.am_op or not self.needs_op: return for p in pending: if p.channel == self.channel and p.needs_op or not p.deop: self.deop = False break if self.deop: self.context.command("chanserv deop %s" % self.channel) # Schedule removal? if self.timer and (self.channel not in can_do_akick or self.banmode == 'q'): action = Action(self.channel, self.me, self.context) action.deop = self.deop action.actions = [x.replace('+', '-', 1) for x in self.actions] action.target = self.target action.target_nick = self.target_nick action.target_ident = self.target_ident action.target_host = self.target_host action.target_name = self.target_name action.target_name_bannable = self.target_name_bannable action.target_account = self.target_account action.resolved = True action.banmode = self.banmode action.needs_op = True xchat.hook_timer( self.timer * 1000, lambda act: act.schedule(update_stamp=True) and False, action)
def scroll(word, word_eol, userdata): global running running = True path = '/home/erm/Documents/irc/irc/ascii/' if len(word) > 2: data = word_eol[2] if data[1:].split()[0] == 'search': #fix later search(path, word[1]) return filepath = '%s%s.txt' % (path, word[1]) try: ascii_txt = open(filepath, 'r').readlines() except IOError: error("File not found!") else: speed = 50 if len(word) > 2: if data.split()[0] == '-speed': #fix later speed = int(data.split()[1]) * 10 if data[0] != '-': #fix later error("Invalid arguments!") return _args = [ arg for arg in data[1:].split(' -') if arg.split()[0] in funcs.keys() ] for arg in _args: ascii_txt = transform(ascii_txt, arg) ctx = xchat.get_context() def on_timer(userdata): for line in ascii_txt: if running: ctx.command("say %s" % line.rstrip('\n')) return ascii_txt.pop(0) xchat.hook_timer(speed, on_timer) return xchat.EAT_ALL
def joiner(self, word, word_eol, userdata): nick = xchat.get_info('nick') if word[0].find(nick) > -1: timeout = 3 if len(self.hooked): for handler in self.hooked: xchat.unhook(handler) self.hooked = [] self._hook_wait = time.time() if not self.hooked_timer: print 'register hook timer' self.hooked_timer = xchat.hook_timer(timeout * 1000, self._xchatHookTest, (timeout))