本文整理汇总了Python中xchat.hook_timer函数的典型用法代码示例。如果您正苦于以下问题:Python hook_timer函数的具体用法?Python hook_timer怎么用?Python hook_timer使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hook_timer函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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)
示例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)
示例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)
示例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
示例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()
示例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
示例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
示例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)
示例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)
示例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
示例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
示例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)
示例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
示例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
示例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