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

Python weechat.hook_modifier函数代码示例

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

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



在下文中一共展示了hook_modifier函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: ns_ban_cb

def ns_ban_cb(data, buffer, args):
	args = args.split()
	oper = args[0]
	nick = args[1]

	channel = weechat.buffer_get_string(buffer, 'localvar_channel')
	server = weechat.buffer_get_string(buffer, 'localvar_server')

	if oper == 'ban':
		found = False
		infolist = weechat.infolist_get("irc_nick", "", "{},{},{}".format(server, channel, nick))
		while weechat.infolist_next(infolist):
			found = True
			account = weechat.infolist_string(infolist, "account")
			if account:
				weechat.command("", '/mode +b $a:{}'.format(account))

		weechat.infolist_free(infolist)

		if not found:
			# TODO: Handle numeric 315 too, ‘End of /WHO list’
			hooks['who'] = weechat.hook_modifier("irc_in_354", "who_mod_cb", "")
			weechat.command("", "/who %s n%%an" % args[1])
			operation[nick] = oper

	else:
		# TODO: Handle numeric 315 too, ‘End of /WHO list’
		hooks['who'] = weechat.hook_modifier("irc_in_354", "who_mod_cb", "")
		weechat.command("", "/who %s n%%an" % args[1])

		operation[nick] = oper

	return weechat.WEECHAT_RC_OK
开发者ID:kyrias,项目名称:dotfiles,代码行数:33,代码来源:nsb.py


示例2: main

def main():
    weechat.hook_modifier("irc_in_notice", "modifier_cb", "")
    weechat.hook_completion("bitlbee", "bitlbee completion",
                            "bitlbee_completion", "")

    weechat.hook_print('', 'irc_332', '', 1, 'print_332', '')
    weechat.hook_print('', 'irc_topic', '', 1, 'print_332', '')
    find_buffer()
开发者ID:DarkDefender,项目名称:scripts,代码行数:8,代码来源:bitlbee_completion.py


示例3: enable_capab

def enable_capab(server):
    server_buffer = weechat.buffer_search('irc', 'server.%s' %server)
    if server_buffer:
        weechat.command(server_buffer, '/quote cap req :identify-msg')
        capab_hooks[server] = (
                weechat.hook_modifier('irc_in_PRIVMSG', 'privmsg_signal_cb', server),
                weechat.hook_modifier('irc_in_NOTICE', 'privmsg_signal_cb', server),
        #weechat.hook_signal('%s,irc_in_PART' %server, 'part_signal_cb', server)
        #weechat.hook_signal('%s,irc_in_QUIT' %server, 'quit_signal_cb', server)
                weechat.hook_modifier('weechat_print', 'privmsg_print_cb', server),
                )
        return True
开发者ID:NuclearW,项目名称:weechat-scripts,代码行数:12,代码来源:capab.py


示例4: hook_all

def hook_all(server):
    global HOOKS

    notice = server + '.notice'
    modifier = server + '.modifier'
    modifier2 = server + '.modifier2'

    if notice not in HOOKS:
        HOOKS[notice] = weechat.hook_signal("%s,irc_raw_in_notice" % server, "auth_success_cb", server)
    if modifier not in HOOKS:
        HOOKS[modifier] = weechat.hook_modifier("irc_out_privmsg", "totp_login_modifier_cb", server)
    if modifier2 not in HOOKS:
        HOOKS[modifier2] = weechat.hook_modifier("irc_out_pass", "totp_login_modifier_cb", server)
开发者ID:Shrews,项目名称:scripts,代码行数:13,代码来源:undernet_totp.py


示例5: main

def main():
    hook = weechat.hook_modifier('weechat_print', 'unhighlight_cb', '')

    description = """
{script_name} lets you set up a regex for things to never highlight.

To use this, set the localvar 'unhighlight_regex' on a buffer. Lines in
that buffer which match will never be highlighted, even if they have
your nick or match highlight_words or highlight_regex.

You will need the script 'buffer_autoset.py' installed to make local
variables persistent; see the examples below.

Examples:
 Temporarily block highlights in the current buffer for lines matching 'banana':
   /buffer set localvar_set_unhighlight_regex banana
 Unhighlight SASL authentication messages for double logins:
   /buffer weechat
   /buffer set localvar_set_unhighlight_regex SaslServ
   /autosetbuffer add core.weechat localvar_set_unhighlight_regex SaslServ
 List buffers with autoset unhighlights:
   /{script_name} list
 Show this help:
   /{script_name}
 Display local variables for current buffer:
   /buffer localvar
""".format(script_name = SCRIPT_NAME)

    weechat.hook_command(SCRIPT_NAME, SCRIPT_DESC, 'list', description, 'list %-', 'command_cb', '')
开发者ID:Zarthus,项目名称:scripts,代码行数:29,代码来源:unhighlight.py


示例6: hook_all

def hook_all():
    """ Hook command_run and modifier """
    global hook_command_run, hooks
    for hook, value in hook_command_run.iteritems():
        if hook not in hooks:
            hooks[hook] = weechat.hook_command_run(value[0], value[1], "")
    if "modifier" not in hooks:
        hooks["modifier"] = weechat.hook_modifier("input_text_display_with_cursor", "input_modifier", "")
开发者ID:ronin13,项目名称:seed,代码行数:8,代码来源:go.py


示例7: init

	def init(self):
		if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
			global SAVEPATH
			SAVEPATH = os.path.join(weechat.info_get('weechat_dir',''),'darktower','adfilter')
			if not os.path.exists(SAVEPATH): os.makedirs(SAVEPATH)
			self.saveFile = os.path.join(SAVEPATH,'adfilter.DT')
			self.exceptFile = os.path.join(SAVEPATH,'AFexceptions.DT')
		
			weechat.hook_command("adfilter", "Dark Tower AdFilter Commands",
				"[COMMANDS]",
				"[COMMANDS DETAIL]",
				"[COMPLETION]",
				"AdFilter", "command_cb:")
			
			weechat.hook_modifier("irc_in_PRIVMSG", "AdFilter","privmsg_event:")
			
		self.loadAds()
		self.loadExceptions()
开发者ID:ruuk,项目名称:dark.tower.fserve,代码行数:18,代码来源:adfilter.py


示例8: ircrypt_init

def ircrypt_init():
	# Initialize configuration
	ircrypt_config_init()
	ircrypt_config_read()
	# Look for GnuPG binary
	if weechat.config_string(weechat.config_get('ircrypt.general.binary')):
		# Initialize public key authentification
		ircrypt_gpg_init()
		# Register Hooks
		weechat.hook_modifier('irc_in_notice', 'ircrypt_notice_hook', '')
		weechat.hook_command('ircrypt-keyex', 'Commands of the Addon IRCrypt-keyex',
				'[list] '
				'| remove-public-key [-server <server>] <nick> '
				'| start [-server <server>] <nick> ',
				SCRIPT_HELP_TEXT,
				'list '
				'|| remove-public-key %(nicks)|-server %(irc_servers) %- '
				'|| start %(nicks)|-server %(irc_servers) %- ',
				'ircrypt_command', '')
	else:
		ircrypt.ircrypt_error('GnuPG not found', weechat.current_buffer())
开发者ID:petvoigt,项目名称:ircrypt-weechat,代码行数:21,代码来源:ircrypt-keyex.py


示例9: hook_modifiers

def hook_modifiers():
	"""Update modifier hooks to match settings."""

	# remove existing modifier hooks
	global hooks
	for hook in hooks:
		weechat.unhook(hook)
	hooks = []

	# add hooks according to settings

	input_option = weechat.config_get_plugin("input")
	if weechat.config_string_to_boolean(input_option):
		hooks.append(weechat.hook_modifier("input_text_display", "modifier_cb", ""))

	send_option = weechat.config_get_plugin("send")
	if weechat.config_string_to_boolean(send_option):
		hooks.append(weechat.hook_modifier("input_text_for_buffer", "modifier_cb", ""))

	buffer_option = weechat.config_get_plugin("buffer")
	if weechat.config_string_to_boolean(buffer_option):
		hooks.append(weechat.hook_modifier("weechat_print", "modifier_cb", ""))
开发者ID:DarkDefender,项目名称:scripts,代码行数:22,代码来源:latex_unicode.py


示例10: hook_all

def hook_all():
    """ Hook command_run and modifier """
    global hook_command_run, hooks
    priority = ""
    version = weechat.info_get("version_number", "") or 0
    # use high priority for hook to prevent conflict with other plugins/scripts
    # (WeeChat >= 0.3.4 only)
    if int(version) >= 0x00030400:
        priority = "2000|"
    for hook, value in hook_command_run.items():
        if hook not in hooks:
            hooks[hook] = weechat.hook_command_run("%s%s" % (priority, value[0]), value[1], "")
    if "modifier" not in hooks:
        hooks["modifier"] = weechat.hook_modifier("input_text_display_with_cursor", "input_modifier", "")
开发者ID:thisismiller,项目名称:dotfiles,代码行数:14,代码来源:go.py


示例11: quit_event

def quit_event(data, signal, signal_data):
	if (check_split(signal_data)):
		weechat.prnt("", "Netsplit? YES - %s" % signal_data)
		strip_string = signal_data
			# Create functions to:
			# Add user/host details to a dictionary to wait for their return
			# Stop the line from appearing in the channel's buffer
			# Count total number of splits
			# Print number of splits and the affected host to the channel's buffer
	else:
		weechat.prnt("", "Netsplit? NO - %s" % signal_data)
		#strip_string = signal_data
		# Check for user/host returning from a split (details will be contained in the dictionary)
		# TODO - Move the following hook so that it only blocks QUITS when they are net splits
	print_hook = weechat.hook_modifier("weechat_print", "strip_print", "")        # Replace string printed to buffer with "" <--- HACKY	
	return weechat.WEECHAT_RC_OK
开发者ID:dregin,项目名称:Weechat-Scripts,代码行数:16,代码来源:split_squash.py


示例12: cmd_help_toggle

def cmd_help_toggle():
    """Toggle help on/off."""
    global cmdhelp_hooks, cmdhelp_settings
    if cmdhelp_hooks['modifier']:
        unhook(('timer', 'modifier'))
    else:
        cmdhelp_hooks['modifier'] = weechat.hook_modifier(
            'input_text_display_with_cursor', 'input_modifier_cb', '')
        timer = cmdhelp_settings['timer']
        if timer and timer != '0':
            try:
                value = float(timer)
                if value > 0:
                    weechat.hook_timer(value * 1000, 0, 1, 'timer_cb', '')
            except ValueError:
                pass
    weechat.bar_item_update('input_text')
开发者ID:DarkDefender,项目名称:scripts,代码行数:17,代码来源:cmd_help.py


示例13: go_hook_all

def go_hook_all():
    """Hook command_run and modifier."""
    global hooks
    priority = ''
    version = weechat.info_get('version_number', '') or 0
    # use high priority for hook to prevent conflict with other plugins/scripts
    # (WeeChat >= 0.3.4 only)
    if int(version) >= 0x00030400:
        priority = '2000|'
    for hook, value in HOOK_COMMAND_RUN.items():
        if hook not in hooks:
            hooks[hook] = weechat.hook_command_run(
                '%s%s' % (priority, value[0]),
                value[1], '')
    if 'modifier' not in hooks:
        hooks['modifier'] = weechat.hook_modifier(
            'input_text_display_with_cursor', 'go_input_modifier', '')
开发者ID:gilbertw1,项目名称:scripts,代码行数:17,代码来源:go.py


示例14: transform_message

    if 'irc_privmsg' in tags:
        message = transform_message(message)
    elif 'irc_notice' in tags:
        target, msg = re.search(NOTICE_PATTERN, message).groups()
        msg = transform_message(msg)
        message = target+msg

    return message


def list_icons_cb(data, buf, args):
    global ICONS

    l = dict()
    for key, val in ICONS.items():
        if val in l:
            l[val] += ", " + key
        else:
            l[val] = key

    weechat.prnt(buf, "%s - list of supported emoticons:" % SCRIPT_NAME)
    [weechat.prnt(buf, " %s  = %s" % (key.encode('utf-8'), l[key])) for key in l.keys()]

    return weechat.WEECHAT_RC_OK


if __name__ == "__main__" and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        weechat.hook_modifier('weechat_print', 'convert_icon_cb', '')
        weechat.hook_command(SCRIPT_COMMAND, "List supported emoticons", "", "", "", "list_icons_cb", "")
开发者ID:KokaKiwi,项目名称:weechat-scripts,代码行数:30,代码来源:weemoticons.py


示例15: encode_beepboop

    msgprefix = ""
    if aftermsg != msgmsg:
        msgprefix = "[BEEPBOOP]: "

    return ":%s PRIVMSG %s :%s%s" % (msgwho, msgwhere, msgprefix, aftermsg)

def encode_beepboop(text):
    res = ""

    text = text.upper()
    for c in text:
        if c == " ":
            res += word_sep
            continue
        if c in morse:
            res += morse[c]
            res += char_sep
    return res

def beepboop_cb(data, buffer, args):
    weechat.command(buffer, encode_beepboop(args))
    return weechat.WEECHAT_RC_OK

weechat.hook_modifier("irc_in_privmsg", "privmsg_mod_cb", "")
weechat.hook_command("beepboop", "converts text to beep boop language",
        "<msg>",
        "The message to convert to message",
        "%(filters_names)",
        "beepboop_cb", "")
开发者ID:aeruder,项目名称:weechat-beepboop,代码行数:29,代码来源:beepboop.py


示例16:

    for tag in tags:
        if tag[:5] == "nick_":
            nick = tag[5:]
            break
    if not nick:
        return string

    # handle service notices
    if re.search(SERVICE, nick):
        # remove color and excess whitespace
        sstring = " ".join(weechat.string_remove_color(string, "").split())

        for pattern, replacement in SERVICEPATTERNS:
            m = re.match(pattern, sstring)
            if m:
                return replacement.format(*m.groups())

    # handle snotices
    if re.search(SERVER, nick):
        # remove color and excess whitespace
        sstring = " ".join(weechat.string_remove_color(string, "").split())

        for pattern, replacement in SERVERPATTERNS:
            m = re.match(pattern, sstring)
            if m:
                return replacement.format(*m.groups())

    return string

weechat.hook_modifier("weechat_print", "modifier_cb", "")
开发者ID:PaulSalden,项目名称:weechat-scripts,代码行数:30,代码来源:operformat.py


示例17: len

    if mask == '':
        return False
    if mask[0] == '*' and mask[-1] == '*':
        return value.find(mask[1:-1]) > -1
    if mask[0] == '*':
         index = value.rfind(mask[1:])
         return len(value[index:]) == len(mask[1:])
    if mask[-1] == '*':
        return value.find(mask[:-1]) == 0
    return value == mask

if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
    for option, default_value in settings.iteritems():
        if not w.config_is_set_plugin(option):
            w.config_set_plugin(option, default_value)
    
    w.hook_command(SCRIPT_COMMAND,
                   "Show or hide nicklist on some buffers",
                   "[show|hide|add|remove]",
                   "  show: show nicklist for buffers in list (hide nicklist for other buffers by default)\n"
                   "  hide: hide nicklist for buffers in list (show nicklist for other buffers by default)\n"
                   "   add: add current buffer to list\n"
                   "remove: remove current buffer from list\n\n"
                   "Instead of using add/remove, you can set buffers list with: "
                   "/set plugins.var.python.%s.buffers \"xxx\". Buffers set in this "
                   "manner can start or end with * as wildcards to match multiple buffers."
                   % SCRIPT_NAME,
                   "show|hide|add|remove",
                   "nicklist_cmd_cb", "")
    w.hook_modifier('bar_condition_nicklist', 'check_nicklist_cb', '')
开发者ID:bradfier,项目名称:configs,代码行数:30,代码来源:toggle_nicklist.py


示例18: len

    password = weechat.config_get_plugin('password')
    service  = weechat.config_get_plugin('service')
    scheme   = weechat.config_get_plugin('scheme')

    if len(username) == 0 or len(password) == 0:
        weechat.prnt(weechat.current_buffer(),
                    '%s[%s] Please set your username and password and reload the plugin to get the /sn commands working' %
                    (weechat.prefix('error'), service))
    else:
        statusnet_handler = StatusNet(username, password, scheme, service)

        if weechat.config_get_plugin('prepopulate') == 'on':
            populate_subscriptions()

    # hook incoming messages for parsing
    weechat.hook_modifier('weechat_print', 'parse_in', '')
    # hook outgoing messages for nick completion
    weechat.hook_modifier('irc_out_privmsg', 'parse_out', '')

    # /sn
    weechat.hook_command('sn',
                         'StatusNet manager',
                         'whois | subscribe | unsubscribe | block | unblock | updates | groups <username> || group | join | leave <group>',
                         '        whois: retrieves profile information from <username>'
                         "\n"
                         '    subscribe: subscribes to <username>'
                         "\n"
                         '  unsubscribe: unsubscribes from <username>'
                         "\n"
                         '        block: blocks <username>'
                         "\n"
开发者ID:s5unty,项目名称:dotfiles,代码行数:31,代码来源:tweetim.py


示例19: incoming_hook

octet = r'(?:2(?:[0-4]\d|5[0-5])|1\d\d|\d{1,2})'
ipAddr = r'%s(?:\.%s){3}' % (octet, octet)
# Base domain regex off RFC 1034 and 1738
label = r'[0-9a-z][-0-9a-z]*[0-9a-z]?'
domain = r'%s(?:\.%s)*\.[a-z][-0-9a-z]*[a-z]?' % (label, label)
urlRe = re.compile(r'(\w+://(?:%s|%s)(?::\d+)?(?:/[^\])>\s]*)?)' % (domain, ipAddr), re.I)


if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                    SCRIPT_DESC, "", ""):

    for option, default_value in settings.iteritems():
        if weechat.config_get_plugin(option) == "":
            weechat.config_set_plugin(option, default_value)

    weechat.hook_modifier("weechat_print", "incoming_hook", "")
    weechat.hook_modifier("irc_out_privmsg", "outgoing_hook", "")

def incoming_hook(data, modifier, modifier_data, string):
    return short_all_url(string, True)

def outgoing_hook(data, modifier, modifier_data, string):
    return short_all_url(string, False)

def short_all_url(string, use_color):
    new_message = string
    color = weechat.color(weechat.config_get_plugin("color"))
    reset = weechat.color('reset')
    for url in urlRe.findall(string):
        if len(url) > int(weechat.config_get_plugin('urllength')) and not ignore_url(url):
            short_url = tiny_url(url)
开发者ID:WnP,项目名称:shorten_url,代码行数:31,代码来源:shorten_url.py


示例20: config_setup

        "  If you are experiencing errors you can enable debug mode by setting\n"
        "    /set plugins.var.python.twitch.debug on\n"
        "  You can also try disabling SSL/TLS cert verification.\n"
        "    /set plugins.var.python.twitch.ssl_verify off\n"
        "\n\n"
        "  Required server settings:\n"
        "    /server add twitch irc.twitch.tv\n"
        "    /set irc.server.twitch.capabilities \"twitch.tv/membership,twitch.tv/commands,twitch.tv/tags\"\n"
        "    /set irc.server.twitch.nicks \"My Twitch Username\"\n"
        "    /set irc.server.twitch.password \"oauth:My Oauth Key\"\n"
        "\n"
        "  If you do not have a oauth token one can be generated for your account here\n"
        "    https://twitchapps.com/tmi/\n"
        "\n"
        "  This script also has whisper support that works like a standard query. \"/query user\"\n\n",
        "", "twitch_main", "")
    weechat.hook_signal('buffer_switch', 'twitch_buffer_switch', '')
    weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'config_change', '')
    config_setup()
    weechat.hook_modifier("irc_in_CLEARCHAT", "twitch_clearchat", "")
    weechat.hook_modifier("irc_in_CLEARMSG", "twitch_clearmsg", "")
    weechat.hook_modifier("irc_in_RECONNECT", "twitch_reconnect", "")
    weechat.hook_modifier("irc_in_USERSTATE", "twitch_suppress", "")
    weechat.hook_modifier("irc_in_HOSTTARGET", "twitch_suppress", "")
    weechat.hook_modifier("irc_in_ROOMSTATE", "twitch_roomstate", "")
    weechat.hook_modifier("irc_in_USERNOTICE", "twitch_usernotice", "")
    weechat.hook_modifier("irc_in_WHISPER", "twitch_whisper", "")
    weechat.hook_modifier("irc_out_PRIVMSG", "twitch_privmsg", "")
    weechat.hook_modifier("irc_out_WHOIS", "twitch_whois", "")
    weechat.hook_modifier("irc_in_PRIVMSG", "twitch_in_privmsg", "")
开发者ID:MatthewCox,项目名称:dotfiles,代码行数:30,代码来源:twitch.py



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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