本文整理汇总了Python中xchat.get_context函数的典型用法代码示例。如果您正苦于以下问题:Python get_context函数的具体用法?Python get_context怎么用?Python get_context使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_context函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: wrap
def wrap(self, datatype, data, nick):
#print "wrap:", type, str(data)[:80], nick
SIZE = 384 # Max size allowed for one part
assert PREFIXES.has_key(datatype)
if datatype == "pub":
encoded = self.str2baseX(data.exportKey())
elif datatype == "key":
encoded = self.str2baseX(data)
elif datatype == "sig":
encoded = self.dec2baseX(data)
elif datatype == "enc":
encoded = self.str2baseX(data)
elif datatype == "mul":
encoded = data
if len(encoded) > SIZE:
#Sends recursively parts in this order: N, N-1, ..., 1
MsgWrapper.wrap("mul", encoded[SIZE:], nick)
envio = PREFIXES[datatype] + encoded[:SIZE]
xchat.get_context().command("raw privmsg " + nick + " " + envio)
else:
envio = PREFIXES[datatype] + encoded
xchat.get_context().command("raw privmsg " + nick + " " + envio)
示例2: 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
示例3: reset_activity_cb
def reset_activity_cb(self, word=None, word_eol=None, data=None):
channel = xchat.get_context().get_info("channel")
server = xchat.get_context().get_info("server")
if server and channel:
key = server + ":" + channel
self.activity[key] = 0
return xchat.EAT_NONE
示例4: private_cb
def private_cb(word, word_eol, userdata):
global focus_context, notify_context
if not same_context(focus_context, xchat.get_context()):
tips.set_tip(icon, ("[%s]: %s"%(word[0], word[1]))[0:79])
tips.enable()
icon.show_all()
notify_context = xchat.get_context()
return xchat.EAT_NONE
示例5: fl_hook
def fl_hook(word, word_eol, userdata):
if xchat.get_info("win_status") == "active":
return xchat.EAT_NONE
set_flashlight(1)
global fl_contexts
context = xchat.get_context()
if context not in fl_contexts:
fl_contexts.append(xchat.get_context())
return xchat.EAT_NONE
示例6: on_message
def on_message(word, word_eol, userdata):
user = word[0]
message = word[1].strip().lower()
for trigger, response in responses:
if message.find(trigger) != -1:
if response[0] == '*':
xchat.get_context().command('me ' + response[1:])
else:
xchat.get_context().command('say ' + response)
return xchat.EAT_XCHAT
return xchat.EAT_XCHAT
示例7: on_address
def on_address(word, word_eol, userdata):
user = word[0]
message = word[1].strip()
pattern = r'^' + username + r"[^A-Za-z0-9]*<(.+)><(.+)>$"
m = re.match(pattern, message)
if m:
responses.append([m.group(1), m.group(2)])
xchat.get_context().command('say ' + '^_^')
return xchat.EAT_ALL
else:
on_message(word, word_eol, userdata)
xchat.get_context().command('say ' + 'nya?')
return xchat.EAT_ALL
示例8: pvt_request
def pvt_request(word, word_eol, userdata):
destination = xchat.get_context()
triggernick = word[0]
trigger = re.split(' ',string.lower(word[1]))
if option["service"] == True:
if trigger[0] in versions and option["service"] == True:
#get_text(trigger[:3], destination)
threading.Thread(target=get_text, args=(trigger[:3], destination)).start()
if trigger[0] == '!search' and trigger[1] in versions:
#get_search(trigger[1], trigger[2:], triggernick)
threading.Thread(target=get_search, args=(trigger[1], trigger[2:], triggernick)).start()
if trigger[0] == '!searchbybook' and trigger[1] in versions:
#get_searchbybook(trigger[1], trigger[2], trigger[3:], triggernick)
threading.Thread(target=get_searchbybook, args=(trigger[1], trigger[2], trigger[3:], triggernick)).start()
if trigger[0] == '!help':
#play_file(option["helpfile"], triggernick)
threading.Thread(target=play_file, args=(option["helpfile"], triggernick)).start()
if trigger[0] == '!rules':
#play_file(option["rulesfile"], triggernick)
threading.Thread(target=play_file, args=(option["rulesfile"], triggernick)).start()
if trigger[0] == '!versions':
#play_file(option["versionfile"], triggernick)
threading.Thread(target=play_file, args=(option["versionfile"], triggernick)).start()
if trigger[0] == '!list' and trigger[1] in versions:
#get_list(trigger[1], triggernick)
threading.Thread(target=get_list, args=(trigger[1], triggernick)).start()
示例9: ether
def ether(word, word_eol, userdata):
# TODO Add iPhone hotspot (find ipheth)
def get_ethernet_devices():
devices = pci_find_by_class(PCI_CLASS_NETWORK_ETHERNET)
devices += pci_find_by_class(PCI_CLASS_NETWORK_ETHERNET_WIFI)
usb_devices = usb_find_by_class(USB_CLASS_NETWORK)
usb_devices += usb_find_by_class(USB_CLASS_NETWORK_GENERIC)
usb_devices += usb_find_by_class(USB_CLASS_BLUETOOTH)
names = []
for device_id, vendor_id in devices:
names.append(pci_find_fullname(device_id, vendor_id))
for device_id, vendor_id in usb_devices:
names.append(usb_find_fullname(device_id, vendor_id))
return names
names = get_ethernet_devices()
output = ', '.join(names)
if output:
dest = xchat.get_context()
dest.command('say %s' % wrap('ether', output))
else:
xchat.prnt('No ethernet devices found')
return xchat.EAT_ALL
示例10: checkPrint
def checkPrint(word, word_eol, userdata):
" if someone says '.yt', respond like 'found http://youtu.be/asdf "
del(word_eol, userdata) # shut up, pylint
# "PRIVMSG Jane :that smells bad"
# word[0] = 'Jane' word[1] = 'that smells bad'
# word_eol[0] = 'Jane that smells bad' word_eol[1] = 'that smells bad'
if ' ' in word[1]:
cmd, params = word[1].split(' ', 1)
else:
cmd, params = word[1], None
context = xchat.get_context()
chan = context.get_info('channel')
if cmd == '!yt':
if not params:
return xchat.NONE
if chan in LASTUSED:
now = time.time()
if LASTUSED[chan] + TIMEOUT >= now:
context.command('msg {} "!yt" on cooldown'.format(word[0]))
else:
found = fetchYTresults(params)[0]
if found['id']:
context.command('me found \x02{}\x0f \x1fhttp://youtu.be/{}\x0f'.format(found['title'], found['id']))
else:
context.command('me couldn\'t search YouTube')
print '*** error searching YouTube: {}'.format(found['title'])
LASTUSED[chan] = now
return xchat.EAT_PLUGIN
示例11: focus_cb
def focus_cb(word, word_eol, userdata):
global focus_context, notify_context
focus_context = xchat.get_context()
if same_context (notify_context, focus_context):
icon.hide()
tips.disable()
return xchat.EAT_NONE
示例12: 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
示例13: on_pvt
def on_pvt(word, word_eol, userdata):
destination = xchat.get_context()
triggernick = word[0]
trigger = re.split(' ', word[1].lower())
if trigger[0] == '!weather' and option["service"] == True:
get_weather(trigger[1], destination)
示例14: __init__
def __init__(self, title, masters, players, hardcore):
self.title = title
self.masters = masters
self.hardcore = hardcore
self.players = players
session.add(self)
characters_list = []
for each_player in players:
new_character = Character()
new_character.name = unicode(each_player.nick)
new_character.games = [self]
session.add(new_character)
characters_list.append(new_character)
self.characters = characters_list
session.commit()
players_string = ""
for each_player in self.players:
if players.index(each_player) < len(players)-1:
players_string += each_player.nick + ", "
else:
players_string += each_player.nick
context = xchat.get_context()
say(context, '[' +self.title + '] ' + '게임이 시작되었습니다. (마스터: ' + self.masters[0].nick + ', ' + '플레이어: ' + players_string + ')')
示例15: 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