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

Python xchat.get_context函数代码示例

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

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



在下文中一共展示了get_context函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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)
开发者ID:dertalai,项目名称:cryptochati,代码行数:27,代码来源:cryptochati.py


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


示例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
开发者ID:Draken98,项目名称:hexchat-addons,代码行数:7,代码来源:treenumbers.py


示例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 
开发者ID:10crimes,项目名称:code,代码行数:8,代码来源:notify_icon.py


示例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
开发者ID:singulared,项目名称:ac100,代码行数:9,代码来源:ac100-flashlight.py


示例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
开发者ID:caretcaret,项目名称:misc,代码行数:13,代码来源:ircbot.py


示例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
开发者ID:caretcaret,项目名称:misc,代码行数:15,代码来源:ircbot.py


示例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()
开发者ID:KnightRobby,项目名称:cancelbot,代码行数:33,代码来源:biblebot.py


示例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
开发者ID:Tatsh,项目名称:xsys,代码行数:28,代码来源:xsys.py


示例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
开发者ID:mozai,项目名称:xchat-scripts,代码行数:28,代码来源:search_youtube_xchat.py


示例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 
开发者ID:10crimes,项目名称:code,代码行数:7,代码来源:notify_icon.py


示例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
开发者ID:0day1day,项目名称:scripts,代码行数:60,代码来源:chatsounds.py


示例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)
开发者ID:KnightRobby,项目名称:cancelbot,代码行数:7,代码来源:weatherbot.py


示例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 + ')') 
开发者ID:MikeEhman,项目名称:GTRPG,代码行数:29,代码来源:GT.py


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


示例16: hwmon

def hwmon(word, word_eol, userdata):
    lm_sensors_info, gpu_temp = sysinfo_hwmon()
    output = []

    if lm_sensors_info is None and gpu_temp is None:
        xchat.prnt('No monitoring sensors detected')
        return xchat.EAT_ALL

    if gpu_temp is not None:
        output.append(u'gpu:: temp0: %d\xb0C' % gpu_temp)

    if lm_sensors_info is not None:
        for device_name in lm_sensors_info:
            temps = lm_sensors_info[device_name]['temps']
            temp_output = []
            i = 0

            if len(temps):
                for temp in temps:
                    add = ('temp%d: %s' % (i, temp)).decode('utf-8')
                    temp_output.append(add)
                    i += 1

                output.append(device_name + ':: ' + ', '.join(temp_output))

    output = '; '.join(output)

    if output:
        dest = xchat.get_context()
        output = 'say %s' % wrap('sensor', output)
        dest.command(output)
    else:
        xchat.prnt('No monitoring sensors detected')

    return xchat.EAT_ALL
开发者ID:Tatsh,项目名称:xsys,代码行数:35,代码来源:xsys.py


示例17: sharedchannels_cb

def sharedchannels_cb(word, word_eol, userdata):
    mynickname = xchat.get_context().get_info("nick")
    excluded_users = [mynickname, 'ChanServ']      # a list of users to ignore, including your nickname(s)
    if len(word) < 2 or word[1][0] != '#':
        usage(); return xchat.EAT_XCHAT
    chan1 = word[1]
    cc = xchat.find_context(channel=chan1)
    if not cc:
        print "Oops - you don't seem to be in channel", chan1
        return xchat.EAT_XCHAT

    chan1server = cc.get_info('server')
    userlist = {}
    for chan in xchat.get_list('channels'):
        if chan.server == chan1server and chan.type == chantype['channel']:
            for user in chan.context.get_list('users'):
                if user.nick not in excluded_users:
                    userlist.setdefault(chan.channel, []).append(user.nick)

    print "###############################################################################"  # 79
    print "# " + ("The users in %s share the following channels with you (%s)" % (chan1, mynickname)).center(79-4) + " #"
    print "###############################################################################"  # 79
    for chan in sorted(userlist.keys()):
        if chan != chan1:
            usersincommon = sorted(set(userlist[chan1]) & set(userlist[chan]))
            if usersincommon:
                print "%15s:\t%s" % (chan, ', '.join(usersincommon))
    print "###############################################################################"  # 79

    return xchat.EAT_XCHAT
开发者ID:Anaerin,项目名称:hexchat-addons,代码行数:30,代码来源:sharedchannels.py


示例18: on_text

def on_text(word, word_eol, userdata):
    if option["service"] != True:
        return
    counter = 0
    destination = xchat.get_context()
    network = destination.get_info('network').lower()
    channel = destination.get_info('channel').lower()
    triggernick = word[0].lower()
    if option["service"] == True and option["relayonly"] == True and triggernick not in option["relaynicks"]:
        return
    
    for badword in option["badwords"]:
        if re.search(badword, word[1], re.I):
            counter += 1
    for relaypair in option["relaypairs"]:
        if relaypair[0] == network and relaypair[1] == channel:
            destination = xchat.find_context(server=relaypair[2], channel=relaypair[3])
            try:
                if counter == 0:
                    for key in option["replacements"].keys():
                        word_eol[1] = string.replace(word_eol[1],key,option["replacements"][key])
                    destination.command("say " + "<"+triggernick+"> " + word_eol[1])
                elif option["relaydefaultmsg"] == True:
                    destination.command("say " + "<"+triggernick+"> " + option["defaultmsg"])
            except AttributeError:
                print color["red"], "It appears you have not joined the relay destination channel", relaypair[3], "on", relaypair[2]
开发者ID:KnightRobby,项目名称:cancelbot,代码行数:26,代码来源:relaybot.py


示例19: checkPrint

def checkPrint(word, word_eol, userdata):
  " if someone says '.giphy', respond like 'found http://blah.gif "
  del(word_eol, userdata)  # shut up, pylint
  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 == '!giphy':
    if not params:
      return xchat.NONE
    if chan in LASTUSED:
      now = time.time()
      if LASTUSED[chan] + TIMEOUT >= now:
        context.command('msg {} "!giphy" on cooldown'.format(word[0]))
      else:
        found = fetchAPIresults(params)
        if found:
          context.command('me found \x1f{}\x0f'.format(found))
        else:
          context.command('me couldn\'t search Giphy')
          print '*** error searching Giphy'
        LASTUSED[chan] = now
    return xchat.EAT_PLUGIN
开发者ID:mozai,项目名称:xchat-scripts,代码行数:25,代码来源:search_giphy_xchat.py


示例20: on_nowplaying

def on_nowplaying(word, word_eol, userdata):
    bus = dbus.SessionBus()
    if bus.name_has_owner('org.mpris.MediaPlayer2.spotify'):
          spotify = bus.get_object('org.mpris.MediaPlayer2.spotify','/org/mpris/MediaPlayer2')
           # Get current channel and get latest track from Spotify
          context = xchat.get_context()
          channel = context.get_info("channel")
          metadatas = dbus.Interface(spotify,'org.freedesktop.DBus.Properties')
          trackinfo = metadatas.Get('org.mpris.MediaPlayer2.Player','Metadata')
          # Get track information from DBus dictionary
          album       = unicode(trackinfo.get("xesam:album")).encode('utf-8')
          title       = unicode(trackinfo.get("xesam:title")).encode('utf-8')       
          trackNumber = str(unicode(trackinfo.get("xesam:trackNumber")).encode('utf-8'))
          discNumber  = str(unicode(trackinfo.get("xesam:discNumber")).encode('utf-8'))
          trackid     = str(unicode(trackinfo.get("xesam:trackid")).encode('utf-8'))
          length      = unicode(trackinfo.get("xesam:length")).encode('utf-8')
          artUrl      = unicode(trackinfo.get("xesam:artUrl")).encode('utf-8')
          url         = unicode(trackinfo.get("xesam:url")).encode('utf-8')
    # The artist list is provided as an array. Combine all artists to a single string.
          artist = str(unicode(", ".join(trackinfo.get("xesam:artist"))).encode('utf-8')).strip()
          npmsg = "Now playing on 02Spotify: %s - %s [%s] (%s)" % (artist, title, album, url)
          xchat.command("msg %s %s" % (channel, npmsg))
          return xchat.EAT_ALL
    else:
          return xchat.EAT_ALL    
开发者ID:Gargadon,项目名称:xchat-spotify-np,代码行数:25,代码来源:xchat-spotify-np.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Python xchat.get_info函数代码示例发布时间:2022-05-26
下一篇:
Python xchat.find_context函数代码示例发布时间: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