本文整理汇总了Python中xchat.hook_server函数的典型用法代码示例。如果您正苦于以下问题:Python hook_server函数的具体用法?Python hook_server怎么用?Python hook_server使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了hook_server函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
def __init__(self):
# fix find a way to remove use of globals
self.festival=festival()
self.vocalized_channels = set()
self.vocalized_nicks = set()
self.muted_nicks_in_channels = set()
self.actors = {
"caleb" : "(voice_kal_diphone)",
"ken" : "(voice_ked_diphone)",
"randal" : "(voice_rab_diphone)",
"alan" : "(voice_cmu_us_awb_arctic_clunits)",
"brett" : "(voice_cmu_us_bdl_arctic_clunits)",
"carmen" : "(voice_cmu_us_clb_arctic_clunits)",
"jerry" : "(voice_cmu_us_jmk_arctic_clunits)",
"roger" : "(voice_cmu_us_rms_arctic_clunits)",
"sarah" : "(voice_cmu_us_slt_arctic_clunits)",
}
self.unpack()
self.substitutions={
}
xchat.hook_command("unmute", self.unmute, help="/unmute [speaker] Turn on speech for this window or a specific speaker in this channel")
xchat.hook_command("mute", self.mute, help="/mute [speaker] Turn off speech for this window, or mute a specific speaker in this channel")
xchat.hook_command("pronounce", self.pronounce, help="'/pronounce word [pronunciation]' - Fix pronunciation for a word, or delete the pronunciation if it exists.")
xchat.hook_command("cast", self.cast, help="'/cast nick [actor]' cast an actor as a particular nick, or clear that casting.")
xchat.hook_server("PRIVMSG", self.chat_hook)
示例2: 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
示例3: ghostcb
def ghostcb(word, word_eol, userdata):
c = xchat.get_context()
nick = word[3] #use this instead of preferred nick, I guess.
pw = c.get_info("nickserv")
u = {"context":c, "nick":nick}
u["hook"] = xchat.hook_server("NOTICE", noticecb, userdata=u)
xchat.command("msg nickserv ghost {} {}".format(nick, pw))
return xchat.EAT_NONE
示例4: noticecb
def noticecb(word, word_eol, userdata):
match = NICKPATTERN.match(word[0])
matchtxt = 'Ghost with your nick has been killed.'
if not match or xchat.nickcmp(match.group(1), 'NickServ') != 0:
return xchat.EAT_NONE
if word_eol[-2][1:] == 'Access denied.':
xchat.unhook(userdata["hook"])
elif len(word_eol) > 7 and word_eol[-7][1:] == matchtxt:
u = {}
u.update(userdata)
c = u["context"]
c.command("nick " + u["nick"])
u["hook"] = xchat.hook_server("", identifycb,
userdata=u)
xchat.unhook(userdata["hook"])
return xchat.EAT_NONE
示例5: __init__
def __init__(self):
self.id_dh = {}
self.hooks = [
xchat.hook_command('', self.on_send_message),
xchat.hook_command('ME', self.on_send_me),
xchat.hook_command('MSG', self.on_send_msg),
xchat.hook_command('NOTICE', self.on_send_notice),
xchat.hook_server('notice', self.on_recv_notice, priority=xchat.PRI_HIGHEST),
xchat.hook_print('Change Nick', self.on_change_nick),
xchat.hook_unload(self.unload),
]
for name in (
'Channel Action', 'Private Action to Dialog', 'Private Action', 'Channel Message',
'Private Message to Dialog', 'Private Message'
):
xchat.hook_print(name, self.on_recv_message, name, priority=xchat.PRI_HIGHEST),
示例6: len
if len(word) >= 3 and word[2] != '--network':
if word_eol[2]=="1" or word_eol[2]=="True" or word_eol[2]=="true":
key.aes = True
if word_eol[2]=="0" or word_eol[2]=="False" or word_eol[2]=="false":
key.aes = False
KEY_MAP[id_] = key
elif len(word) >= 5 and word[2] == '--network':
if word_eol[4]=="1" or word_eol[4]=="True" or word_eol[4]=="true":
key.aes = True
if word_eol[4]=="0" or word_eol[4]=="False" or word_eol[4]=="false":
key.aes = False
print 'Key aes', id_, 'set', key.aes
return xchat.EAT_ALL
import xchat
xchat.hook_command('key', key, help='show information or set key, /key <nick> [<--network> <network>] [new_key]')
xchat.hook_command('key_exchange', key_exchange, help='exchange a new key, /key_exchange <nick>')
xchat.hook_command('key_list', key_list, help='list keys, /key_list')
xchat.hook_command('key_load', key_load, help='load keys, /key_load')
xchat.hook_command('key_pass', key_pass, help='set key file pass, /key_pass password')
xchat.hook_command('aes', aes, help='aes #channel/nick 1|0 or True|False')
xchat.hook_command('key_remove', key_remove, help='remove key, /key_remove <nick>')
xchat.hook_server('notice', dh1080)
xchat.hook_print('Channel Message', decrypt_print, 'Channel Message')
xchat.hook_print('Change Nick', change_nick)
xchat.hook_print('Private Message to Dialog', decrypt_print, 'Private Message to Dialog')
xchat.hook_server('332', server_332)
xchat.hook_command('', encrypt_privmsg)
xchat.hook_unload(unload)
load()
示例7: msg
import xchat
__module_name__ = "Pirates-next"
__module_author__ = "OSN64"
__module_version__ = "1"
__module_description__ = "Bot to play pirates game"
#__fetch_interval = 47 * 60 # 47 minutes
pirate_channel = "#smp"
pirate_server = "criten"
pirate_host = "JeromeTheBaller"
cnc = xchat.find_context(channel=pirate_channel)
def msg(word, word_eol, userdata):
if xchat.nickcmp(word[1], pirate_host) == 0:
xchat.prnt("They are the same!")
#xchat.prnt(', '.join(word_eol))
#userlist = context.get_list("users")
#xchat.prnt(word)
return xchat.EAT_NONE
xchat.hook_server("PRIVMSG", msg)
#xchat.hook_timer(__fetch_interval * 1000, dig)
xchat.prnt(__module_name__ + ' version ' + __module_version__ + ' loaded.')
示例8: DidJoin
import xchat
didJoin = {}
def DidJoin(word,word_eol,userdata):
global didJoin
didJoin[xchat.get_info("server") + "/" + word[1]] = True
#enddef
def fc(word): return word[1:] if word[0] == ":" else word
def OrDidI(word,word_eol,userdata):
global didJoin
nick = word[0]
nick = nick[1:nick.find("!")]
if nick == xchat.get_info("nick"):
chan = fc(word[2])
if chan[0] == ":": chan = chan[1:]
servChan = xchat.get_info("server") + "/" + chan
if servChan not in didJoin:
xchat.command("part " + chan)
return xchat.EAT_ALL
else:
del didJoin[servChan]
#endif
#endif
#enddef
xchat.hook_server("JOIN",OrDidI)
xchat.hook_command("join",DidJoin)
xchat.prnt("Loaded %s version %s." % (__module_name__,__module_version__))
示例9: WhoLoopStart
global dInfo
sServ=xchat.get_info("network")
if sServ in dInfo and dInfo[sServ]["on"] == 3:
lChannels = xchat.get_list("channels")
for i in lChannels:
if i.type == 2:
lUsers = i.context.get_list("users")
for j in lUsers:
if j.nick == dInfo[sServ]["nick"]:
dInfo[sServ]["on"] = 5 # Wait for quit
return
#endif
#endfor
#endif
#endfor
WhoLoopStart()
#endif
#enddef
xchat.hook_print("Notice", DoNick)
xchat.hook_print("Your Nick Changing", DoIdentify)
xchat.hook_print("Join", CheckJoin)
xchat.hook_print("Quit", CheckQuit)
xchat.hook_print("Part", CheckPart)
xchat.hook_print("You Join", CheckUserList)
xchat.hook_server("376",GhostThatFucker,True) #MOTD End
xchat.hook_server("422",GhostThatFucker,True) #MOTD Missing
xchat.hook_command("gnick",GhostThatFucker,False)
xchat.prnt("Loaded %s version %s." % (__module_name__,__module_version__))
示例10: make_ip
import dns.exception
import dns.resolver
import dns.reversename
import re
import socket
import struct
import xchat
__module_name__ = "gateway_identify"
__module_description__ = "Print the IP of users joining from gateways"
__module_version__ = "1.0"
hex_ip_regex = re.compile(r'^~?[0-9a-f]{8}$')
def make_ip(s):
return socket.inet_ntoa(struct.pack('!I',eval('0x'+s)))
def identify_gateway(word, word_eol, userdata):
id = word[0][1:]
nick, ident, host = re.split('[@!]', id)
if not (hex_ip_regex.match(ident) and host.startswith('gateway/')):
return
channel = word[-1][1:]
ip = make_ip(ident[-8:])
try:
host = dns.resolver.query(dns.reversename.from_address(ip), 'PTR').response.answer[0][0].to_text()[:-1]
except (dns.resolver.NXDOMAIN, dns.exception.Timeout):
host = 'unknown hostname'
xchat.find_context(channel=channel).emit_print('Server Notice', "%s is coming from %s (%s)" % (nick, ip, host))
xchat.hook_server('JOIN', identify_gateway, priority=xchat.PRI_LOWEST)
示例11: Host
if k == "Part":
if args[3]: msgid = "Part with Reason"
else: msgid = "Part"
# We want to keep if it's a highlight intact, so pass the event along.
elif k == "Message" or k == "Action":
if k == "Action": msg = "\x01ACTION " + args[1] + "\x01"
else: msg = args[1]
# Emulate the message so that it will promote the channel status appropriately.
nick, host = args[0].split("@")
xchat.command("RECV :%s PRIVMSG %s :%s" % (
nick + "@" + host + "!" + Host(host), word[2], msg
))
return xchat.EAT_XCHAT
# Otherwise use the key.
else: msgid = k
# Emit the actual message.
xchat.emit_print(msgid, *args)
# Tell xchat not to print H-tan's Channel Message.
return xchat.EAT_XCHAT
#endif
#endfor
return xchat.EAT_NONE
#enddef
xchat.hook_server("PRIVMSG", ProxyMessage)
xchat.prnt("Loaded %s version %s." % (__module_name__,__module_version__))
示例12: megapart
def megapart(self, word, word_eol, userdata):
self.whoishook = xchat.hook_server("319",self.got_319)
self.timer = xchat.hook_timer(120000,self.reset)
user = word[1]
xchat.command("QUOTE whois %s" % user)
示例13: rem_server
# servers.add(server)
# print "Suggestible servers are:", " ".join(map(repr, servers))
# return xchat.EAT_ALL
# xchat.hook_command("SUGGEST_ADD", add_server,
# help="/SUGGEST_ADD <server> become suggestible on server.")
# def rem_server(word, word_eol, userdata=None):
# for server in word[1:]:
# if server in servers:
# servers.remove(server)
# else:
# print "%r is not in servers." % server
# print "Suggestible servers are:", " ".join(map(repr, servers))
# return xchat.EAT_ALL
# xchat.hook_command("SUGGEST_REM", rem_server,
# help="/SUGGEST_REM <server> be not suggestible on server.")
def suggestible(word, word_eol, userdata=None):
context = xchat.get_context()
connected_to = context.get_info("server").lower()
context.command("JOIN " + word[3])
return xchat.EAT_XCHAT
xchat.hook_server("INVITE", suggestible)
print "Becoming suggestible"
示例14: enable
def enable(self, *args):
dprint("enable()")
if not self.privmsg_hook:
self.privmsg_hook = xchat.hook_server("PRIVMSG", self.responder)
示例15: otcauth_gpg_decrypt
# Link Good! cURL our string and decrypt.
curl = pycurl.Curl()
curl.setopt(curl.URL, url)
curl.setopt(curl.USERAGENT, """Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727)""")
curl.setopt(curl.WRITEFUNCTION, buf.write)
curl.perform()
# Decrypt and message gribble back the verify string.
auth_string = buf.getvalue()
buf.close()
xchat.command("MSG gribble everify %s" % otcauth_gpg_decrypt(auth_string))
eauthCheck = False
return xchat.EAT_NONE
# Hook the server event when gribble messages us.
xchat.hook_server("PRIVMSG", otcauth_gpg_auth)
# The callback function to our hook that ties it all together
def otcauth_cb(word, word_eol, userdata):
if len(word) < 2:
switch = "help"
else:
switch = str(word[1]).lower()
if switch == "help":
otcauth_help(word[1:])
elif switch == "version":
otcauth_ver()
elif switch == "eauth":
nick = xchat.get_info('nick')