本文整理汇总了Python中xchat.get_info函数的典型用法代码示例。如果您正苦于以下问题:Python get_info函数的具体用法?Python get_info怎么用?Python get_info使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_info函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_key_type
def set_key_type(self, word, word_eol, userdata):
target = xchat.get_info('channel')
server = xchat.get_info('server')
ktype = ''
if len(word) == 2:
ktype = word[1]
elif len(word) >= 3:
target = word[1]
if len(word) == 3:
ktype = word[2]
else:
server = word[2]
ktype = word[3]
try:
key = self.keymap[target, server]
except KeyError:
print 'No key set for {} @ {}.'.format(target, server)
else:
if ktype.lower() in ['aes', 'a', 'blowfish', 'b']:
key.aes = (ktype.lower() in ['aes', 'a'])
print 'Key type for {} @ {} set to {}.'.format(target, server, key.get_type())
elif not ktype:
print 'Key type for {} @ {} is {}.'.format(target, server, key.get_type())
else:
print 'Key type must be either AES or Blowfish.'
return xchat.EAT_ALL
示例2: CheckWhoRet
def CheckWhoRet(word,word_eol,userdata):
global hosts
servChan = xchat.get_info("host")+"/"+xchat.get_info("channel")
nick,user,host = (word[7],word[4],word[5])
if servChan not in hosts: hosts[servChan] = {}
hosts[servChan][nick] = (user,host)
return xchat.EAT_NONE
示例3: handle_message
def handle_message(self, word, word_eol, userdata):
'''
Handle a message in xchat.
word is something like:
[ '\xaaaanick', "the message we're acting on" ]
where aaaa is a number like \x0328
This, incidentally, is not what the doc says it should be at
http://xchat.org/docs/xchatpython.html
userdata is something like: 'Channel Message', from EVENTS,
so you can play different sounds depending on what happened.
'''
# If it's too soon after startup, don't do anything.
# Then we won't hear a slew of alerts from past scrollback,
# NickServ 'You are now identified for" messages, etc.
if time.time() - self.start_time < XchatSoundHandler.STARTUP_DELAY :
return xchat.EAT_NONE
# You may want to use channel name, network name or variables
# in the xchat context to decide which alerts to play.
channel = xchat.get_info('channel')
network = xchat.get_info('network')
ctxt = xchat.get_context()
mynick = ctxt.get_info("nick")
line = word[1]
# Now, customize the rest as desired. Here are some examples:
# Anyone addressing or mentioning my nick:
if line.find(mynick) > 0 and word[0] != 'NickServ' or \
userdata == "Channel Msg Hilight" or \
userdata == "Channel Action Hilight" :
# print ">>>>> Contains my nick!", userdata, ">>", line
self.player.play(os.path.join(self.sound_dir, "akk.wav"))
return xchat.EAT_NONE
# Private message:
elif userdata.startswith("Private Message") :
# print ">>>>> Private message!"
self.player.play(os.path.join(self.sound_dir, "akk.wav"))
return xchat.EAT_NONE
# Now check whether we're silenced.
# Note that nick references and private messages are exempt
# from this check -- you'll hear them even on silenced channels.
if channel in self.silenced_channels :
return xchat.EAT_NONE
# More subtle sound for bitlbee/twitter, since they're so numerous:
if channel == "#twitter_" + mynick :
# print ">>>>> Twitter channel!"
self.player.play(os.path.join(self.sound_dir, "SingleClick.wav"))
# if you want to be fairly noisy or don't have many active channels,
# you might want an alert for every channel message:
elif userdata.startswith("Channel M") or \
userdata.startswith("Channel Action") :
self.player.play(os.path.join(self.sound_dir, "pop.wav"))
return xchat.EAT_NONE
示例4: messagebuffer
def messagebuffer(dunno):
global list_
#Makes sure we have locked the list so that we start on a new list if we send messages during execution
tmplist = list_
list_ = None
#Get's the current channel, so we know where we should send messages
channel = xchat.get_info('channel')
#If the list is shorter than the pastelimit, just send them one by one to the irc-server
if len(tmplist) <= settings['limit']:
for i in tmplist:
#send the actual string
xchat.command("PRIVMSG %s :%s" % (channel, i))
#recreate the output from a regular message, as this is just a regular message
xchat.emit_print("Your Message", xchat.get_info('nick'), i, "@")
else:
#Add all the lines together into a string
str_ = ""
for i in tmplist:
str_ += i + "\n"
# do the paste
pastie_url = do_pastie(str_[:-1])
xchat.command("PRIVMSG %s :%s" % (xchat.get_info('channel'), pastie_url))
xchat.emit_print("Your Message", xchat.get_info('nick'), pastie_url, "@")
return 0 # Return 0 so we don't repeat the timer.
示例5: 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
示例6: nickchange
def nickchange(word, word_eol, userdata):
desired_nick = xchat.get_prefs("irc_nick1")
password = xchat.get_info("nickserv")
if xchat.get_info("nick") is desired_nick:
lineprint("Got desired nick now: "+desired_nick)
return SUCCESS
return FAIL
示例7: CheckCondition
def CheckCondition(cond, arg):
if cond in ["ifuser", "ifnotuser"]:
# EVERY CHANNEL LIKE A RETARD, XCHAT
# WHY NOT JUST HAVE xchat.get_info("user") HUH? FUCK YOU
username = None
serv = xchat.get_info("server")
for ch in xchat.get_list("channels"):
if ch.server == serv:
nick = xchat.get_info("nick")
for user in ch.context.get_list("users"):
if user.nick == nick:
# FURTHER TROLLING?
username = user.host.split("@")[0].lstrip("~")
break
# endif
# endfor
# endif
# endfor
if not username:
return False
if "not" in cond:
return arg != username
else:
return arg == username
elif cond == "true":
return True
return False
示例8: dc801_channel
def dc801_channel():
print "dc801_channel"
''' Is this channel #dc801 on FreeNode? '''
global CHANNEL_NAME, NETWORK_NAME
net = xchat.get_info("network")
chan = xchat.get_info("channel")
return net==NETWORK_NAME and chan==CHANNEL_NAME
示例9: main
def main(word, word_eol, userdata):
channel = xchat.get_info("channel")[1:]
if xchat.get_info("server") == "tmi.twitch.tv":
server = "twitch.tv"
else:
server = defaultserver
if len(word) == 1:
connect(channel, quality, server)
elif word[1] == "raw" and len(word) >= 3:
xchat.command("exec livestreamer {0}".format(word_eol[2]))
elif word[1] == "help" and len(word) >= 2:
xstreamHelp(word, word_eol)
elif any(word[1] == stopcmd for stopcmd in stopcommands) and len(word) == 2:
if platform.system() == "Windows":
xchat.command("exec taskkill /im livestreamer.exe /f")
elif platform.system() == "Linux":
xchat.command("exec pkill livestreamer")
else:
print("Sorry, I don't recognize your operating system")
elif len(word) == 2:
if word[1] == "stop":
xchat.command("execkill")
elif word[1] == "raw":
print("syntax: /xstream raw <command>")
else:
connect(word[1], quality, server)
elif len(word) == 3:
connect(word[1], word[2], server)
elif len(word) == 4:
connect(word[1], word[2], word[3])
else:
print("Usage: /xstream (<channel>) (<quality>) (<server>)")
return xchat.EAT_ALL
示例10: CheckJoin
def CheckJoin(word,word_eol,userdata):
global hosts
servChan = xchat.get_info("host")+"/"+xchat.get_info("channel")
nick = word[0]
user,host = tuple(word[2].split("@"))
if servChan not in hosts: hosts[servChan] = {}
hosts[servChan][nick] = (user,host)
return xchat.EAT_NONE
示例11: slap
def slap(word, word_eol, userdata):
try:
xchat.command("ME slaps {0} around a bit with a {1}".format(word[1], ' '.join(word[2:])))
xchat.command("SAPART {0} {1} {2}".format(word[1], xchat.get_info("channel"), "Slapped!"))
xchat.command("SAJOIN {0} {1}".format(word[1], xchat.get_info("channel")))
except:
print("Syntax is /slap person fish")
return xchat.EAT_ALL
示例12: banned
def banned(word, word_eol, userdata):
'''Looks like we've been banned from a channel, lets get payback!'''
#I was going to add kicking.. Its not really 'pacback' yet..
if xchat.get_info("server") == "opsimathia.datnode.net":
print("* \x02[Banned]\x02 Attempting to takeover channel {0}.".format(word[0]))
xchat.command("SAJOIN {0} {1}".format(xchat.get_info("nick"), word[0]))
xchat.command("SAMODE {0} +q {1}".format(word[0], xchat.get_info("nick")))
else:
print("* \x02[Banned]\x02 from channel {0}.".format(word[0]))
示例13: __init__
def __init__(self):
# Auto Delete after database size gets bigger than <some size>
# self.max_size = (1024 * 1024) * 1024
if os.name != "posix":
self.dbconnection = sqlite3.connect(xchat.get_info("xchatdir") + "\\seen.db")
else:
self.dbconnection = sqlite3.connect(xchat.get_info("xchatdir") + "/seen.db")
self.curs = self.dbconnection.cursor()
self.curs.execute("CREATE TABLE IF NOT EXISTS seen (nick TEXT UNIQUE, msg TEXT)")
示例14: get_nick
def get_nick(first_word=None, network=None):
'''
Get the key id of a nick (if specified) or channel.
'''
if first_word:
nick = first_word.split('!')[0] if '!' in first_word else first_word
else:
nick = xchat.get_info('channel')
return '{}@{}'.format(nick, network or xchat.get_info('network'))
示例15: search
def search(word, word_eol, userdata):
"""Searches whatever messages we have for any passed arguments.
If userdata is equal to 'a', usernames and messages will be searched for
matches.
If userdata is equal to 'u', only usernames will be searched for matches.
Finally, if userdata is equal to 'm', only messages will be searched for
matches.
Found matches are highlighted. The above rules are respected for
highlighting matches.
"""
channel = xchat.get_info("channel")
network = xchat.get_info("network")
if network not in networks:
print("\00307Nothing to search in %s." % network)
return
if channel not in networks[network]:
print("\00307Nothing to search in %s:%s." % (network, channel))
return
args = split(word_eol[1])
msgs = []
for msg in networks[network][channel]:
# Convert the timestamp to H:M:S format, then get the nickname's color.
timestamp = strftime("%H:%M:%S", localtime(msg[0]))
ucolor = color(msg[1])
found = False
for arg in args:
if userdata == 'a' and (arg in msg[1] or arg in msg[2]):
found = True
user = "%s%s%s" % (ucolor, replace_arg(msg[1], arg), ucolor)
umsg = replace_arg(msg[2], arg)
elif userdata == 'u' and arg in msg[1]:
found = True
user = "%s%s%s" % (ucolor, replace_arg(msg[1], arg), ucolor)
umsg = msg[2]
elif userdata == 'm' and arg in msg[2]:
found = True
user = ucolor
umsg = replace_arg(msg[2], arg)
if found:
# Append result to msgs, which will be used later, and break
# so the same match isn't counted multiple times if multiple
# arguments are passed.
msgs.append("%s\t%s\017: %s" % (timestamp, user, umsg))
break
if len(msgs) > 0:
# Open a new dialog and print all found results in it.
xchat.command("DIALOG Search")
dialog = xchat.find_context(network, "Search")
for msg in msgs:
dialog.prnt(msg)
else:
print("\00307No results founds in %s:%s." % (network, channel))
return xchat.EAT_ALL