Пример #1
0
def buffer_switch(data, signal, signal_data):
    full_name = weechat.buffer_get_string(
        signal_data, 'full_name')  # get full_name of current buffer
    if full_name == '':  # upps, something totally wrong!
        return weechat.WEECHAT_RC_OK

    for option in list(OPTIONS.keys()):
        option = option.split('.')
        customize_plugin = weechat.config_get_plugin(
            '%s.%s' %
            (option[1], full_name))  # for example: title.irc.freenode.#weechat
        if customize_plugin:  # option exists
            config_pnt = weechat.config_get('weechat.bar.%s.items' % option[1])
            #            current_bar = weechat.config_string(weechat.config_get('weechat.bar.%s.items' % option[1]))
            weechat.config_option_set(config_pnt, customize_plugin,
                                      1)  # set customize_bar
        else:
            current_bar = weechat.config_string(
                weechat.config_get('weechat.bar.%s.items' % option[1]))
            default_plugin = weechat.config_get_plugin(
                'default.%s' % option[1])  # option we are looking for
            if default_plugin == '':  # default_plugin removed by user?
                weechat.config_set_plugin(
                    'default.%s' % option[1],
                    DEFAULT_OPTION[option[1]])  # set default_plugin again!
            if current_bar != default_plugin:
                config_pnt = weechat.config_get('weechat.bar.%s.items' %
                                                option[1])
                weechat.config_option_set(config_pnt, default_plugin,
                                          1)  # set customize_bar

    return weechat.WEECHAT_RC_OK
Пример #2
0
def fish_secure_key_cb(data, option, value):
    global fish_secure_key, fish_secure_cipher

    fish_secure_key = weechat.config_string(
        weechat.config_get("fish.secure.key")
    )

    if fish_secure_key == "":
        fish_secure_cipher = None
        return weechat.WEECHAT_RC_OK

    if fish_secure_key[:6] == "${sec.":
        decrypted = weechat.string_eval_expression(
            fish_secure_key, {}, {}, {}
        )
        if decrypted:
            fish_secure_cipher = Blowfish(decrypted)
            return weechat.WEECHAT_RC_OK
        else:
            weechat.config_option_set(fish_config_option["key"], "", 0)
            weechat.prnt("", "Decrypt sec.conf first\n")
            return weechat.WEECHAT_RC_OK

    if fish_secure_key != "":
        fish_secure_cipher = Blowfish(fish_secure_key)

    return weechat.WEECHAT_RC_OK
Пример #3
0
def jmh_cmd(data, buffer, args=None):
    """ Command /jabber_message_handler """
    if args:
        argv = args.split(None, 1)
        if len(argv) > 0:
            if argv[0] == "on":
                weechat.config_option_set(
                        jmh_config_option["enabled"], "on", 1)
            elif argv[0] == "off":
                weechat.config_option_set(
                        jmh_config_option["enabled"], "off", 1)
            elif argv[0] == "verbose":
                if len(argv) > 1:
                    weechat.config_option_set(
                            jmh_config_option["verbose"], argv[1], 1)
                else:
                    weechat.config_option_set(
                            jmh_config_option["verbose"], "toggle", 1)
            elif argv[0] == "log":
                if len(argv) > 1:
                    weechat.config_option_set(
                            jmh_config_option["log"], argv[1], 1)
            else:
                weechat.prnt("", "jabber_message_handler: unknown action")

    print_settings()
    return weechat.WEECHAT_RC_OK
Пример #4
0
def save_new_force_nicks():
    global colored_nicks
    #    new_nick_color_force = ';'.join([ ':'.join(item) for item in colored_nicks.items()])
    new_nick_color_force = ';'.join(
        [':'.join(item) for item in list(colored_nicks.items())])
    config_pnt = weechat.config_get(nick_option)
    weechat.config_option_set(config_pnt, new_nick_color_force, 1)
Пример #5
0
def fish_secure_key_cb(data, option, value):
    global fish_secure_key, fish_secure_cipher

    fish_secure_key = weechat.config_string(
        weechat.config_get("fish.secure.key")
    )

    if fish_secure_key == "":
        fish_secure_cipher = None
        return weechat.WEECHAT_RC_OK

    if fish_secure_key[:6] == "${sec.":
        decrypted = weechat.string_eval_expression(
            fish_secure_key, {}, {}, {}
        )
        if decrypted:
            fish_secure_cipher = Blowfish(decrypted)
            return weechat.WEECHAT_RC_OK
        else:
            weechat.config_option_set(fish_config_option["key"], "", 0)
            weechat.prnt("", "Decrypt sec.conf first\n")
            return weechat.WEECHAT_RC_OK

    if fish_secure_key != "":
        fish_secure_cipher = Blowfish(fish_secure_key)

    return weechat.WEECHAT_RC_OK
Пример #6
0
def shutdown_cb():
    # write back default options to original options, then quit...
    for option in list(OPTIONS.keys()):
        option = option.split('.')
        default_plugin = weechat.config_get_plugin('default.%s' % option[1])
        config_pnt = weechat.config_get('weechat.bar.%s.items' % option[1])
        weechat.config_option_set(config_pnt, default_plugin, 1)
    return weechat.WEECHAT_RC_OK
Пример #7
0
def shutdown_cb():
    # write back default options to original options, then quit...
    for option in OPTIONS.keys():
        option = option.split('.')
        default_plugin = weechat.config_get_plugin('default.%s' % option[1])
        config_pnt = weechat.config_get('weechat.bar.%s.items' % option[1])
        weechat.config_option_set(config_pnt,default_plugin,1)
    return weechat.WEECHAT_RC_OK
Пример #8
0
def refresh():
    width = weechat.window_get_integer(weechat.current_window(),
                                       'win_chat_width')
    string = option_values['marker']

    marker = string + ' ' * (width -
                             (len(string.decode('utf-8')) * 2)) + string

    config = weechat.config_get('weechat.look.read_marker_string')
    weechat.config_option_set(config, marker, 0)
Пример #9
0
def remove_from_nick_colours(colour):
    colours = nick_colours()
    if not colour in colours:
        weechat.prnt(
            weechat.current_buffer(),
            '%sThe colour \"%s\" is not present in weechat.color.chat_nick_colors'
            % (weechat.prefix("error"), colour))
        return
    colours.remove(colour)
    wc_nick_colours = ','.join(colours)
    weechat.config_option_set(wc_nick_colours_pointer(), wc_nick_colours, 1)
    load_buffer_items()
Пример #10
0
def add_to_nick_colours(colour):
    colours = nick_colours()
    if colour in colours:
        weechat.prnt(
            weechat.current_buffer(),
            '%sThe colour \"%s\" is already present in weechat.color.chat_nick_colors'
            % (weechat.prefix("error"), colour))
        return
    colours.append(colour)
    wc_nick_colours = ','.join(colours)
    weechat.config_option_set(wc_nick_colours_pointer(), wc_nick_colours, 1)
    load_buffer_items()
Пример #11
0
def remove_from_nick_colours(colour):
    colours = nick_colours()
    if not colour in colours:
        weechat.prnt(
            weechat.current_buffer(),
            '%sThe colour "%s" is not present in weechat.color.chat_nick_colors' % (weechat.prefix("error"), colour),
        )
        return
    colours.remove(colour)
    wc_nick_colours = ",".join(colours)
    weechat.config_option_set(wc_nick_colours_pointer(), wc_nick_colours, 1)
    load_buffer_items()
Пример #12
0
def add_to_nick_colours(colour):
    colours = nick_colours()
    if colour in colours:
        weechat.prnt(
            weechat.current_buffer(),
            '%sThe colour "%s" is already present in weechat.color.chat_nick_colors'
            % (weechat.prefix("error"), colour),
        )
        return
    colours.append(colour)
    wc_nick_colours = ",".join(colours)
    weechat.config_option_set(wc_nick_colours_pointer(), wc_nick_colours, 1)
    load_buffer_items()
Пример #13
0
def fish_secure_genkey(buffer):
    global fish_secure_cipher, fish_config_option

    newKey = blowcrypt_b64encode(urandom(32))

    # test to see if sec.conf decrypted
    weechat.command(buffer, "/secure set fish test")
    decrypted = weechat.string_eval_expression("${sec.data.fish}", {}, {}, {})

    if decrypted == "test":
        weechat.config_option_set(fish_config_option["key"],
                                  "${sec.data.fish}", 0)
        fish_secure_cipher = Blowfish(newKey)
        weechat.command(buffer, "/secure set fish %s" % newKey)
Пример #14
0
def webex_cmd_reconnect(data, buffer, access_token):
    """ Reconnect to webex """
    global webex_server, webex_config_option
    if access_token:
        weechat.config_option_set(webex_config_option["access_token"],
                                  access_token, 1)

    # Do full reconnect if sock not working
    if not webex_server.sock:
        webex_server.connect()
    else:
        webex_server.connect_webex()
        webex_server.start_websocket(force=True)

    return weechat.WEECHAT_RC_OK
Пример #15
0
def ircrypt_check_binary():
	'''If binary is not set, try to determine it automatically
	'''
	cfg_option = weechat.config_get('ircrypt.general.binary')
	gnupg = weechat.config_string(cfg_option)
	if not gnupg:
		(gnupg, version) = ircrypt_find_gpg_binary(('gpg','gpg2'))
		if not gnupg:
			ircrypt_error('Automatic detection of the GnuPG binary failed and '
					'nothing is set manually. You wont be able to use IRCrypt like '
					'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)
Пример #16
0
 def install(self):
     try:
         numset = 0
         numerrors = 0
         for name in self.options:
             option = weechat.config_get(name)
             if option:
                 if weechat.config_option_set(option, self.options[name], 1) == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
                     self.prnt_error('Error setting option "%s" to value "%s" (running an old WeeChat?)' % (name, self.options[name]))
                     numerrors += 1
                 else:
                     numset += 1
             else:
                 self.prnt('Warning: option not found: "%s" (running an old WeeChat?)' % name)
                 numerrors += 1
         errors = ''
         if numerrors > 0:
             errors = ', %d error(s)' % numerrors
         if self.filename:
             self.prnt('Theme "%s" installed (%d options set%s)' % (self.filename, numset, errors))
         else:
             self.prnt('Theme installed (%d options set%s)' % (numset, errors))
     except:
         if self.filename:
             self.prnt_error('Failed to install theme "%s"' % self.filename)
         else:
             self.prnt_error('Failed to install theme')
Пример #17
0
def ircrypt_check_binary():
    '''If binary is not set, try to determine it automatically
	'''
    cfg_option = weechat.config_get('ircrypt.general.binary')
    gnupg = weechat.config_string(cfg_option)
    if not gnupg:
        (gnupg, version) = ircrypt_find_gpg_binary(('gpg', 'gpg2'))
        if not gnupg:
            ircrypt_error(
                'Automatic detection of the GnuPG binary failed and '
                'nothing is set manually. You wont be able to use IRCrypt like '
                '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)
Пример #18
0
 def install(self):
     try:
         numset = 0
         numerrors = 0
         for name in self.options:
             option = weechat.config_get(name)
             if option:
                 if weechat.config_option_set(
                         option, self.options[name],
                         1) == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
                     self.prnt_error(
                         'Error setting option "%s" to value "%s" (running an old WeeChat?)'
                         % (name, self.options[name]))
                     numerrors += 1
                 else:
                     numset += 1
             else:
                 self.prnt(
                     'Warning: option not found: "%s" (running an old WeeChat?)'
                     % name)
                 numerrors += 1
         errors = ''
         if numerrors > 0:
             errors = ', %d error(s)' % numerrors
         if self.filename:
             self.prnt('Theme "%s" installed (%d options set%s)' %
                       (self.filename, numset, errors))
         else:
             self.prnt('Theme installed (%d options set%s)' %
                       (numset, errors))
     except:
         if self.filename:
             self.prnt_error('Failed to install theme "%s"' % self.filename)
         else:
             self.prnt_error('Failed to install theme')
Пример #19
0
 def install(self):
     try:
         numset = 0
         numerrors = 0
         for name in self.options:
             option = weechat.config_get(name)
             if option:
                 rc = weechat.config_option_set(option,
                                                self.options[name], 1)
                 if rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
                     self.prnt_error('Error setting option "{0}" to value '
                                     '"{1}" (running an old WeeChat?)'
                                     ''.format(name, self.options[name]))
                     numerrors += 1
                 else:
                     numset += 1
             else:
                 self.prnt('Warning: option not found: "{0}" '
                           '(running an old WeeChat?)'.format(name))
                 numerrors += 1
         errors = ''
         if numerrors > 0:
             errors = ', {0} error(s)'.format(numerrors)
         if self.filename:
             self.prnt('Theme "{0}" installed ({1} options set{2})'
                       ''.format(self.filename, numset, errors))
         else:
             self.prnt('Theme installed ({0} options set{1})'
                       ''.format(numset, errors))
     except:
         if self.filename:
             self.prnt_error('Failed to install theme "{0}"'
                             ''.format(self.filename))
         else:
             self.prnt_error('Failed to install theme')
Пример #20
0
 def install(self):
     try:
         numset = 0
         numerrors = 0
         for name in self.options:
             option = weechat.config_get(name)
             if option:
                 rc = weechat.config_option_set(option, self.options[name],
                                                1)
                 if rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
                     self.prnt_error('Error setting option "{0}" to value '
                                     '"{1}" (running an old WeeChat?)'
                                     ''.format(name, self.options[name]))
                     numerrors += 1
                 else:
                     numset += 1
             else:
                 self.prnt('Warning: option not found: "{0}" '
                           '(running an old WeeChat?)'.format(name))
                 numerrors += 1
         errors = ''
         if numerrors > 0:
             errors = ', {0} error(s)'.format(numerrors)
         if self.filename:
             self.prnt('Theme "{0}" installed ({1} options set{2})'
                       ''.format(self.filename, numset, errors))
         else:
             self.prnt('Theme installed ({0} options set{1})'
                       ''.format(numset, errors))
     except:
         if self.filename:
             self.prnt_error('Failed to install theme "{0}"'
                             ''.format(self.filename))
         else:
             self.prnt_error('Failed to install theme')
Пример #21
0
def fish_secure_genkey(buffer):
    global fish_secure_cipher, fish_config_option

    newKey = blowcrypt_b64encode(urandom(32))

    # test to see if sec.conf decrypted
    weechat.command(buffer, "/secure set fish test")
    decrypted = weechat.string_eval_expression(
        "${sec.data.fish}", {}, {}, {}
    )

    if decrypted == "test":
        weechat.config_option_set(fish_config_option["key"],
                                  "${sec.data.fish}", 0)
        fish_secure_cipher = Blowfish(newKey)
        weechat.command(buffer, "/secure set fish %s" % newKey)
Пример #22
0
 def add_to_nick_list(self, *logins):
     contact_list = {
         True: [],
         False: self.get_option('contacts').replace(' ', '').split(',')
     }[self.get_option('contacts').replace(' ', '') == '']
     new_contacts = []
     for login in logins:
         if login in self.contacts:
             continue
         contact_list.append(login)
         new_contacts.append(login)
         self.contacts[login] = {}
         weechat.nicklist_add_group(self.buffer, '', login, 'lightcyan', 1)
     self._ns_user_cmd_who('{%s}' % ','.join(new_contacts))
     self._ns_user_cmd_watch_log_user(','.join(contact_list))
     weechat.config_option_set(self.options['contacts'],
                               ','.join(contact_list), 0)
Пример #23
0
 def add_to_nick_list(self, *logins):
     contact_list = {
         True: [],
         False: self.get_option('contacts').replace(' ', '').split(',')
     }[self.get_option('contacts').replace(' ', '') == '']
     new_contacts = []
     for login in logins:
         if login in self.contacts:
             continue
         contact_list.append(login)
         new_contacts.append(login)
         self.contacts[login] = {}
         weechat.nicklist_add_group(self.buffer, '', login, 'lightcyan', 1)
     self._ns_user_cmd_who('{%s}' % ','.join(new_contacts))
     self._ns_user_cmd_watch_log_user(','.join(contact_list))
     weechat.config_option_set(self.options['contacts'],
                               ','.join(contact_list), 0)
Пример #24
0
def check_config():
    option = weechat.config_get("weechat.completion.default_template")
    default_template = weechat.config_string(option)
    if TEMPLATE_NAME not in default_template:
        rc = weechat.config_option_set(option, default_template + "|%(" + TEMPLATE_NAME + ")", 1)
        if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
            weechat.prnt("", SCRIPT_NAME + " -  warning! - weechat.completion.default_template same value")
        elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
            weechat.prnt("", SCRIPT_NAME + " -  error! - writing weechat.completion.default_template option")
Пример #25
0
def bas_config_buffer_create_option_cb(data, config_file, section, option_name, value):
    option = weechat.config_search_option(config_file, section, option_name)
    if option:
        return weechat.config_option_set (option, value, 1)
    else:
        option = weechat.config_new_option (config_file, section, option_name, "string",
                                            "", "", 0, 0, "", value, 0,
                                            "", "", "", "", "", "")
        if not option:
            return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
        return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
Пример #26
0
def bas_config_buffer_create_option_cb(data, config_file, section, option_name, value):
    option = weechat.config_search_option(config_file, section, option_name)
    if option:
        return weechat.config_option_set(option, value, 1)
    else:
        option = weechat.config_new_option(
            config_file, section, option_name, "string", "", "", 0, 0, "", value, 0, "", "", "", "", "", ""
        )
        if not option:
            return weechat.WEECHAT_CONFIG_OPTION_SET_ERROR
        return weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE
Пример #27
0
    def set_value(self, section_name, option_name, value):
        """Set a configuration option."""
        section = weechat.config_search_section(
            self._config_file,
            section_name)
        option = weechat.config_search_option(
            self._config_file,
            section,
            option_name)

        ret = weechat.config_option_set(option, value, 1)
        return ret
Пример #28
0
def buffer_switch(data, signal, signal_data):
    full_name = weechat.buffer_get_string(signal_data,'full_name')                      # get full_name of current buffer
    if full_name == '':                                                                 # upps, something totally wrong!
        return weechat.WEECHAT_RC_OK

    for option in OPTIONS.keys():
        option = option.split('.')
        customize_plugin = weechat.config_get_plugin('%s.%s' % (option[1], full_name))  # for example: title.irc.freenode.#weechat
        if customize_plugin:                                                            # option exists
            config_pnt = weechat.config_get('weechat.bar.%s.items' % option[1])
#            current_bar = weechat.config_string(weechat.config_get('weechat.bar.%s.items' % option[1]))
            weechat.config_option_set(config_pnt,customize_plugin,1)                    # set customize_bar
        else:
            current_bar = weechat.config_string(weechat.config_get('weechat.bar.%s.items' % option[1]))
            default_plugin = weechat.config_get_plugin('default.%s' % option[1])        # option we are looking for
            if default_plugin == '':                                                    # default_plugin removed by user?
                weechat.config_set_plugin('default.%s' % option[1],DEFAULT_OPTION[option[1]]) # set default_plugin again!
            if current_bar != default_plugin:
                config_pnt = weechat.config_get('weechat.bar.%s.items' % option[1])
                weechat.config_option_set(config_pnt,default_plugin,1)                  # set customize_bar

    return weechat.WEECHAT_RC_OK
Пример #29
0
def set_under_notify_list(new_notify_list):
    """Change the irc.server.'under'.notify configuration setting.

	To a new list based on either the nicks in NICKLIST or reset back to
	original value.
	"""
    # noinspection PyProtectedMember
    function_name = sys._getframe().f_code.co_name  # pylint: disable=W0212

    wp.debug(function_name, "START : %s" % new_notify_list, wdb.SHOW_START)
    if add_nick_to_send_list(new_notify_list):
        if d.OPTION_NOTIFY is not None:
            callback_return = w.config_option_set(d.OPTION_NOTIFY,
                                                  new_notify_list, 1)
            if callback_return == w.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
                # ... option changed
                # wp.wprint("NOTIFY:: Notify list is now: %s" % new_notify_list)
                d.NOTIFY_LIST_CHANGED = True
                return True
            elif callback_return == w.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
                return False
            elif callback_return == w.WEECHAT_CONFIG_OPTION_SET_ERROR:
                # ... option set error
                wp.error_print(
                    "ERROR: Option set error, NOT set to %s" % new_notify_list,
                    2)
                return False
            else:
                wp.error_print(
                    "ERROR: THIS SHOULD NEVER HAPPEN, WEECHAT RETURNED \
                           INVALID VALUE", 5)
        else:
            wp.error_print(
                "ERROR: under notify list never found or it's option \
                       never saved", 4)
    else:
        wp.error_print(
            "ERROR: xfer list never found or it's option never saved", 4)
    return False
Пример #30
0
def set_xfer_down_accept(newxferlist):
    """Set the xfer nick which are automatically accepted."""
    # noinspection PyProtectedMember
    function_name = sys._getframe().f_code.co_name  # pylint: disable=W0212

    wp.debug(function_name, "START : %s" % newxferlist, wdb.SHOW_START)
    option_xfer = w.config_get("xfer.file.auto_accept_nicks")
    if newxferlist:
        callback_return = w.config_option_set(option_xfer, newxferlist, 1)

        if callback_return == w.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED or \
          callback_return == w.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
            return True
            # option changed or set same value
        elif callback_return == w.WEECHAT_CONFIG_OPTION_SET_ERROR:
            # ... option set error
            wp.debug(function_name,
                     "ERROR. callback_return = %d" % callback_return,
                     wdb.SHOW_ERROR)
            wp.error_print(
                "ERROR: Option XFER set error, NOT set to %s" % newxferlist, 2)
    # wp.error_print("XFER set error")
    return False
Пример #31
0
def set_autojoin_list(server, list_of_channels, list_of_keys):
    ptr_config_autojoin = weechat.config_get("irc.server.%s.autojoin" % server)
    if not ptr_config_autojoin:
        return 0

    if OPTIONS["sorted"].lower() == "on" and not list_of_keys:
        # no keys, sort the channel-list
        channels = "%s" % ",".join(sorted(list_of_channels))
    else:
        # don't sort channel-list with given key
        channels = "%s" % ",".join(list_of_channels)

    # strip leading ','
    if channels[0] == ",":
        channels = channels.lstrip(",")

    # add keys to list of channels
    if list_of_keys:
        channels = "%s %s" % (channels, list_of_keys)

    rc = weechat.config_option_set(ptr_config_autojoin, channels, 1)
    if not rc:
        return 0
    return 1
Пример #32
0
def set_autojoin_list(server,list_of_channels, list_of_keys):
    ptr_config_autojoin = weechat.config_get('irc.server.%s.autojoin' % server)
    if not ptr_config_autojoin:
        return 0

    if OPTIONS['sorted'].lower() == 'on' and not list_of_keys:
        # no keys, sort the channel-list
        channels = '%s' % ','.join(sorted(list_of_channels))
    else:
        # don't sort channel-list with given key
        channels = '%s' % ','.join(list_of_channels)

    # strip leading ','
    if channels[0] == ',':
        channels = channels.lstrip(',')

    # add keys to list of channels
    if list_of_keys:
        channels = '%s %s' % (channels,list_of_keys)

    rc = weechat.config_option_set(ptr_config_autojoin,channels,1)
    if not rc:
        return 0
    return 1
Пример #33
0
def add_autojoin_cmd_cb(data, buffer, args):
    if args == "":                                                                              # no args given. quit
        return weechat.WEECHAT_RC_OK

    argv = args.strip().split(' ')

#    if (len(argv) <= 1):
#        weechat.prnt(buffer,"%s%s: too few arguments." % (weechat.prefix('error'),SCRIPT_NAME))
#        return weechat.WEECHAT_RC_OK

    server = weechat.buffer_get_string(buffer, 'localvar_server')                               # current server
    channel = weechat.buffer_get_string(buffer, 'localvar_channel')                             # current channel
    buf_type = weechat.buffer_get_string(buffer, 'localvar_type')

    # only "add <servername>" given by user
    if (len(argv) == 2):
        weechat.prnt(buffer,"%s%s: invalid number of arguments." % (weechat.prefix('error'),SCRIPT_NAME))
        return weechat.WEECHAT_RC_OK

    # '-key' keyword in command line?
    if '-key' in argv:
        found_key_word = argv.index('-key')
        key_words = argv[int(found_key_word)+1:]
        # don't use "-key" in argv
        argv = argv[:int(found_key_word)]

    # ADD argument
    if (argv[0].lower() == 'add'):
        # add current channel to autojoin. Only option "add" was given..
        if (len(argv) == 1):
            if server == "" or channel == "" or server == channel or buf_type == "" or buf_type != 'channel':
                weechat.prnt(buffer,"%s%s: current buffer is not a channel buffer." % (weechat.prefix('error'),SCRIPT_NAME))
                return weechat.WEECHAT_RC_OK
            list_of_channels, list_of_current_keys = get_autojoin_list(buffer,server)
            # no channels in option!
            if list_of_channels == 1 and list_of_current_keys == 1:
                ptr_config_autojoin = weechat.config_get('irc.server.%s.autojoin' % server)
                rc = weechat.config_option_set(ptr_config_autojoin,channel,1)
                return weechat.WEECHAT_RC_OK
            if channel in list_of_channels:
                weechat.prnt(buffer,"%s%s: channel '%s' already in autojoin for server '%s'" % (weechat.prefix("error"),SCRIPT_NAME,channel,server))
            else:
                # first char of channel '#' ?
                if channel[0] == '#':
                    if '-key' in args and len(key_words) > 1:
                        weechat.prnt(buffer,"%s%s: too many key(s) for given channel(s) " % (weechat.prefix('error'),SCRIPT_NAME))
                        return weechat.WEECHAT_RC_OK
                    elif '-key' in args and len(key_words) == 1:
                        list_of_channels.insert(0,channel)
                        list_of_current_keys = ','.join(key_words)
                        # strip leading ','
                        if list_of_current_keys[0] == ',':
                            list_of_current_keys = list_of_current_keys.lstrip(',')
                    else:
                        list_of_channels.append(channel)

                    if not set_autojoin_list(server,list_of_channels, list_of_current_keys):
                        weechat.prnt(buffer,"%s%s: set new value for option failed..." % (weechat.prefix('error'),SCRIPT_NAME))
        # server and channels given by user
        elif (len(argv) >= 3):
            server = argv[1]
            list_of_channels = argv[2:]
            if '-key' in args and len(list_of_channels) < len(key_words):
                weechat.prnt(buffer,"%s%s: too many key(s) for given channel(s) " % (weechat.prefix('error'),SCRIPT_NAME))
                return weechat.WEECHAT_RC_OK

            list_of_current_channels,list_of_current_keys = get_autojoin_list(buffer,server)
            # autojoin option is empty
            if list_of_current_channels == 1:
                # no channel -> no key!
                list_of_current_keys = ""
                if '-key' in args:
                    list_of_current_keys = ','.join(key_words)
                    # strip leading ','
                    if list_of_current_keys[0] == ',':
                        list_of_current_keys = list_of_current_keys.lstrip(',')
                if not set_autojoin_list(server,list_of_channels, list_of_current_keys):
                    weechat.prnt(buffer,"%s%s: set new value for option failed..." % (weechat.prefix('error'),SCRIPT_NAME))
            else:
                if '-key' in args:
                    j = 0
                    new_keys = []
                    list_of_new_keys = []
                    for i in list_of_channels:
                        if i not in list_of_current_channels and j <= len(key_words):
#                            weechat.prnt(buffer,"channel: %s, channel key is: '%s'" % (i,key_words[j]))
                            list_of_current_channels.insert(j,i)
                            new_keys.insert(j,key_words[j])
                        j += 1
                    missing_channels = list_of_current_channels
                    list_of_new_keys = ','.join(new_keys)
                    if list_of_current_keys:
                        list_of_current_keys = list_of_new_keys + ',' + list_of_current_keys
                    else:
                        list_of_current_keys = list_of_new_keys
                    # strip leading ','
                    if list_of_current_keys[0] == ',':
                        list_of_current_keys = list_of_current_keys.lstrip(',')
                else:
                    # check given channels with channels already set in option
                    missing_channels = get_difference(list_of_channels,list_of_current_channels)
                    missing_channels = list_of_current_channels + missing_channels

                if not set_autojoin_list(server,missing_channels, list_of_current_keys):
                    weechat.prnt(buffer,"%s%s: set new value for option failed..." % (weechat.prefix('error'),SCRIPT_NAME))
        return weechat.WEECHAT_RC_OK

    # DEL argument
    if (argv[0].lower() == 'del'):
        # del current channel from autojoin. Only option "del" was given..
        if (len(argv) == 1):
            if server == "" or channel == "" or server == channel or buf_type == "" or buf_type != 'channel':
                weechat.prnt(buffer,"%s%s: current buffer is not a channel buffer." % (weechat.prefix('error'),SCRIPT_NAME))
                return weechat.WEECHAT_RC_OK
            list_of_channels, list_of_keys = get_autojoin_list(buffer,server)
            # no channels in option, nothing to delete
            if list_of_channels == 1 and list_of_current_keys == 1:
                return weechat.WEECHAT_RC_OK
            if channel not in list_of_channels:
                weechat.prnt(buffer,"%s%s: channel '%s' not found in autojoin for server '%s'" % (weechat.prefix("error"),SCRIPT_NAME,channel,server))
                return weechat.WEECHAT_RC_OK
            else:
                # first char of channel '#' ?
                if channel[0] == '#':
                    channel_key_index = list_of_channels.index(channel)
                    if not list_of_keys:
                        list_of_channels.remove(list_of_channels[channel_key_index])
                        list_of_current_keys = ''
                    else:
                        list_of_keys_tup = list_of_keys.split(",")
                        list_of_current_keys = list_of_keys
                        # channel does not have a key (position of channel > number of keys!)
                        if channel_key_index + 1 > len(list_of_keys_tup):
                            list_of_channels.remove(list_of_channels[channel_key_index])
                        # remove channel and key from autjoin option
                        else:
                            list_of_channels.remove(list_of_channels[channel_key_index])
                            list_of_keys_tup.remove(list_of_keys_tup[channel_key_index])
                            # does a key exists, after removing?
                            if len(list_of_keys_tup) > 0:
                                list_of_current_keys = ','.join(list_of_keys_tup)
                                # strip leading ','
                                if list_of_current_keys[0] == ',':
                                    list_of_current_keys = list_of_current_keys.lstrip(',')
                            else:   # all keys deleted
                                list_of_current_keys = ''

                    # unset option if everything is gone.
                    if not list_of_channels and not list_of_current_keys:
                        ptr_config_autojoin = weechat.config_get('irc.server.%s.autojoin' % server)
                        if ptr_config_autojoin:
                            rc = weechat.config_option_unset(ptr_config_autojoin)
                        return weechat.WEECHAT_RC_OK
                    
                    if not set_autojoin_list(server,list_of_channels, list_of_current_keys):
                        weechat.prnt(buffer,"%s%s: set new value for option failed..." % (weechat.prefix('error'),SCRIPT_NAME))

        # server and channels given by user
        elif (len(argv) >= 3):
            server = argv[1]
            list_of_current_channels,list_of_current_keys = get_autojoin_list(buffer,server)

            # autojoin option is empty
            if list_of_current_channels == 1:
                weechat.prnt(buffer,"%s%s: nothing to delete..." % (weechat.prefix('error'),SCRIPT_NAME))
                return weechat.WEECHAT_RC_OK
            else:
                list_of_channels = args.split(" ")[2:]
                if list_of_current_keys:
                    list_of_current_keys_tup = list_of_current_keys.split(",")
                else:
                    list_of_current_keys_tup = ''

                for i in list_of_channels:
                    # check if given channel is in list of options
                    if not i in list_of_current_channels:
                        continue
                    channel_key_index = list_of_current_channels.index(i)
                    # channel does not have a key (position of channel > number of keys!)
                    if channel_key_index + 1 > len(list_of_current_keys_tup):
                        list_of_current_channels.remove(i)
#                        if len(list_of_current_channels) <= 0:
#                            list_of_current_channels = ''
                    else: # remove channel and key from autjoin option
                        list_of_current_channels.remove(i)
                        list_of_current_keys_tup.remove(list_of_current_keys_tup[channel_key_index])
                        # does an key exists, after removing?
                        if len(list_of_current_keys_tup) > 0:
                            list_of_current_keys = ','.join(list_of_current_keys_tup)
                            # strip leading ','
                            if list_of_current_keys[0] == ',':
                                list_of_current_keys = list_of_current_keys.lstrip(',')
                        else:   # all keys deleted
                            list_of_current_keys = ''

#                for j in list_of_current_channels:
#                    weechat.prnt(buffer,"chan:%s" % j)
#                for j in list_of_current_keys_tup:
#                    weechat.prnt(buffer,"key :%s" % j)

                # unset option if everything is gone.
                if not list_of_current_channels and not list_of_current_keys:
                    ptr_config_autojoin = weechat.config_get('irc.server.%s.autojoin' % server)
                    if ptr_config_autojoin:
                        rc = weechat.config_option_unset(ptr_config_autojoin)
                    return weechat.WEECHAT_RC_OK

                if not set_autojoin_list(server,list_of_current_channels, list_of_current_keys):
                    weechat.prnt(buffer,"%s%s: set new value for option failed..." % (weechat.prefix('error'),SCRIPT_NAME))

    return weechat.WEECHAT_RC_OK
Пример #34
0
	def save_helpers(self, run_callback = True):
		''' Save the current helpers to the configuration. '''
		weechat.config_option_set(self.__helpers, json.dumps(self.helpers), run_callback)
Пример #35
0
def wee_ns_serv_sect_read_cb(data, config_file, section, option_name, value):
    return weechat.config_option_set(server.options[option_name], value, 0)
Пример #36
0
def config_set(option, value):
    option = weechat.config_get(option)
    if option:
        weechat.config_option_set(option, value, 1)
Пример #37
0
def wee_ns_serv_sect_read_cb(data, config_file, section, option_name, value):
    return weechat.config_option_set(server.options[option_name], value, 0)
Пример #38
0
	def save_replacements(self, run_callback = True):
		''' Save the current replacement patterns to the configuration. '''
		weechat.config_option_set(self.__replacements, encode_replacements(self.replacements), run_callback)
Пример #39
0
	def save_replacements(self, run_callback = True):
		''' Save the current replacement patterns to the configuration. '''
		weechat.config_option_set(self.__replacements, encode_replacements(self.replacements), run_callback)
Пример #40
0
def save_new_force_nicks():
    global colored_nicks
#    new_nick_color_force = ';'.join([ ':'.join(item) for item in colored_nicks.items()])
    new_nick_color_force = ';'.join([ ':'.join(item) for item in list(colored_nicks.items())])
    config_pnt = weechat.config_get('irc.look.nick_color_force')
    weechat.config_option_set(config_pnt,new_nick_color_force,1)
Пример #41
0
def save_new_force_nicks():
    global colored_nicks
    new_nick_color_force = ';'.join([ ':'.join(item) for item in sorted(colored_nicks.items())])
    config_pnt = weechat.config_get(nick_option)
    weechat.config_option_set(config_pnt,new_nick_color_force,1)
Пример #42
0
import datetime

weechat.register("soju", "soju", "0.2.0", "AGPL3", "soju bouncer integration",
                 "", "")

BOUNCER_CAP = "soju.im/bouncer-networks"
READ_CAP = "soju.im/read"

caps_option = weechat.config_get("irc.server_default.capabilities")
caps = weechat.config_string(caps_option)
for name in [READ_CAP, BOUNCER_CAP]:
    if name not in caps:
        if caps != "":
            caps += ","
        caps += name
        weechat.config_option_set(caps_option, caps, 1)

main_server = None
added_networks = {}
read_times = {}


def server_by_name(server_name):
    hdata = weechat.hdata_get("irc_server")
    server_list = weechat.hdata_get_list(hdata, "irc_servers")
    weechat_version = int(weechat.info_get("version_number", "") or 0)
    if weechat_version >= 0x03040000:
        return weechat.hdata_search(
            hdata,
            server_list,
            "${irc_server.name} == ${name}",
Пример #43
0
	def save_rules(self, run_callback = True):
		''' Save the current rules to the configuration. '''
		weechat.config_option_set(self.__rules, RuleList.encode(self.rules), run_callback)
Пример #44
0
def weeNS_server_section_read_cb(data, config_file, section, option_name, value) :
    global server
    return weechat.config_option_set(server.options[option_name], value, 0)
Пример #45
0
	def save_rules(self, run_callback = True):
		''' Save the current rules to the configuration. '''
		weechat.config_option_set(self.__rules, RuleList.encode(self.rules), run_callback)
Пример #46
0
def add_autojoin_cmd_cb(data, buffer, args):
    if args == "":  # no args given. quit
        return weechat.WEECHAT_RC_OK

    argv = args.strip().split(" ")

    #    if (len(argv) <= 1):
    #        weechat.prnt(buffer,"%s%s: too few arguments." % (weechat.prefix('error'),SCRIPT_NAME))
    #        return weechat.WEECHAT_RC_OK

    server = weechat.buffer_get_string(buffer, "localvar_server")  # current server
    channel = weechat.buffer_get_string(buffer, "localvar_channel")  # current channel
    buf_type = weechat.buffer_get_string(buffer, "localvar_type")

    # only "add <servername>" given by user
    if len(argv) == 2:
        weechat.prnt(buffer, "%s%s: invalid number of arguments." % (weechat.prefix("error"), SCRIPT_NAME))
        return weechat.WEECHAT_RC_OK

    # '-key' keyword in command line?
    if "-key" in argv:
        found_key_word = argv.index("-key")
        key_words = argv[int(found_key_word) + 1 :]
        # don't use "-key" in argv
        argv = argv[: int(found_key_word)]

    # ADD argument
    if argv[0].lower() == "add":
        # add current channel to autojoin. Only option "add" was given..
        if len(argv) == 1:
            if server == "" or channel == "" or server == channel or buf_type == "" or buf_type != "channel":
                weechat.prnt(
                    buffer, "%s%s: current buffer is not a channel buffer." % (weechat.prefix("error"), SCRIPT_NAME)
                )
                return weechat.WEECHAT_RC_OK
            list_of_channels, list_of_current_keys = get_autojoin_list(server)
            # no channels in option!
            if list_of_channels == 1 and list_of_current_keys == 1:
                ptr_config_autojoin = weechat.config_get("irc.server.%s.autojoin" % server)
                rc = weechat.config_option_set(ptr_config_autojoin, channel, 1)
                return weechat.WEECHAT_RC_OK
            if channel in list_of_channels:
                weechat.prnt(
                    buffer,
                    "%s%s: channel '%s' already in autojoin for server '%s'"
                    % (weechat.prefix("error"), SCRIPT_NAME, channel, server),
                )
            else:
                # first char of channel '#' ?
                if channel[0] == "#":
                    if "-key" in args and len(key_words) > 1:
                        weechat.prnt(
                            buffer,
                            "%s%s: too many key(s) for given channel(s) " % (weechat.prefix("error"), SCRIPT_NAME),
                        )
                        return weechat.WEECHAT_RC_OK
                    elif "-key" in args and len(key_words) == 1:
                        list_of_channels.insert(0, channel)
                        list_of_current_keys = ",".join(key_words)
                        # strip leading ','
                        if list_of_current_keys[0] == ",":
                            list_of_current_keys = list_of_current_keys.lstrip(",")
                    else:
                        list_of_channels.append(channel)

                    if not set_autojoin_list(server, list_of_channels, list_of_current_keys):
                        weechat.prnt(
                            buffer, "%s%s: set new value for option failed..." % (weechat.prefix("error"), SCRIPT_NAME)
                        )
        # server and channels given by user
        elif len(argv) >= 3:
            server = argv[1]
            list_of_channels = argv[2:]
            if "-key" in args and len(list_of_channels) < len(key_words):
                weechat.prnt(
                    buffer, "%s%s: too many key(s) for given channel(s) " % (weechat.prefix("error"), SCRIPT_NAME)
                )
                return weechat.WEECHAT_RC_OK

            list_of_current_channels, list_of_current_keys = get_autojoin_list(server)
            # autojoin option is empty
            if list_of_current_channels == 1:
                # no channel -> no key!
                list_of_current_keys = ""
                if "-key" in args:
                    list_of_current_keys = ",".join(key_words)
                    # strip leading ','
                    if list_of_current_keys[0] == ",":
                        list_of_current_keys = list_of_current_keys.lstrip(",")
                if not set_autojoin_list(server, list_of_channels, list_of_current_keys):
                    weechat.prnt(
                        buffer, "%s%s: set new value for option failed..." % (weechat.prefix("error"), SCRIPT_NAME)
                    )
            else:
                if "-key" in args:
                    j = 0
                    new_keys = []
                    list_of_new_keys = []
                    for i in list_of_channels:
                        if i not in list_of_current_channels and j <= len(key_words):
                            #                            weechat.prnt(buffer,"channel: %s, channel key is: '%s'" % (i,key_words[j]))
                            list_of_current_channels.insert(j, i)
                            new_keys.insert(j, key_words[j])
                        j += 1
                    missing_channels = list_of_current_channels
                    list_of_new_keys = ",".join(new_keys)
                    if list_of_current_keys:
                        list_of_current_keys = list_of_new_keys + "," + list_of_current_keys
                    else:
                        list_of_current_keys = list_of_new_keys
                    # strip leading ','
                    if list_of_current_keys[0] == ",":
                        list_of_current_keys = list_of_current_keys.lstrip(",")
                else:
                    # check given channels with channels already set in option
                    missing_channels = get_difference(list_of_channels, list_of_current_channels)
                    missing_channels = list_of_current_channels + missing_channels

                if not set_autojoin_list(server, missing_channels, list_of_current_keys):
                    weechat.prnt(
                        buffer, "%s%s: set new value for option failed..." % (weechat.prefix("error"), SCRIPT_NAME)
                    )
        return weechat.WEECHAT_RC_OK

    # DEL argument
    if argv[0].lower() == "del":
        # del current channel from autojoin. Only option "del" was given..
        if len(argv) == 1:
            if server == "" or channel == "" or server == channel or buf_type == "" or buf_type != "channel":
                weechat.prnt(
                    buffer, "%s%s: current buffer is not a channel buffer." % (weechat.prefix("error"), SCRIPT_NAME)
                )
                return weechat.WEECHAT_RC_OK
            list_of_channels, list_of_keys = get_autojoin_list(server)
            # no channels in option, nothing to delete
            if list_of_channels == 1 and list_of_current_keys == 1:
                return weechat.WEECHAT_RC_OK
            if channel not in list_of_channels:
                weechat.prnt(
                    buffer,
                    "%s%s: channel '%s' not found in autojoin for server '%s'"
                    % (weechat.prefix("error"), SCRIPT_NAME, channel, server),
                )
                return weechat.WEECHAT_RC_OK
            else:
                # first char of channel '#' ?
                if channel[0] == "#":
                    channel_key_index = list_of_channels.index(channel)
                    if not list_of_keys:
                        list_of_channels.remove(list_of_channels[channel_key_index])
                        list_of_current_keys = ""
                    else:
                        list_of_keys_tup = list_of_keys.split(",")
                        list_of_current_keys = list_of_keys
                        # channel does not have a key (position of channel > number of keys!)
                        if channel_key_index + 1 > len(list_of_keys_tup):
                            list_of_channels.remove(list_of_channels[channel_key_index])
                        # remove channel and key from autjoin option
                        else:
                            list_of_channels.remove(list_of_channels[channel_key_index])
                            list_of_keys_tup.remove(list_of_keys_tup[channel_key_index])
                            # does a key exists, after removing?
                            if len(list_of_keys_tup) > 0:
                                list_of_current_keys = ",".join(list_of_keys_tup)
                                # strip leading ','
                                if list_of_current_keys[0] == ",":
                                    list_of_current_keys = list_of_current_keys.lstrip(",")
                            else:  # all keys deleted
                                list_of_current_keys = ""

                    # unset option if everything is gone.
                    if not list_of_channels and not list_of_current_keys:
                        ptr_config_autojoin = weechat.config_get("irc.server.%s.autojoin" % server)
                        if ptr_config_autojoin:
                            rc = weechat.config_option_unset(ptr_config_autojoin)
                        return weechat.WEECHAT_RC_OK

                    if not set_autojoin_list(server, list_of_channels, list_of_current_keys):
                        weechat.prnt(
                            buffer, "%s%s: set new value for option failed..." % (weechat.prefix("error"), SCRIPT_NAME)
                        )

        # server and channels given by user
        elif len(argv) >= 3:
            server = argv[1]
            list_of_current_channels, list_of_current_keys = get_autojoin_list(server)
            # autojoin option is empty
            if list_of_current_channels == 1:
                weechat.prnt(buffer, "%s%s: nothing to delete..." % (weechat.prefix("error"), SCRIPT_NAME))
                return weechat.WEECHAT_RC_OK
            else:
                list_of_channels = args.split(" ")[2:]
                if list_of_current_keys:
                    list_of_current_keys_tup = list_of_current_keys.split(",")
                else:
                    list_of_current_keys_tup = ""

                for i in list_of_channels:
                    # check if given channel is in list of options
                    if not i in list_of_current_channels:
                        continue
                    channel_key_index = list_of_current_channels.index(i)
                    # channel does not have a key (position of channel > number of keys!)
                    if channel_key_index + 1 > len(list_of_current_keys_tup):
                        list_of_current_channels.remove(i)
                    #                        if len(list_of_current_channels) <= 0:
                    #                            list_of_current_channels = ''
                    else:  # remove channel and key from autjoin option
                        list_of_current_channels.remove(i)
                        list_of_current_keys_tup.remove(list_of_current_keys_tup[channel_key_index])
                        # does an key exists, after removing?
                        if len(list_of_current_keys_tup) > 0:
                            list_of_current_keys = ",".join(list_of_current_keys_tup)
                            # strip leading ','
                            if list_of_current_keys[0] == ",":
                                list_of_current_keys = list_of_current_keys.lstrip(",")
                        else:  # all keys deleted
                            list_of_current_keys = ""

                #                for j in list_of_current_channels:
                #                    weechat.prnt(buffer,"chan:%s" % j)
                #                for j in list_of_current_keys_tup:
                #                    weechat.prnt(buffer,"key :%s" % j)

                # unset option if everything is gone.
                if not list_of_current_channels and not list_of_current_keys:
                    ptr_config_autojoin = weechat.config_get("irc.server.%s.autojoin" % server)
                    if ptr_config_autojoin:
                        rc = weechat.config_option_unset(ptr_config_autojoin)
                    return weechat.WEECHAT_RC_OK

                if not set_autojoin_list(server, list_of_current_channels, list_of_current_keys):
                    weechat.prnt(
                        buffer, "%s%s: set new value for option failed..." % (weechat.prefix("error"), SCRIPT_NAME)
                    )

    return weechat.WEECHAT_RC_OK
Пример #47
0
def save_new_force_nicks():
    global colored_nicks
    new_nick_color_force = ';'.join(
        [':'.join(item) for item in colored_nicks.items()])
    config_pnt = weechat.config_get('irc.look.nick_color_force')
    weechat.config_option_set(config_pnt, new_nick_color_force, 1)
Пример #48
0
def xdccq_help_cb(data, buffer, args):
    """Callback for /xdccq command."""
    global botname, pack, channel
    response = {
        'add', 'list', 'listall', 'clear', 'clearall',
    }
    if args:
        words = args.strip().split(' ')
        if words[0] in response:
            if words[0] == "add":
                channel = buffer
                botname = words[1]
                pack = numToList(words[2])
                # look for packs aldready added
                # if already in transfer just add to list
                # else add and start transfer

                # check if bot is in auto accept nicks
                autonicks = weechat.config_string(weechat.config_get("xfer.file.auto_accept_nicks")).split(",")

                if not botname in autonicks:
                    xfer_option = weechat.config_get("xfer.file.auto_accept_nicks")
                    newlist = weechat.config_string(xfer_option)+","+botname

                    rc = weechat.config_option_set(xfer_option, newlist, 1)
                    if rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_CHANGED:
                        weechat.prnt('', "%s added to xdcc auto-accept list" % botname)
                    elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_OK_SAME_VALUE:
                        weechat.prnt('', "%s already in xdcc auto-accept list" % botname)
                    elif rc == weechat.WEECHAT_CONFIG_OPTION_SET_ERROR:
                        weechat.prnt('', "Error in adding %s in auto-accept list" % botname)
                else:
                    weechat.prnt('', "%s already in xdcc auto-accept nicks, not added." % botname)

                if len(pack):
                    runcommands()
                    pass
            elif words[0] == "list":
                # if botname[words[1]]:
                #     weechat.prnt('',"%s packs left" % botname[words[1]])
                #     weechat.prnt('',"from %s bot" % words[1])
                # else:
                #     weechat.prnt('',"Botname not in queue. Can't list!")
                pass
            elif words[0] == "listall":
                if len(pack):
                    weechat.prnt('', "%s packs left" % pack)
                    weechat.prnt('', "from %s bot" % botname)
                else:
                    weechat.prnt('', "No packs left")
            elif words[0] == "clear":
                # if botname[words[1]]:
                #     del botname[words[1]]
                #     weechat.prnt('',"%s bot queue cleared" % words[1])
                # else:
                #     weechat.prnt('',"Botname not in queue. Can't clear!")
                pass
            elif words[0] == "clearall":
                botname = ""
                pack = ""
                # botname.clear()
                weechat.prnt('', "Queue cleared")
        else:
            weechat.prnt('', "xdccq error: %s not a recognized command. Try /help xdccq" % words[0])

    return weechat.WEECHAT_RC_OK