• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Python xchat.hook_timer函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中xchat.hook_timer函数的典型用法代码示例。如果您正苦于以下问题:Python hook_timer函数的具体用法?Python hook_timer怎么用?Python hook_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了hook_timer函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: done

    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)
开发者ID:grimreaper,项目名称:chanserv.py,代码行数:35,代码来源:chanserv.py


示例2: weapon_activate

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)
开发者ID:lsanscombe,项目名称:random,代码行数:7,代码来源:hammer.py


示例3: run

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 %[email protected]%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)
开发者ID:archlinuxaur,项目名称:aur-mirror-migration,代码行数:35,代码来源:xdccq.py


示例4: initialize

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
开发者ID:DoktorUnicorn,项目名称:xchatscripts,代码行数:25,代码来源:allcapsfriday.py


示例5: message_cb

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()
开发者ID:Tahvok,项目名称:hexchat-game-bots,代码行数:34,代码来源:hangman_bot.py


示例6: since_cb

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
开发者ID:EliteSoba,项目名称:xchat_scripts,代码行数:27,代码来源:tim.py


示例7: sellout_cb

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
开发者ID:EliteSoba,项目名称:xchat_scripts,代码行数:59,代码来源:sellout.py


示例8: init_cb

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)
开发者ID:Tahvok,项目名称:hexchat-game-bots,代码行数:8,代码来源:scramble_bot.py


示例9: weapon_timer

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)       
开发者ID:lsanscombe,项目名称:random,代码行数:9,代码来源:hammer.py


示例10: say_cb

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
开发者ID:thecodeassassin,项目名称:xchat-autopaster,代码行数:12,代码来源:xchat-autopaster.py


示例11: say_next_line

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
开发者ID:dcchut,项目名称:trollchat,代码行数:12,代码来源:trollchat.py


示例12: message_cb

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)
开发者ID:Tahvok,项目名称:hexchat-game-bots,代码行数:13,代码来源:hunt_bot.py


示例13: on_join

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
开发者ID:dcchut,项目名称:trollchat,代码行数:50,代码来源:trollchat.py


示例14: request_letter

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
开发者ID:Tahvok,项目名称:hexchat-game-bots,代码行数:14,代码来源:hangman_bot.py


示例15: start

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
开发者ID:Ultrabenosaurus,项目名称:EasyXdcc,代码行数:7,代码来源:EasyXdcc.py


示例16: steiner

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', 'homo', '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 faggot".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
开发者ID:ScottSteiner,项目名称:xchat-scripts,代码行数:27,代码来源:steiner-replies.py


示例17: ReadySend

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
开发者ID:GunfighterJ,项目名称:xchat-plugins,代码行数:7,代码来源:delayedmsg.py


示例18: endgame

def endgame():
    global counter
    global h_timer
    global timeless
    
    if counter > 0 or timeless:
        h_timer = XC.hook_timer(random.randint(10000, 20000), fire)
开发者ID:Tahvok,项目名称:hexchat-game-bots,代码行数:7,代码来源:hangman_bot.py


示例19: cap_cb

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
开发者ID:rofl0r,项目名称:ixchat,代码行数:33,代码来源:cap_sasl_xchat.py


示例20: toggle_cb

    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
开发者ID:nbm077,项目名称:hush,代码行数:34,代码来源:hush.py



注:本文中的xchat.hook_timer函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python xchat.hook_unload函数代码示例发布时间:2022-05-26
下一篇:
Python xchat.hook_server函数代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap