Exemplo n.º 1
0
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
Exemplo n.º 2
0
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()
Exemplo n.º 3
0
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()
Exemplo n.º 4
0
def main():
    check_config()
    weechat.hook_modifier("irc_in_notice", "modifier_cb", "")
    weechat.hook_completion(TEMPLATE_NAME, "TAB completion to bitlbee",
                            "completion_cb", "")

    weechat.hook_print('', 'irc_332', '', 1, 'print_cb', '')
    weechat.hook_print('', 'irc_topic', '', 1, 'print_cb', '')
    find_buffer()
Exemplo n.º 5
0
    def add_command(self):
        """Add command and create callbacks."""
        name = "confload"
        desc = "Load $WEECHAT_HOME/weechatrc. Expects KeePassXC passphrase"
        args = "<passphrase>"

        w.hook_command(name, desc, args, '', '',
                       self.callback(self.command_cb), '')
        w.hook_modifier("input_text_display",
                        self.callback(self.passwd_conceil_cb), "")
Exemplo n.º 6
0
 def initialize(self):
     """Create hooks to grab all user input to obtain KeePassXC password."""
     w.config_set_desc_plugin(
         self.option,
         "If not yet initialized, run once. (default: \"off\")")
     self.passwd_conceil_hook = w.hook_modifier(
         "input_text_display_with_cursor",
         self.callback(self.passwd_conceil_cb), "")
     self.passwd_grab_hook = w.hook_modifier(
         "input_text_for_buffer", self.callback(self.passwd_grab_cb), "")
Exemplo n.º 7
0
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
Exemplo n.º 8
0
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)
Exemplo n.º 9
0
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
Exemplo n.º 10
0
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
   /buffer_autoset 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', '')
Exemplo n.º 11
0
def install_hooks():
    HOOKS.extend([
        wc.hook_command_run("%d|%s" % (HOOK_PRIORITY, "/input *"),
                            "input_hook", ""),
        wc.hook_modifier("%d|%s" % (HOOK_PRIORITY, "input_text_display_with_cursor"),
                              "modifier_hook", "")
    ]) # yapf: disable
Exemplo n.º 12
0
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', '')
Exemplo n.º 13
0
Arquivo: go.py Projeto: ronin13/seed
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", "")
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)
Exemplo n.º 15
0
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] = w.hook_command_run(value[0], value[1], "")
    if "modifier" not in hooks:
        hooks["modifier"] = w.hook_modifier(
            "input_text_display_with_cursor", "input_modifier", "")
Exemplo n.º 16
0
	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()
Exemplo n.º 17
0
def main():
    """Initialisation."""
    register(_name, _author, _version, _license, _description, '', '')

    if not _config():
        return

    _init_cache()

    hook_signal('*,irc_in2_join', 'join_cb', '')
    hook_signal('*,irc_in2_344', 'list_cb', '')
    hook_signal('*,irc_in2_346', 'list_cb', '')
    hook_signal('*,irc_in2_mode', 'mode_cb', '')

    hook_modifier('weechat_print', 'modifier_cb', '')

    hook_command('reop', '{}\n\n{}'.format(_description, __doc__),
                 'list | reload', '', '', 'command_cb', '')
Exemplo n.º 18
0
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())
Exemplo n.º 19
0
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", ""))
Exemplo n.º 20
0
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", ""))
Exemplo n.º 21
0
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", "")
Exemplo n.º 22
0
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", "")
Exemplo n.º 23
0
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', '')
Exemplo n.º 24
0
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
Exemplo n.º 25
0
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:
                pass
    weechat.bar_item_update('input_text')
Exemplo n.º 26
0
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', '')
Exemplo n.º 27
0
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')
Exemplo n.º 28
0
            "| remove [-server <server>] <target> "
            "| exchange [-server <server>] [<nick>]",
            "Add, change or remove key for target or perform DH1080 key"
            "exchange with <nick>.\n"
            "Target can be a channel or a nick.\n"
            "\n"
            "Without arguments this command lists all keys.\n"
            "\n"
            "Examples:\n"
            "Set the key for a channel: /blowkey set -server freenet #blowfish key\n"
            "Remove the key:            /blowkey remove #blowfish\n"
            "Set the key for a query:   /blowkey set nick secret+key\n"
            "List all keys:             /blowkey\n"
            "DH1080:                    /blowkey exchange nick\n"
            "\nPlease read the source for a note about DH1080 key exchange\n",
            "list || set %(irc_channel)|%(nicks)|-server %(irc_servers) %- "
            "|| remove %(irc_channel)|%(nicks)|-server %(irc_servers) %- "
            "|| exchange %(nick)|-server %(irc_servers) %-",
            "fish_cmd_blowkey", "")

    fish_config_init()
    fish_config_read()

    weechat.hook_modifier("irc_in_notice", "fish_modifier_in_notice_cb", "")
    weechat.hook_modifier("irc_in_privmsg", "fish_modifier_in_privmsg_cb", "")
    weechat.hook_modifier("irc_in_topic", "fish_modifier_in_topic_cb", "")
    weechat.hook_modifier("irc_in_332", "fish_modifier_in_332_cb", "")
    weechat.hook_modifier("irc_out_privmsg", "fish_modifier_out_privmsg_cb",
            "")
    weechat.hook_modifier("irc_out_topic", "fish_modifier_out_topic_cb", "")
Exemplo n.º 29
0
    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"
Exemplo n.º 30
0
            SCRIPT_DESC,
            """""",  # TODO
            """Prepend to weechat.bar.buflist.items:
    go_buflist,

Append to buflist.look.display_conditions:
    && ${buffer.local_variables.go_buflist_hidden}==0

Prepend to buflist.format.buffer:
    ${eval:${plugins.var.python.go_buflist.format}}""",  # TODO
            """""".replace("\n", ""),  # TODO
            "command_cb",
            "")

        weechat.bar_item_new("(extra)%s" % SCRIPT_BAR_ITEM, "bar_item_cb", "")

        weechat.hook_command_run("/input *", "command_run_input_cb", "")
        weechat.hook_modifier("input_text_display_with_cursor",
                              "input_text_display_with_cursor_cb", "")

        for option, value in SETTINGS.items():
            if not weechat.config_is_set_plugin(option):
                weechat.config_set_plugin(option, value[0])

            weechat.config_set_desc_plugin(
                option, "%s (default: \"%s\")" % (value[1], value[0]))

        weechat.key_bind("default", KEYS)

        set_localvars("")
Exemplo n.º 31
0
            "Without arguments this command lists all keys.\n"
            "\n"
            "Examples:\n"
            "Set the key for a channel: /blowkey set -server freenet #blowfish key\n"
            "Remove the key:            /blowkey remove #blowfish\n"
            "Set the key for a query:   /blowkey set nick secret+key\n"
            "List all keys:             /blowkey\n\n"
            "\n** stores keys in plaintext by default **\n\n"
            "DH1080:                    /blowkey exchange nick\n"
            "DH1080 (no CBC):           /blowkey exchange -ecb nick\n"
            "\nPlease read the source for a note about DH1080 key exchange\n",
            "list"
            "|| genkey"
            "|| set %(irc_channel)|%(nicks)|-server %(irc_servers) %- "
            "|| remove %(irc_channel)|%(nicks)|-server %(irc_servers) %- "
            "|| exchange %(nick)|-server %(irc_servers) %-|-ecb",
            "fish_cmd_blowkey", "")

    fish_config_init()
    fish_config_read()
    fish_secure()

    weechat.hook_modifier("irc_in_notice", "fish_modifier_in_notice_cb", "")
    weechat.hook_modifier("irc_in_privmsg", "fish_modifier_in_privmsg_cb", "")
    weechat.hook_modifier("irc_in_topic", "fish_modifier_in_topic_cb", "")
    weechat.hook_modifier("irc_in_332", "fish_modifier_in_332_cb", "")
    weechat.hook_modifier("irc_out_privmsg", "fish_modifier_out_privmsg_cb", "")
    weechat.hook_modifier("irc_out_topic", "fish_modifier_out_topic_cb", "")
    weechat.hook_modifier("input_text_for_buffer", "fish_modifier_input_text", "")
    weechat.hook_config("fish.secure.key", "fish_secure_key_cb", "")
Exemplo n.º 32
0
  urls = re.findall('[a-z]{2,5}://[^\s()\[\]]*', string)
  for url in urls:
    color = weechat.color(weechat.config_get_plugin("color"))
    reset = weechat.color('reset')
    urllength = int(weechat.config_get_plugin('urllength'))
    if len(url) < urllength:
      color_url = "{color}{url}{reset}".format(color=color, url=url, reset=reset)
      string = re.sub(re.escape(url), color_url, string)
    else:
      buffer = getbuffer(modifier_data, string)
      shorten(buffer, url)
  return string

if __name__ == "__main__":
  if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "end_script", ""):
    weechat.hook_modifier("irc_in2_privmsg", "modifier_cb", "")
    weechat.hook_command("shortenurl", "Shortens a url and prints it to your current buffer.", "[<URL...>]",
      "         URL: URL to shorten (multiple URLs may be given)\n", "", "shortenurl", "");

    settings = {
      'shortener': ('is.gd', 'URL Shortener to use. (is.gd, v.gd, rldn.net)'),
      'urllength': ('40', 'Max length of url before shortening.'),
      'color': ('lightblue', 'Color for all urls.'),
    }

    version = weechat.info_get('version_number', '')
    for option, default_desc in settings.iteritems():
      if not weechat.config_is_set_plugin(option):
        weechat.config_set_plugin(option, default_desc[0])
      if int(version) >= 0x00030500:
        weechat.config_set_desc_plugin(option, default_desc[1])
Exemplo n.º 33
0
    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', '')
Exemplo n.º 34
0
            out = _format_action(server, chan, nick, text)
            w.prnt(buff, out)
            return ""

    return line


def on_command(data, buffer, args):
    server = w.buffer_get_string(buffer, 'localvar_server')
    if args.count(" ") > 0:
        target, _, message = args.partition(" ")
        if target[0] in _statusmsg(server):
            buff = w.buffer_search("irc", f"{server}.{target[1:]}")
            if buff:
                nick = w.info_get("irc_nick", server)
                out = _format_action(server, target, nick, message)
                w.prnt(buff, out)
                w.command(
                    buff, f"/quote PRIVMSG {target} :\x01ACTION {message}\x01")
        else:
            buff = w.buffer_search("irc", f"{server}.{target}")
            if buff:
                w.command(buff, f"/me {message}")
    return w.WEECHAT_RC_OK


if import_ok and w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                            SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
    w.hook_modifier("irc_in2_privmsg", "modify_privmsg", "")
    w.hook_command("action", '', '', '', '', "on_command", '')
Exemplo n.º 35
0
    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", "")
Exemplo n.º 36
0
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
#

# This script uses fribidi library to display rtl text properly

import weechat
from pyfribidi import log2vis, LTR

SCRIPT_NAME = "biditext"
SCRIPT_AUTHOR = "Oscar Morante <*****@*****.**>"
SCRIPT_VERSION = "1"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "Use fribidi to handle RTL text"


def biditext_cb(data, modifier, modifier_data, line):
    return log2vis(line, LTR)


if __name__ == "__main__":
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        weechat.hook_modifier('weechat_print', 'biditext_cb', '')
Exemplo n.º 37
0
def get_nick_group(buffer, group_name):
    group = w.nicklist_search_group(buffer, "", group_name)
    if not group:
        group = w.nicklist_add_group(buffer, "", group_name,
                                     "weechat.color.nicklist_group", 1)
    return group


def nicklist_nick_added_cb(data, signal, buffer):
    group = get_nick_group(buffer, 'bot2human')

    return w.WEECHAT_RC_OK


if __name__ == '__main__':
    w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
               SCRIPT_DESC, "", "")

    parse_config()

    w.hook_modifier("irc_in_privmsg", "msg_cb", "")
    w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")

    # Glowing Bear will choke if a nick is added into a newly created group.
    # As a workaround, we add the group as soon as possible BEFORE Glowing Bear loads groups,
    # and we must do that AFTER EVERY nicklist reload. nicklist_nick_added satisfies both.
    # TODO(quietlynn): Find better signals to hook instead.
    w.hook_signal("nicklist_nick_added", "nicklist_nick_added_cb", "")

# vim: ts=4 sw=4 sts=4 expandtab
Exemplo n.º 38
0
        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|toggle|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"
        "toggle: show/hide nicklist for buffers in list\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|toggle|add|remove", "nicklist_cmd_cb", "")
    w.hook_modifier('bar_condition_nicklist', 'check_nicklist_cb', '')
Exemplo n.º 39
0

# register script with weechat, set config
if __name__ == "__main__":
    try:
        import weechat
        if weechat.register(
                SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                SCRIPT_LICENSE, SCRIPT_DESC, "", "UTF-8"):
            weechat_dir = weechat.info_get("weechat_dir", "")
            version = weechat.info_get("version_number", "") or 0
            if int(version) < 0x00030000:
                weechat.prnt("", "%s%s: WeeChat 0.3.0 is"
                                 " required for this script."
                             % (weechat.prefix("error"), SCRIPT_NAME))

            else:
                for option, default_value in script_options.iteritems():
                    if not weechat.config_is_set_plugin(option):
                        weechat.config_set_plugin(option, default_value)

                weechat.hook_modifier("irc_in_privmsg",
                                      "weechat_msg_decrypt", "")
                weechat.hook_modifier("irc_out_privmsg",
                                      "weechat_msg_encrypt", "")
    except ImportError:
        # not running under Weechat, run a simple test instead
        print "Running simple tests"
        # TODO: run some simple tests
        pass
Exemplo n.º 40
0
    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"
Exemplo n.º 41
0
    """Create the OTR subdirectory in the WeeChat config directory if it does
    not exist."""
    if not os.path.exists(OTR_DIR):
        weechat.mkdir_home(OTR_DIR_NAME, 0700)


if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENCE,
                    SCRIPT_DESC, 'shutdown', ''):
    init_config()

    OTR_DIR = os.path.join(info_get('weechat_dir', ''), OTR_DIR_NAME)
    create_dir()

    ACCOUNTS = AccountDict()

    weechat.hook_modifier('irc_in_privmsg', 'message_in_cb', '')
    weechat.hook_modifier('irc_out_privmsg', 'message_out_cb', '')

    weechat.hook_command(
        SCRIPT_NAME, SCRIPT_HELP, 'start [NICK SERVER] || '
        'finish [NICK SERVER] || '
        'smp ask NICK SERVER SECRET [QUESTION] || '
        'smp respond NICK SERVER SECRET || '
        'trust [NICK SERVER] || '
        'policy [POLICY on|off]', '', 'start %(nick) %(irc_servers) %-||'
        'finish %(nick) %(irc_servers) %-||'
        'smp ask|respond %(nick) %(irc_servers) %-||'
        'trust %(nick) %(irc_servers) %-||'
        'policy %(otr_policy) on|off %-||', 'command_cb', '')

    weechat.hook_completion('otr_policy', 'OTR policies',
Exemplo n.º 42
0
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 find_and_process_urls(string)


def outgoing_hook(data, modifier, modifier_data, string):
    return find_and_process_urls(string, use_color=False)


def find_and_process_urls(string, use_color=True):
    new_message = string
    color = weechat.color(weechat.config_get_plugin("color"))
    reset = weechat.color('reset')
Exemplo n.º 43
0
                weechat.config_set_plugin(option, value[0])
                twitch_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(option, value[1] + " ( default: " + value[0] + ")")
        user_self["name"] = weechat.config_string(
            weechat.config_get("irc.server." + twitch_settings["group_server"] + ".nicks")
        ).split(",", 1)[0]
        user_self["display_name"] = user_self["name"]
        user_self["color"] = weechat.config_string(weechat.config_get("weechat.color.chat_nick_self"))
        user_self["channels"]["#" + user_self["name"]] = {"user_type": "broadcaster"}
        users[user_self["name"]] = user_self

        # Detect config changes
        weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "handle_config_change", "")

        weechat.hook_modifier("irc_in_whisper", "handle_whisper", "")
        weechat.hook_modifier("irc_in_globaluserstate", "handle_globaluserstate", "")
        weechat.hook_modifier("irc_in_userstate", "handle_userstate", "")
        weechat.hook_modifier("irc_in_roomstate", "handle_roomstate", "")
        # Signals don't work because it doesn't send tags
        weechat.hook_modifier("irc_in_privmsg", "handle_privmsg", "twitch")
        weechat.hook_command(
            "3000|whisper",
            "Send a Twitch.TV whisper to a user",
            "<user> <message>",
            "   user: Send to this user\n" "message: Send this message",
            "%(irc_server_nicks)",
            "handle_whisper_command",
            "",
        )
        weechat.hook_command(
Exemplo n.º 44
0
if __name__ == '__main__':
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR,
                        SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):

        WEECHAT_DIR = weechat.info_get("weechat_dir", "")
        WEECHAT_VERSION = weechat.info_get("version_number", "") or 0

        config = Config(
            'whitelist',
            'whitelist_config_reload_cb',
            '')
        if config.is_ok():
            config.read()

        weechat.hook_modifier(
            "irc_in_privmsg",
            "whitelist_privmsg_modifier_cb",
            "")
        weechat.hook_command(
            SCRIPT_COMMAND,
            "Manage the whitelist",
            # OPTION ARGUMENTS
            "list"
            " || add <type> <arg>"
            " || del <type> <arg>",
            # ARGUMENT DESCRIPTIONS
            "      list: lists whitelists and their contents\n"
            "       add: add an entry to a given whitelist\n"
            "       del: delete an entry from a given whitelist\n"
            "\n"
            "Examples:\n"
            "  Add entries to whitelist:\n"
Exemplo n.º 45
0
    weechat.prnt("", "Authenticating as {}...".format(username))
    weechat.command(server_buffer, "/quote PRIVMSG {} :CHALLENGE".format(qbot_user))

    return weechat.WEECHAT_RC_OK


if __name__ == "__main__" and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, SCRIPT_CLOSE_CB, ""):

        for option, (default_value, description) in OPTIONS.items():
            description = add_default_value_to(description, default_value)
            weechat.config_set_desc_plugin(option, description)
            if not weechat.config_is_set_plugin(option):
                weechat.config_set_plugin(option, default_value)

        requests = {}
        qbot_user = weechat.config_get_plugin('challengeauth_qbot_user')
        qbot_host = weechat.config_get_plugin('challengeauth_qbot_host')

        weechat.hook_command(SCRIPT_COMMAND,
                             SCRIPT_DESC,
                             SCRIPT_ARGS,
                             "",
                             "",
                             "challengeauth",
                             "",
                             )

        weechat.hook_modifier("irc_in_notice", "challenge_notice", "")
Exemplo n.º 46
0
    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", "")
Exemplo n.º 47
0
					'this. Please install GnuPG or set the path to the binary to '
					'use.', '')
		else:
			ircrypt_info('Found %s' % version, '')
			weechat.config_option_set(cfg_option, gnupg, 1)


# register plugin
if __name__ == '__main__' and weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR,
		SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, 'ircrypt_unload_script',
		'UTF-8'):
	# register the modifiers
	ircrypt_config_init()
	ircrypt_config_read()
	ircrypt_check_binary()
	weechat.hook_modifier('irc_in_privmsg',  'ircrypt_decrypt_hook', '')
	weechat.hook_modifier('irc_out_privmsg', 'ircrypt_encrypt_hook', '')

	weechat.hook_command('ircrypt', 'Commands to manage IRCrypt options and execute IRCrypt commands',
			'[list]'
			'| set-key [-server <server>] <target> <key> '
			'| remove-key [-server <server>] <target> '
			'| set-cipher [-server <server>] <target> <cipher> '
			'| remove-cipher [-server <server>] <target> '
			'| plain [-server <server>] [-channel <channel>] <message>',
			SCRIPT_HELP_TEXT,
			'list || set-key %(irc_channel)|%(nicks)|-server %(irc_servers) %- '
			'|| remove-key %(irc_channel)|%(nicks)|-server %(irc_servers) %- '
			'|| set-cipher %(irc_channel)|-server %(irc_servers) %- '
			'|| remove-cipher |%(irc_channel)|-server %(irc_servers) %- '
			'|| plain |-channel %(irc_channel)|-server %(irc_servers) %-',
Exemplo n.º 48
0
            "  /uotp disable freenode", "otp %(irc_servers)"
            " || list"
            " || add %(irc_servers)"
            " || remove %(configured_servers)"
            " || enable %(irc_servers)"
            " || disable %(disabled_servers)", "options_cb", "")
        weechat.hook_signal("irc_server_connecting", "signal_cb", "")
        weechat.hook_signal("irc_server_disconnected", "signal_cb", "")
        weechat.hook_config(
            "plugins.var.python.undernet_totp.otp_server_names",
            "config_update_cb", "")
        weechat.hook_completion("configured_servers",
                                "list of otp configured servers",
                                "server_completion_cb", "configured_servers")
        weechat.hook_completion("disabled_servers", "list of disabled servers",
                                "server_completion_cb", "enabled_servers")
        weechat.hook_modifier("input_text_display", "hide_secret_cb", "")

        for option, default_value in SETTINGS.items():
            if weechat.config_get_plugin(option) == "":
                weechat.config_set_plugin(option, default_value[0])
            weechat.config_set_desc_plugin(
                option,
                '%s (default: %s)' % (default_value[1], default_value[0]))

        # For now we enable the hooks until it's possible to force script plugins to
        # load before the irc plugin on weechat startup, otherwise the irc_server_connecting signal
        # get missed.
        for server in enabled_servers():
            hook_all(server)
Exemplo n.º 49
0
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_print('', 'irc_privmsg', '', 1, 'notify', '')
    weechat.hook_modifier('irc_out_privmsg', 'outgoing_hook', '')


def notify(data, buf, date, tags, displayed, hilight, prefix, msg):
    color = weechat.color(weechat.config_get_plugin('color'))
    reset = weechat.color('reset')

    my_nick = weechat.buffer_get_string(buf, 'localvar_nick')
    if prefix != my_nick:
        urls = find_and_process_urls(msg)

        for url, short_url in urls:
            weechat.prnt(buf, '%(color)s[ %(url)s ]%(reset)s' % dict(
                color=color,
                url=short_url,
                reset=reset))
Exemplo n.º 50
0
    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", "")
Exemplo n.º 51
0
        buf = weechat.window_get_pointer(window, 'buffer')
    else:
        buf = weechat.current_buffer()
    if os.path.exists(weechat_dir + '/' + \
         weechat.buffer_get_string(buf, 'short_name') + '.db'):
        return weechat.config_get_plugin("statusbar_indicator")
    else:
        return ""


# register plugin
if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, \
                    SCRIPT_LICENSE, SCRIPT_DESC, "", "UTF-8"):
    weechat_dir = weechat.info_get("weechat_dir", "")
    key_dir = weechat.config_get_plugin('key_dir')
    version = weechat.info_get("version_number", "") or 0
    if int(version) < 0x00030000:
        weechat.prnt(
            "", "%s%s: WeeChat 0.3.0 is required for this script." %
            (weechat.prefix("error"), SCRIPT_NAME))
    else:
        weechat.bar_item_new('axolotl', 'encryption_statusbar', '')
        for option, default_value in script_options.iteritems():
            if not weechat.config_is_set_plugin(option):
                weechat.config_set_plugin(option, default_value)

        # register the modifiers
        weechat.hook_modifier("irc_in_privmsg", "decrypt", "")
        weechat.hook_modifier("irc_out_privmsg", "encrypt", "")
        weechat.hook_signal("buffer_switch", "update_encryption_status", "")
Exemplo n.º 52
0
            '  - don\'t like the built-in HTTP server to start automatically? '
            'Disable it:\n'
            '      /set plugins.var.python.urlserver.http_autostart "off"\n'
            '  - have external port 80 or 443 (https) forwarded to your '
            'internal server port? Remove :port with:\n'
            '      /set plugins.var.python.urlserver.http_port_display "80" '
            'or "443" respectively\n'
            '\n'
            'Tip: use URL without key at the end to display list of all URLs '
            'in your browser.', 'start|restart|stop|status|clear',
            'urlserver_cmd_cb', '')

        if urlserver_settings['http_autostart'] == 'on':
            # start mini HTTP server
            urlserver_server_start()

        # load urls from file
        urlserver_read_urls()

        # catch URLs in buffers
        weechat.hook_print('', '', '://', 1, 'urlserver_print_cb', '')

        # modify URLS in irc messages (for relay)
        weechat.hook_modifier('irc_in2_privmsg', 'urlserver_modifier_irc_cb',
                              '')
        weechat.hook_modifier('irc_in2_notice', 'urlserver_modifier_irc_cb',
                              '')

        # search buffer
        urlserver['buffer'] = weechat.buffer_search('python', SCRIPT_BUFFER)
Exemplo n.º 53
0
        "  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", "")
Exemplo n.º 54
0
        weechat.hook_completion_list_add(completion, ":%s:" % key, 0, weechat.WEECHAT_LIST_POS_SORT)
    return weechat.WEECHAT_RC_OK


def replace_emoji(match):
    text = match.group(0)
    codepoint = EMOJI.get(text[1:-1])
    if codepoint:
        raw = "\\U%08x" % int(codepoint, 16)
        return raw.decode("unicode-escape").encode("utf-8")
    return text


if __name__ == "__main__" and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        weechat.hook_modifier("weechat_print", "interpolate_emoji_cb", "")
        weechat.hook_completion("emoji_names", "complete colon :emoji:", "emoji_completion_cb", "")


# Emoji mapping is modified from
# https://github.com/iamcal/emoji-data/blob/master/emoji.json
#
# The MIT License (MIT)
#
# Copyright (c) 2013 Cal Henderson
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
Exemplo n.º 55
0
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)
Exemplo n.º 56
0
        w.nicklist_add_nick(buffer, group, name, "weechat.color.nicklist_group", "~", "lightgreen", 1)
    return w.WEECHAT_RC_OK

def get_nick_group(buffer, group_name):
    group = w.nicklist_search_group(buffer, "", group_name)
    if not group:
        group = w.nicklist_add_group(buffer, "", group_name, "weechat.color.nicklist_group", 1)
    return group

def nicklist_nick_added_cb(data, signal, buffer):
    group = get_nick_group(buffer, 'bot2human')

    return w.WEECHAT_RC_OK

if __name__ == '__main__':
    w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
               SCRIPT_DESC, "", "")

    parse_config()

    w.hook_modifier("irc_in_privmsg", "msg_cb", "")
    w.hook_config("plugins.var.python."+SCRIPT_NAME+".*", "config_cb", "")
    
    # Glowing Bear will choke if a nick is added into a newly created group.
    # As a workaround, we add the group as soon as possible BEFORE Glowing Bear loads groups,
    # and we must do that AFTER EVERY nicklist reload. nicklist_nick_added satisfies both.
    # TODO(quietlynn): Find better signals to hook instead.
    w.hook_signal("nicklist_nick_added", "nicklist_nick_added_cb", "")

# vim: ts=4 sw=4 sts=4 expandtab
Exemplo n.º 57
0
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_print('', 'irc_privmsg', '', 1, 'notify', '')
    weechat.hook_modifier('irc_out_privmsg', 'outgoing_hook', '')


def notify(data, buf, date, tags, displayed, hilight, prefix, msg):
    color = weechat.color(weechat.config_get_plugin('color'))
    reset = weechat.color('reset')

    my_nick = weechat.buffer_get_string(buf, 'localvar_nick')
    if prefix != my_nick:
        urls = find_and_process_urls(msg)

        for url, short_url in urls:
            weechat.prnt(
                buf, '%(color)s[ %(url)s ]%(reset)s' %
                dict(color=color, url=short_url, reset=reset))
Exemplo n.º 58
0
            server = w.buffer_get_string(w.current_buffer(), 'localvar_server')
            plugin = w.buffer_get_string(w.current_buffer(), 'plugin')
            output = w.buffer_search(plugin, 'server.'+server)
        elif options['warning_buffer'] == '':
            output = None
        else:
            output = '' # if invalid option set to weechat buffer
        if not output == None:
            w.prnt_date_tags(output, 0, 'no_log', '%sunwanted message deleted: "%s"' % (w.prefix('error'), string))
        w.buffer_set(w.current_buffer(), 'input', string)
        return ''
    else:
        return string

options = {}
for option in settings.keys():
    options[option] = w.config_get_plugin(option)
unwanted_pattern = re.compile(options['regexp'])

def my_config_cb(data, option, value):
    global options, unwanted_pattern
    for option in settings.keys():
        options[option] = w.config_get_plugin(option)
    unwanted_pattern = re.compile(options['regexp'])
    return w.WEECHAT_RC_OK

for option in settings.keys():
    w.hook_config("plugins.var.python.%s.%s" % (name, option), "my_config_cb", "")

w.hook_modifier('input_text_for_buffer', 'my_modifier_cb', '')
Exemplo n.º 59
0
def send_typing(nick, level):
    if not channel_has_nick(bitlbee_server_name, bitlbee_channel, nick):
        return
    cookie = sending_typing.get(nick, 1) + 1
    if not sending_typing.get(nick, None):
        send_typing_ctcp(nick, level)
    sending_typing[nick] = cookie
    w.hook_timer(4000, 0, 1, "typing_disable_timer", "%s:%i" % (nick, cookie))


def typing_notice_item_cb(data, buffer, args):
    if typing:
        msgs = []
        for key, value in typing.items():
            msg = key
            if value == 2:
                msg += " (stale)"
            msgs.append(msg)
        return "typing: " + ", ".join(sorted(msgs))
    return ""


if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
              SCRIPT_DESC, "", ""):
    w.hook_signal("input_text_changed", "typed_char", "")
    w.hook_signal(bitlbee_server_name + ",irc_in_quit", "stop_typing", "")
    w.hook_signal(bitlbee_server_name + ",irc_in_privmsg", "stop_typing", "")
    w.bar_item_new('bitlbee_typing_notice', 'typing_notice_item_cb', '')
    w.hook_modifier("irc_in_privmsg", "ctcp_cb", "")