예제 #1
0
def create_hooks():
    # create hooks
    weechat.hook_signal('quit', 'quit_signal_cb', '')
    weechat.hook_signal('upgrade_ended', 'upgrade_ended_cb', '')
    weechat.hook_signal('buffer_opened', 'buffer_opened_cb', '')
    weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' )
    weechat.hook_signal('buffer_closing', 'buffer_closing_cb', '')
예제 #2
0
def create_hooks():
    # create hooks
    weechat.hook_signal('quit', 'quit_signal_cb', '')
    weechat.hook_signal('upgrade_ended', 'upgrade_ended_cb', '')
    # low priority for hook_signal('buffer_opened') to ensure that buffer_autoset hook_signal() runs first
    weechat.hook_signal('1000|buffer_opened', 'buffer_opened_cb', '')
    weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' )
    weechat.hook_signal('buffer_closing', 'buffer_closing_cb', '')
예제 #3
0
def main():
    """ Entry point, initializes everything  """

    weechat.register(
        SCRIPT_NAME,
        SCRIPT_AUTHOR,
        SCRIPT_VERSION,
        SCRIPT_LICENSE,
        SCRIPT_DESCRIPTION,
        "", # Shutdown callback function
        "", # Charset (blank for utf-8)
    )

    # Default values for settings
    default_settings = {
        'dbfile': os.path.join(
            weechat.info_get("weechat_dir", ""), "emojis-db.dat")
    }

    # Apply default configuration values if anything is unset
    for option, default in default_settings.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, default)

    # Hook callbacks
    weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
        "configuration_cb", "")
    weechat.hook_command_run("/input return", "transform_cb", "")
    weechat.hook_command_run("/input complete*", "complete_cb", "")
    #weechat.hook_modifier("input_text_display", "collapse_cb", "")

    # Command callbacks
    weechat.hook_command(  # command name
                           SCRIPT_NAME,
                           # description
                           " display :common_name: with its emoji equivalent",
                           # arguments
                           "reload"
                           " || add <name> <emoji>"
                           " || show <emoji>",
                           # description of arguments
                           " name: emoji name, sans colons\n"
                           "emoji: text that replaces :name:\n",
                           # completions
                           "reload || add || show %(emoji_name)", "emojis_cb", "")
    weechat.hook_completion("emoji_name", "Emoji name", "emoji_name_completion_cb", "")

    dbfile = weechat.config_get_plugin("dbfile")

    weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile))

    try:
        load_emojis(dbfile)
    except IOError as e:
        weechat.prnt("",
            "%s%s: Database file %s is missing or inaccessible." \
                    % (weechat.prefix("error"), SCRIPT_NAME, dbfile))
        raise e # TODO: handle this better instead of brutally aborting
예제 #4
0
def init_config():
    for option, (default_value, description) in SW_CONFIG_DEFAULTS.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, default_value)
            sw_config[option] = default_value
        else:
            sw_config[option] = weechat.config_get_plugin(option)
        weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (description, default_value))

    weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'update_config', '')
예제 #5
0
def main():
    """ Entry point, initializes everything  """

    weechat.register(
        SCRIPT_NAME,
        SCRIPT_AUTHOR,
        SCRIPT_VERSION,
        SCRIPT_LICENSE,
        SCRIPT_DESCRIPTION,
        "",  # Shutdown callback function
        "",  # Charset (blank for utf-8)
    )

    # Default values for settings
    default_settings = {
        'dbfile': os.path.join(
            weechat.info_get("weechat_dir", ""), "emojis-db.dat")
    }

    # Apply default configuration values if anything is unset
    for option, default in default_settings.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, default)

    # Hook callbacks
    weechat.hook_config(
        "plugins.var.python." + SCRIPT_NAME + ".*",
        "configuration_cb", "")
    weechat.hook_command_run("/input return", "transform_cb", "")
    weechat.hook_command_run("/input complete*", "complete_cb", "")

    # Command callbacks
    weechat.hook_command(
        "reloademojis", "reload emojis from file",
        "", "", "", "reload_emojis_cb", "")

    dbfile = weechat.config_get_plugin("dbfile")

    weechat.prnt("", "%s: Loading emojis from %s" % (SCRIPT_NAME, dbfile))

    try:
        load_emojis(dbfile)
    except IOError as e:
        weechat.prnt(
            "",
            "%s%s: Database file %s is missing or inaccessible."
            % (weechat.prefix("error"), SCRIPT_NAME, dbfile))
        raise e  # TODO: handle this better instead of brutally aborting
예제 #6
0
def init_script():
    global default_settings

    for option, default_value in default_settings.items():
        if not weechat.config_is_set_plugin(option):
            weechat.config_set_plugin(option, default_value)

    weechat.hook_command(
        "weemustfeed",
        "open/switch to weemustfeed buffer",
        "",
        "",
        "",
        "weemustfeed_command_cb", ""
        )

    weechat.hook_config(
        "plugins.var.python.weemustfeed.interval",
        "weemustfeed_reset_timer_cb", ""
        )
예제 #7
0
def config_init():
    """Add configuration options to weechat."""
    global KEEP_ALIVE_TIMEOUT

    config = {
        "hide_inactive": ("off", "Hide inactive buffers"),
        "hide_private": ("off", "Hide private buffers"),
        "unhide_low": ("off",
            "Unhide a buffer when a low priority message (like JOIN, PART, etc.) has been received"),
        "exemptions": ("", "An enumeration of buffers that should not get hidden"),
        "keep_open": ("off", "Keep a buffer open for a short amount of time"),
        "keep_open_timeout": ("60 * 1000", "Timeout in milliseconds for how long a selected buffer should be kept around"),
    }
    for option, default_value in config.items():
        if weechat.config_get_plugin(option) == "":
            weechat.config_set_plugin(option, default_value[0])
        weechat.config_set_desc_plugin(
            option, '{} (default: "{}")'.format(default_value[1], default_value[0]))

    weechat.hook_config("plugins.var.python.buffer_autohide.keep_open_timeout", "timeout_config_changed_cb", "")
    if weechat.config_is_set_plugin("keep_open_timeout"):
        KEEP_ALIVE_TIMEOUT = eval_expr(weechat.config_get_plugin("keep_open_timeout"))
def main():
    at_config('load')
    # hook our config
    weechat.hook_config(STRIP_VAR+'*','at_config','')
    # hook the nick complete
    weechat.hook_command_run('/input complete_next', 'at_completion', '')
    # hook the /atcomplete
    weechat.hook_command('atcomplete','manage @nick completion plugin',
        '[enable|disable|toggle] '
        ' | [servers [list | add name | del name]]'
        ' | [buffers [list | add name | del name]]',
        'args desc',
        'status %-'
        ' || enable %-'
        ' || disable %-'
        ' || toggle %-'
        ' || server list|add|del %(buffers_names)'
        ' || buffer list|add|del %(buffers_names)'
        ,
        'at_control','')
    # hook the completetion for /atcomplete
    weechat.hook_completion('plugin_at_completion','@nick completion','at_complete','')
예제 #9
0
        else:
            OPTIONS[option] = weechat.config_get_plugin(option)
        weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))

def toggle_refresh(pointer, name, value):
    global OPTIONS
    option = name[len('plugins.var.python.' + SCRIPT_NAME + '.'):]        # get optionname
    OPTIONS[option] = value                                               # save new value
    return weechat.WEECHAT_RC_OK

# ================================[ main ]===============================
if __name__ == "__main__":
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        weechat.hook_command(SCRIPT_NAME,SCRIPT_DESC,
                        '',
                        'You have to edit options with: /set *autosavekey*\n'
                        'I suggest using /fset plugin (or /iset script).\n',
                        '',
                        'print_usage',
                        '')
        version = weechat.info_get("version_number", "") or 0

        if int(version) >= 0x00030200:
            init_options()
            weechat.hook_config( 'plugins.var.python.' + SCRIPT_NAME + '.*', 'toggle_refresh', '' )
            weechat.hook_signal("*,irc_raw_in_mode","irc_raw_in_mode_cb","")
            weechat.hook_signal("*,irc_raw_in_324","irc_raw_in_324_cb","")
        else:
            weechat.prnt("","%s%s %s" % (weechat.prefix("error"),SCRIPT_NAME,": needs version 0.3.2 or higher"))
            weechat.command("","/wait 1ms /python unload %s" % SCRIPT_NAME)
예제 #10
0

SETTINGS = {
    "args-first": ["no", "whether or not to sort modes with args first"]
}

if import_ok and w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                            SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
    for name, (default, description) in SETTINGS.items():
        if not w.config_is_set_plugin(name):
            w.config_set_plugin(name, default)
            w.config_set_desc_plugin(name, description)

    w.bar_item_new("better_nick", "bar_item_nick", "")
    w.bar_item_new("better_umodes", "bar_item_umodes", "")
    w.bar_item_new("better_cmodes", "bar_item_cmodes", "")
    w.bar_item_new("better_prefix", "bar_item_prefix", "")
    w.bar_item_new("better_prompt", "bar_item_prompt", "")
    items_update()

    w.hook_config(f"plugins.var.python.{SCRIPT_NAME}.*", "config_plugin", '')
    w.hook_config("irc.color.item_channel_modes", "config_channel", '')
    w.hook_config("irc.color.item_nick_modes", "config_user", '')
    w.hook_config("irc.color.nick_prefixes", "config_prefix", '')
    w.hook_config("irc.color.input_nick", "config_nick", '')
    w.hook_config("weechat.bar.input.color_delim", "config_delim", '')

    w.hook_signal("*,irc_in_MODE", "signal_mode", '')
    w.hook_signal("*,irc_in_221", "signal_mode", '')  # RPL_UMODEIS
    w.hook_signal("*,irc_in_324", "signal_mode", '')  # RPL_CHANNELMODEIS
예제 #11
0
    weechat.config_set_desc_plugin('data_timeout',
                                   'Time before a message is expired.')

    weechat.config_set_desc_plugin('message_limit',
                                   'Number of messages to store per nick.')

    weechat.config_set_desc_plugin(
        'print_format', 'Format string for the printed corrections.')

    weechat.config_set_desc_plugin('print_limit',
                                   'Maximum number of lines to correct.')

    return weechat.WEECHAT_RC_OK


if __name__ == '__main__' and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        # Load the configuration options.
        load_config()

        # Set up the descriptions for each option.
        desc_options()

        # Register hook to run load_config when options are changed.
        weechat.hook_config('plugins.var.python.{}.*'.format(SCRIPT_NAME),
                            'load_config', '')

        # Register hook_print to process each new message as it comes in.
        weechat.hook_print('', '', '', 1, 'handle_message_cb', '')
예제 #12
0
                             "            size: set max size (width and height) for layout to be automatically applied\n"
                             "        nicklist: show or hide nicklist bar when layout is automatically applied\n"
                             "default_nicklist: default show or hide nicklist bar if not configured per layout\n"
                             "          remove: remove settings for responsive layout\n"
                             "            list: list current configuration\n"
                             "        terminal: list current terminal width and height\n"
                             "           debug: print script debug output\n\n"
                             "To get current layout and terminal dimensions in your bar, use 'rlayout' bar item.",
                             "size %(layouts_names)"
                             " || nicklist %(layouts_names) %(rlayout_bool_value)"
                             " || default_nicklist %(rlayout_bool_value)"
                             " || remove %(rlayouts_names)"
                             " || list"
                             " || terminal"
                             " || debug %(rlayout_bool_value)",
                             "rlayout_cmd_cb",
                             "")

        # Default settings
        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]))

        weechat.hook_completion("rlayout_bool_value", "list of bool values", "rlayout_completion_bool_cb", "")
        weechat.hook_completion("rlayouts_names", "list of rlayouts", "rlayout_completion_layout_list_cb", "")
        weechat.hook_config("plugins.var.python.responsive_layout.layout.*", "config_cb", "")
        weechat.bar_item_new("rlayout", "rlayout_bar_cb", "")
        update_layout_list()
        hook = weechat.hook_signal("signal_sigwinch", "responsive_cb", "")
예제 #13
0
파일: memon.py 프로젝트: Shrews/scripts
def notify(data, signal, signal_data):
    if state and MEMOSERVICE in signal_data:
        if new_memo_from.match(signal_data) or connect_memo.match(signal_data):
            msg = signal_data.rpartition(":")[2]

            subprocess.call(["/usr/bin/notify-send", "MemoN", "{0}".format(msg), "-t", time], shell=False)

    return weechat.WEECHAT_RC_OK


if weechat.register(SCRIPT_COMMAND, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
    get_state("", "", "")
    get_time("", "", "")

weechat.hook_config("plugins.var.python." + SCRIPT_COMMAND + ".state", "get_state", "")
weechat.hook_config("plugins.var.python." + SCRIPT_COMMAND + ".time", "get_time", "")
weechat.hook_signal("*,irc_in2_notice", "notify", "")

weechat.hook_command(
    SCRIPT_COMMAND,
    """Freenode memo notifications

If the user receives a memo a little notification window will apear

Requires libnotify!

Author: Barbu Paul - Gheorghe <*****@*****.**>

LICENSE:
예제 #14
0
        # set default settings
        version = weechat.info_get("version_number", "") or 0
        for option, value in cmdhelp_settings_default.items():
            if weechat.config_is_set_plugin(option):
                cmdhelp_settings[option] = weechat.config_get_plugin(option)
            else:
                weechat.config_set_plugin(option, value[0])
                cmdhelp_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(
                    option,
                    '%s (default: "%s")' % (value[1], value[0]))

        # detect config changes
        weechat.hook_config('plugins.var.python.%s.*' % SCRIPT_NAME,
                            'config_cb', '')

        # add hook to catch "enter" key
        if cmdhelp_settings['stop_on_enter'] == 'on':
            cmdhelp_hooks['command_run'] = weechat.hook_command_run(
                '/input return', 'command_run_cb', '')

        # add command
        weechat.hook_command(
            SCRIPT_COMMAND,
            'Contextual command line help.',
            '',
            'This comand toggles help on command line.\n\n'
            'It is recommended to bind this command on a key, for example '
            'F1:\n'
            '  /key bind <press alt-k> <press F1> /cmd_help\n'
예제 #15
0
파일: autosort.py 프로젝트: 0xdkay/dotfiles
## Example
As an example, consider the following rule list:
0: core            = 0
1: irc             = 2
2: *               = 1

3: irc.server.*.#* = 1
4: irc.server.*.*  = 0

Rule 0 ensures the core buffer is always sorted first.
Rule 1 sorts IRC buffers last and rule 2 puts all remaining buffers in between the two.

Rule 3 and 4 would make no sense with the group_irc option off.
With the option on though, these rules will sort private buffers before regular channel buffers.
Rule 3 matches channel buffers and assigns them a higher score,
while rule 4 matches the buffers that remain and assigns them a lower score.
The same effect could also be achieved with a single rule:
irc.server.*.[^#]* = 0
'''

command_completion = 'sort||rules list|add|insert|update|delete|move|swap||replacements list|add|insert|update|delete|move|swap'


if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
	config = Config('autosort')

	weechat.hook_config('autosort.*',      'on_config_changed',  '')
	weechat.hook_command('autosort', command_description, '', '', command_completion, 'on_autosort_command', 'NULL')
	on_config_changed()
예제 #16
0
                   '', '', '', 'hloff_cb', '')
    w.hook_command('hltimer',
                   'Set highlightxmpp timer status automatically after a period of '
                   'inactivity.',
                   '[time|off]',
                   '      time: minutes of inactivity to set highlightxmpp timer\n'
                   '       off: set highlightxmpp timer off (0 also sets off)\n'
                   '\n'
                   'Without any arguments prints the current settings.\n'
                   '\n'
                   'Examples:\n'
                   '\n'
                   '/hltimer 20\n'
                   'Sets highlightxmpp timer to 20 minutes'
                   '\n'
                   '/hltimer off\n'
                   '/hltimer 0\n'
                   'Disables highlightxmpp timer.\n',
                   '',
                   'hltimer_cmd', '')
    w.hook_config('plugins.var.python.highlightxmpp.idletime',
                  'switch_chk', '')
    w.hook_config('plugins.var.python.highlightxmpp.status_prnt',
                  'print_chk', '')

    version = w.info_get('version_number', '') or 0
    timer_hook = None
    input_hook = None

    timer_hook_function()
예제 #17
0
                       "[time|off] [message]",
                       "      time: minutes of inactivity to set away\n"
                       "       off: disable auto-away (0 also disables)\n"
                       "   message: away message (optional)\n"
                       "\n"
                       "Without any arguments prints the current settings.\n"
                       "\n"
                       "Examples:\n"
                       "\n"
                       "/autoaway 20 I'm away\n"
                       "Sets auto-away to 20 minutes, and away message to "
                       "'I'm away'.\n"
                       "\n"
                       "/autoaway 30\n"
                       "Sets auto-away to 30 minutes, and uses the previously "
                       "set, or default, away message.\n"
                       "\n"
                       "/autoaway off\n"
                       "/autoaway 0\n"
                       "Disables auto-away.\n",
                       "",
                       "autoaway_cmd", "")
        w.hook_config("plugins.var.python.auto_away.idletime",
                      "switch_chk", "")

        version = w.info_get("version_number", "") or 0
        timer_hook = None
        input_hook = None

        timer_hook_function()
예제 #18
0
            '%%h/%s' % SCRIPT_SAVEFILE,
            {},
            {},
            options,
        )
        # Set default settings
        version = weechat.info_get("version_number", "") or 0
        for option, value in list(zncplayback_settings_default.items()):
            if weechat.config_is_set_plugin(option):
                zncplayback_settings[option] = weechat.config_get_plugin(
                    option)
            else:
                weechat.config_set_plugin(option, value[0])
                zncplayback_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(
                    option, "%s (default: \"%s\")" % (value[1], value[0]))

        read_last_times()
        zncplayback_hooks["config"] = weechat.hook_config(
            "plugins.var.python.%s.*" % SCRIPT_NAME, "zncplayback_config_cb",
            "")
        zncplayback_hooks["connected"] = weechat.hook_signal(
            "irc_server_connected", "zncplayback_connected_cb", "")
        for serv in zncplayback_settings["servers"].split(","):
            zncplayback_hooks["messages"][serv] = weechat.hook_signal(
                "{},irc_raw_in_PRIVMSG".format(serv), "zncplayback_message_cb",
                serv)

        # TODO: Unhook when unloading script
def config_cb(data, option, value):
	"""Handle config hooks (option changes)."""

	option = option[len(SETTINGS_PREFIX):]

	if SETTINGS[option][2]: # if option requires modifier hooks update
		hook_modifiers()

	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_command(SCRIPT_COMMAND, SCRIPT_DESC,
"""reload
 || redownload""",
"""    reload: reload replacements from XML file
redownload: redownload replacements XML file and load it""",
"""reload
 || redownload""",
		"command_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.hook_config(SETTINGS_PREFIX + "*", "config_cb", "")

		setup()
예제 #20
0
                w.command("", cmd)

    return w.WEECHAT_RC_OK


if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
              SCRIPT_DESC, "", ""):
    version = w.info_get('version_number', '') or 0
    for option, default_desc in settings.iteritems():
        if not w.config_is_set_plugin(option):
            w.config_set_plugin(option, default_desc[0])
        if int(version) >= 0x00030500:
            w.config_set_desc_plugin(option, default_desc[1])

    if 'STY' in os.environ.keys():
        # We are running under screen
        cmd_output = os.popen('env LC_ALL=C screen -ls').read()
        match = re.search(r'Sockets? in (/.+)\.', cmd_output)
        if match:
            SOCK = os.path.join(match.group(1), os.environ['STY'])

    if not SOCK and 'TMUX' in os.environ.keys():
        # We are running under tmux
        socket_data = os.environ['TMUX']
        SOCK = socket_data.rsplit(',', 2)[0]

    if SOCK:
        set_timer()
        w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
                      "screen_away_config_cb", "")
                "server (all channels) (requires WeeChat >= 0.3.4):\n"
                "    /" + SCRIPT_COMMAND + " add irc.freenode.* "
                "hotlist_max_level_nicks_add bot:-1",
                "add %(buffers_plugins_names)|"
                "%(buffer_autoset_current_buffer) "
                "%(buffer_properties_set)"
                " || del %(buffer_autoset_options)", "bas_cmd", "")
            weechat.hook_completion("buffer_autoset_current_buffer",
                                    "current buffer name for buffer_autoset",
                                    "bas_completion_current_buffer_cb", "")
            weechat.hook_completion("buffer_autoset_options",
                                    "list of options for buffer_autoset",
                                    "bas_completion_options_cb", "")
            weechat.hook_signal("9000|buffer_opened",
                                "bas_signal_buffer_opened_cb", "")
            weechat.hook_config("%s.buffer.*" % CONFIG_FILE_NAME,
                                "bas_config_option_cb", "")

            # core buffer is already open on script startup, check manually!
            bas_signal_buffer_opened_cb("", "", weechat.buffer_search_main())

# ==================================[ end ]===================================


def bas_unload_script():
    """ Function called when script is unloaded. """
    global bas_config_file

    if bas_config_file:
        bas_config_write()
    return weechat.WEECHAT_RC_OK
예제 #22
0

def conf_update_cb(data, option, value):
    #Commit data if not part of ignore list.
    if weechat.config_get_plugin(
            "commit_each_change"
    ) == "true" and not option in weechat.config_get_plugin(
            "auto_commit_ignore").split(","):
        #Call use pause else /save will be called before the config is actually saved to disc
        #This is kinda hack but better input would be appricated.
        weechat.hook_timer(500, 0, 1, "commit_cb", "")
    return weechat.WEECHAT_RC_OK


def confversion_cmd(data, buffer, args):
    commit_cb()
    return weechat.WEECHAT_RC_OK


if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                    SCRIPT_DESC, "", ""):
    for option, default_value in settings.items():
        if weechat.config_get_plugin(option) == "":
            weechat.config_set_plugin(option, default_value)

    weechat.hook_command("confversion",
                         "Saves configurations to version control", "", "", "",
                         "confversion_cmd", "")
    init_repo()
    hook = weechat.hook_config("*", "conf_update_cb", "")
예제 #23
0
def config_changed(data, option, value):
    init_config()
    return w.WEECHAT_RC_OK

def tc_action_cb():
    global tc_options
    if tc_options['warn_command']:
        if tc_options['warn_command'] == '$bell':
            f = open('/dev/tty', 'w')
            f.write('\a')
            f.close()
        else:
            os.system(tc_options['warn_command'])
    return w.WEECHAT_RC_OK

if __name__ == "__main__" and import_ok:
    if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                  SCRIPT_LICENSE, SCRIPT_DESC,
                  "", ""):
        version = w.info_get("version_number", "") or 0
        init_config() # read configuration
        tc_bar_item_update() # update status bar display

        w.hook_signal('input_text_changed', 'tc_bar_item_update', '')
        w.hook_signal('input_text_cursor_moved','tc_bar_item_update','')
        w.hook_command_run('/input move_previous_char','command_run_cb','')
        w.hook_command_run('/input delete_previous_char','command_run_cb','')
        w.hook_signal('buffer_switch','tc_bar_item_update','')
        w.hook_config('plugins.var.python.' + SCRIPT_NAME + ".*", "config_changed", "")
        w.bar_item_new('tc', 'tc_bar_item', '')
예제 #24
0
    weechat.config_set_desc_plugin('data_timeout',
                                   'Time before a message is expired.')

    weechat.config_set_desc_plugin('message_limit',
                                   'Number of messages to store per nick.')

    weechat.config_set_desc_plugin(
        'print_format', 'Format string for the printed corrections.')

    weechat.config_set_desc_plugin('print_limit',
                                   'Maximum number of lines to correct.')

    return weechat.WEECHAT_RC_OK


if __name__ == '__main__' and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        # Load the configuration options.
        load_config()

        # Set up the descriptions for each option.
        desc_options()

        # Register hook to run load_config when options are changed.
        weechat.hook_config('plugins.var.python.%s.*' % SCRIPT_NAME,
                            'load_config', '')

        # Register hook_print to process each new message as it comes in.
        weechat.hook_print('', '', '', 1, 'handle_message_cb', '')
예제 #25
0
파일: fish.py 프로젝트: oakkitten/scripts
            "\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\n"
            "\n** stores keys in plaintext by default **\n\n"
            "DH1080:                    /blowkey exchange 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) %-",
            "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", "")
예제 #26
0
def command_factreload(data, buffer, args):
    """Reload factoids."""
    return load_factoids()


def kwfactoids_completion_cb(data, completion_item, buffer, completion):
    """Add completion for factoids."""
    for factoid in FACTOIDS:
        weechat.hook_completion_list_add(completion, factoid, 0,
                                         weechat.WEECHAT_LIST_POS_SORT)
    return weechat.WEECHAT_RC_OK


load_factoids()

weechat.hook_command(
    "factoid", "Send a factoid to channel.", "[factoid] [user]",
    "factoid is name of factoid, user (optional) is user to direct the factoid at.",
    "%(kwfactoidsc) %(nicks)", "command_factoid", "")
weechat.hook_command(
    "f", "Send a factoid to channel.", "[factoid] [user]",
    "factoid is name of factoid, user (optional) is user to direct the factoid at.",
    "%(kwfactoidsc) %(nicks)", "command_factoid", "")
weechat.hook_command("factreload", "Reload factoids.", "", "", "",
                     "command_factreload", "")
weechat.hook_completion("kwfactoidsc", "Factoid completion",
                        "kwfactoids_completion_cb", "")
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb",
                    "")
예제 #27
0
    return w.WEECHAT_RC_OK

def update_blacklist(*args):
    ''' Set the blacklist for channels and nicks. '''
    global ignore_channels, ignore_nicks
    ignore_channels = w.config_string(colorize_config_option['blacklist_channels']).split(',')
    ignore_nicks = w.config_string(colorize_config_option['blacklist_nicks']).split(',')
    return w.WEECHAT_RC_OK

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

        # Run once to get data ready
        update_blacklist()
        populate_nicks()

        w.hook_signal('nicklist_nick_added', 'add_nick', '')
        w.hook_signal('nicklist_nick_removed', 'remove_nick', '')
        w.hook_modifier('weechat_print', 'colorize_cb', '')
        # Hook config for changing colors
        w.hook_config('weechat.color.chat_nick_colors', 'populate_nicks', '')
        # Hook for working togheter with other scripts (like colorize_lines)
        w.hook_modifier('colorize_nicks', 'colorize_cb', '')
        # Hook for modifying input
        w.hook_modifier('250|input_text_display', 'colorize_input_cb', '')
        # Hook for updating blacklist (this could be improved to use fnmatch)
        weechat.hook_config('%s.look.blacklist*' % SCRIPT_NAME, 'update_blacklist', '')
예제 #28
0
        name = None
        never_away = False
        hotlist = w.infolist_get("hotlist", "", "")
        main_weechat_buffer = w.info_get(
            "irc_buffer", "%s.%s" % (domain, "DOESNOTEXIST!@#$"))

        ### End global var section

        #channels = SearchList()
        servers = SearchList()
        for token in slack_api_token.split(','):
            servers.append(SlackServer(token))
        channels = Meta('channels', servers)
        users = Meta('users', servers)

        w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
                      "config_changed_cb", "")
        w.hook_timer(10, 0, 0, "async_queue_cb", "")
        w.hook_timer(6000, 0, 0, "slack_connection_persistence_cb", "")

        ### attach to the weechat hooks we need
        w.hook_timer(1000, 0, 0, "typing_update_cb", "")
        w.hook_timer(1000, 0, 0, "buffer_list_update_cb", "")
        w.hook_timer(1000, 0, 0, "hotlist_cache_update_cb", "")
        w.hook_timer(1000 * 3, 0, 0, "slack_never_away_cb", "")
        w.hook_timer(1000 * 60 * 29, 0, 0, "slack_never_away_cb", "")
        w.hook_signal('buffer_closing', "buffer_closing_cb", "")
        w.hook_signal('buffer_switch', "buffer_switch_cb", "")
        w.hook_signal('window_switch', "buffer_switch_cb", "")
        w.hook_signal('input_text_changed', "typing_notification_cb", "")
        w.hook_command(
            'slack',
예제 #29
0
                "server (all channels) (requires WeeChat >= 0.3.4):\n"
                "    /" + SCRIPT_COMMAND + " add irc.freenode.* "
                "hotlist_max_level_nicks_add bot:-1",
                "add %(buffers_plugins_names)|"
                "%(buffer_autoset_current_buffer) "
                "%(buffer_properties_set)"
                " || del %(buffer_autoset_options)", "as_cmd", "")
            weechat.hook_completion("buffer_autoset_current_buffer",
                                    "current buffer name for autoset",
                                    "as_completion_current_buffer_cb", "")
            weechat.hook_completion("buffer_autoset_options",
                                    "list of options for autoset",
                                    "as_completion_options_cb", "")
            weechat.hook_signal("9000|buffer_opened",
                                "as_signal_buffer_opened_cb", "")
            weechat.hook_config("{}.buffer.*".format(CONFIG_FILE_NAME),
                                "as_config_option_cb", "")

            # apply settings to all already opened buffers
            buffers = weechat.infolist_get("buffer", "", "")
            if buffers:
                while weechat.infolist_next(buffers):
                    buffer = weechat.infolist_pointer(buffers, "pointer")
                    as_signal_buffer_opened_cb("", "", buffer)
                weechat.infolist_free(buffers)

# ==================================[ end ]===================================


def as_unload_script():
    """ Function called when script is unloaded. """
    global as_config_file
예제 #30
0
파일: weetwit.py 프로젝트: netf/weetwit
        user = twitter.api.me()

        # Find timelined
        timelined = which(wc.config_get_plugin("timelined_location"))
        if not timelined:
            print_error(
                "Couldn't find timelined, please set 'plugins.var.python.weetwit.timelined"
            )

        tl = timelined[0]

        setup_timeline(tl, followed=followed)
        bar_item = wc.bar_item_new('tweet_counter', 'tcounter_item_cb', '')

        # Config change hook.
        wc.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
                       "storage_cb", "")

        # All commands
        hook = wc.hook_command(
            "tweet", "Updates your twitter status.", "[tweet]",
            "The text to update with (140 characters max).", "", "tweet_cb",
            "")

        hook = wc.hook_command(
            "tinfo", "Lookup info about a certain tweet.",
            "[tweet id/@username]",
            "The ID of the tweet, if @username is given, the ID of their last tweet is used.",
            "", "tweet_info_cb", "")

        hook = wc.hook_command(
            "treply", "Reply to a specific tweet", "[tweet id/@username]",
예제 #31
0
This should keep your buffers sorted in almost all situations.
However, you may wish to change the list of signals that cause your buffer list to be sorted.
Simply edit the "autosort.sorting.signals" option to add or remove any signal you like.
If you remove all signals you can still sort your buffers manually with the "/autosort sort" command.
To prevent all automatic sorting, "autosort.sorting.sort_on_config_change" should also be set to off.
'''

command_completion = '%(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort) %(plugin_autosort)'

info_replace_description = 'Replace all occurences of `from` with `to` in the string `text`.'
info_replace_arguments   = 'from,to,text'

info_order_description = (
	'Get a zero padded index of a value in a list of possible values.'
	'If the value is not found, the index for `*` is returned.'
	'If there is no `*` in the list, the highest index + 1 is returned.'
)
info_order_arguments   = 'value,first,second,third,...'


if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
	config = Config('autosort')

	weechat.hook_config('autosort.*', 'on_config_changed',  '')
	weechat.hook_completion('plugin_autosort', '', 'on_autosort_complete', '')
	weechat.hook_command('autosort', command_description, '', '', command_completion, 'on_autosort_command', '')
	weechat.hook_info('autosort_replace', info_replace_description, info_replace_arguments, 'on_info_replace', '')
	weechat.hook_info('autosort_order',   info_order_description,   info_order_arguments,   'on_info_order',   '')

	apply_config()
예제 #32
0
def my_config_cb(data, option, value):
    global options

    for boolean_option in boolean_options:
        if option.endswith(boolean_option):
            if value in booleans.keys():
                options[boolean_option] = booleans[w.config_get_plugin(
                    boolean_option)]
            else:
                w.prnt(
                    '',
                    'Error: "%s" is not a boolean, please use "on" or "off"' %
                    w.config_get_plugin(boolean_option))
                w.config_set_plugin(
                    boolean_option,
                    invertdict(booleans)[options[boolean_option]])
    write_file()
    return w.WEECHAT_RC_OK


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

###  HOOKS  ###

w.hook_command("hl2file_clear", "", "", "", "", "clear_file_cb", "")
w.hook_signal("buffer_switch", "buffer_switch_cb", "")
w.hook_signal("window_switch", "buffer_switch_cb", "")
w.hook_print("", "", "", 1, "my_print_cb", "")
예제 #33
0
    if w.config_get_plugin('buffer'):
        buffer = w.buffer_search('', w.config_get_plugin('buffer'))
        hook_it(buffer)
    return WEECHAT_RC_OK


def msg_command_buffer_opened_cb(data, signal, signal_data):

    buffer = signal_data
    buffer_name = w.buffer_get_string(buffer, "name")
    if buffer_name == w.config_get_plugin('buffer'):
        hook_it(buffer)

    return WEECHAT_RC_OK

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


    for opt, val in settings.iteritems():
        if not weechat.config_is_set_plugin(opt):
            weechat.config_set_plugin(opt, val)

    weechat.hook_signal('buffer_opened', 'msg_command_buffer_opened_cb', '')
    weechat.hook_config('plugins.var.python.%s' %SCRIPT_NAME, 'msg_command_conf_update', '')
    msg_command_conf_update() # To init hook


# vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=100:
예제 #34
0
    config_value = weechat.config_get_plugin(option)
    if config_value:
        # value is set in weechat config, store it here
        config[option] = config_value
    else:
        # value isn't set in weechat config, set config value from defaults
        weechat.config_set_plugin(option, default_value)

    # warn if value isn't valid
    if not config[option]:
        weechat.prnt('', 'sendmail_notify:i please set option |%s|' % option)


# setup hooks
weechat.hook_print('', '', '', 1, 'send_message', '')
weechat.hook_config('plugins.var.python.sendmail_notify.*',
                    'update_config', '')


def debug_msg(msg):
    if config['debug'] == 'on':
        weechat.prnt('', 'sendmail_notify: ' + msg)


def is_ping(buffer_type, prefix, channel, highlight):
    """Determine if a message was a ping
       private type AND prefix nick is channel name = ping
       channel type AND highlight = ping
       anything else != ping
    """
    if buffer_type == 'private' and channel == prefix:
        return True
예제 #35
0
파일: twitch.py 프로젝트: vmindru/scripts
        "  want to ignore someone /ignore add re:[~@%]{0,3}nightbot should ignore\n"
        "  a nick with all or none of the prefixes used by this script.\n"
        "  NOTE: This may cause high cpu usage in very active chat and/or on slower cpus.\n"
        "  This can also be disabled by setting\n    /set plugins.var.python.twitch.prefix_nicks 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_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", "")
예제 #36
0
    elif len(args) == 2:
        msg = u": ".join((args[1], ftext))
    else:
        msg = ftext
    weechat.command(buffer, msg.encode("utf-8"))
    return weechat.WEECHAT_RC_OK


def command_factreload(data, buffer, args):
    """Reload factoids."""
    return load_factoids()


def kwfactoids_completion_cb(data, completion_item, buffer, completion):
    """Add completion for factoids."""
    for factoid in FACTOIDS:
        weechat.hook_completion_list_add(completion, factoid, 0, weechat.WEECHAT_LIST_POS_SORT)
    return weechat.WEECHAT_RC_OK

load_factoids()

weechat.hook_command("factoid", "Send a factoid to channel.", "[factoid] [user]",
                     "factoid is name of factoid, user (optional) is user to direct the factoid at.",
                     "%(kwfactoidsc) %(nicks)", "command_factoid", "")
weechat.hook_command("f", "Send a factoid to channel.", "[factoid] [user]",
                     "factoid is name of factoid, user (optional) is user to direct the factoid at.",
                     "%(kwfactoidsc) %(nicks)", "command_factoid", "")
weechat.hook_command("factreload", "Reload factoids.", "", "", "", "command_factreload", "")
weechat.hook_completion("kwfactoidsc", "Factoid completion", "kwfactoids_completion_cb", "")
weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "config_cb", "")
예제 #37
0

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

        # Set default settings
        for option, default_value in settings.iteritems():
            if not w.config_is_set_plugin(option):
                w.config_set_plugin(option, default_value)
        ignore_buffers = Ignores('ignore_buffers')

        w.hook_print("", "", "://", 1, "url_print_cb", "")
        w.hook_timer(\
            int(w.config_get_plugin('reannounce_wait')) * 1000 * 60,
            0,
            0,
            "purge_cb",
            '')
        weechat.hook_config('plugins.var.python.%s.ignore_buffers' %SCRIPT_NAME, 'ignore_update', '')
    color_chat_delimiters = weechat.color('chat_delimiters')
    color_chat_nick       = weechat.color('chat_nick')
    color_reset           = weechat.color('reset')
    color_chat_buffer     = weechat.color('chat_buffer')
    # pretty printing
    script_nick = '%s[%s%s%s]%s' %(color_chat_delimiters,
                                   color_chat_nick,
                                   w.config_get_plugin('global_prefix'),
                                   color_chat_delimiters,
                                   color_reset)
예제 #38
0
                                'nameday_completion_namedays_cb', '')
        weechat.hook_command(SCRIPT_COMMAND,
                             'Display name days',
                             '[* | number | date | name | !]',
                             '     *: display list of name days in a new buffer\n'
                             'number: display name day for today and <number> days in future\n'
                             '  date: display name day for this date, format is day/month (for example: 31/01)\n'
                             '  name: display date for this name\n'
                             '     !: display reminder dates for names defined in option "reminder"\n\n'
                             'A bar item "nameday" can be used in a bar.\n\n'
                             'Examples:\n'
                             '  /nameday *          display list of name days in a new buffer\n'
                             '  /nameday            display name day for today and tomorrow\n'
                             '  /nameday 2          display name day for today, tomorrow, and after tomorrow\n'
                             '  /nameday 20/01      display name day for january, 20th\n'
                             '  /nameday sébastien  display day for name "sébastien"',
                             '*|!|%(namedays)', 'nameday_cmd_cb', '')

        # new item
        nameday_build_item()
        weechat.bar_item_new(SCRIPT_BAR_ITEM, 'nameday_item_cb', '')

        # timer
        weechat.hook_timer(3600 * 24 * 1000, 3600 * 24, 0, 'nameday_timer_cb', '')

        # config
        weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*', 'nameday_config_cb', '')

        # reminder
        nameday_reminder()
예제 #39
0
        else:
            OPTIONS[option] = w.config_get_plugin(option)
        w.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))


def toggle_refresh(pointer, name, value):
    global OPTIONS
    option = name[len("plugins.var.python." + SCR_NAME + ".") :]  # get optionname
    OPTIONS[option] = value  # save new value
    return w.WEECHAT_RC_OK


if __name__ == "__main__" and import_ok:
    if w.register(SCR_NAME, SCR_AUTHOR, SCR_VERSION, SCR_LICENSE, SCR_DESC, "", ""):
        init_options()
        w.hook_config("plugins.var.python." + SCR_NAME + ".*", "toggle_refresh", "")
        parser = MyHTMLParser()
        fn_connected("", "", "")
        # hook to "connected to a server"-signal
        w.hook_signal("irc_server_connected", "fn_connected", "")
        w.hook_command(  # help-text
            SCR_COMMAND,
            "",
            """

The script tries to retrieve your external IP, in three cases:
  1) When it is loaded
  2) whenever you have succesfully connected to a server
  3) when the script is called as a command ("/xfer_setip").

""",
예제 #40
0
    return weechat.WEECHAT_RC_OK


command_description = r'''/autobump add high: Add the current buffer to the high priority list
/autobump add low: Add the current buffer to the low priority list
/autobump del high: Remove the current buffer from the high priority list
/autobump del low: Remove the current buffer from the low priority list

You can manually modify the high/low priority lists (for instance, with custom patterns) with /set var.plugins.python.autobump.highprio_buffers and /set var.plugins.python.autobump.lowprio_buffers.

See /help filter for documentation on writing buffer lists.
'''

command_completion = 'add high || add low || del high || del low'

if __name__ == '__main__':
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        for option, value in DEFAULTS.items():
            if not weechat.config_is_set_plugin(option):
                weechat.config_set_plugin(option, value[0])
            weechat.config_set_desc_plugin(option, value[1])

        update_hook()
        weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.tags',
                            'update_hook', '')
        weechat.hook_signal('buffer_opened', 'on_buffer_open', '')

        weechat.hook_command('autobump', command_description, '', '',
                             command_completion, 'on_autobump_command', '')
예제 #41
0
    error = proc.stderr.read()
    if error != '':
        for line in error.split('\n'):
            if line == 'FATAL_ERROR: The server is not running':
                return STATUS_NOT_RUNNING
            
    output = proc.stdout.read()
    proc.wait()
    return output

# ==================================[ main ]==================================

if __name__ == "__main__" and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "moc_unload", ""):
        load_settings('', '', '')
        weechat.hook_config('plugins.var.python.moc_control.*', 'load_settings', '')

        weechat.bar_item_new('moc_infobar', 'moc_infobar_update', '')
        weechat.hook_timer(infobar['update']*1000,0,0,'moc_infobar_updater','')

        if infobar['enabled']:
            _add_infobar()
        weechat.hook_command(
            SCRIPT_COMMAND,
            'Control moc or display now playing information.',
            'play|pause|pp|stop|prev|next|infobar|help',
            'Commands Available\n'
            '  /moc         - Display currently playing song.\n'
            '  /moc play    - Start playing music.\n'
            '  /moc pause   - Toggle between pause/playing.\n'
            '  /moc pp      - Toggle between pause/playing.\n'
예제 #42
0
def ignore_update(*args):
    ignore_channel._get_ignores()
    ignore_nick._get_ignores()
    ignore_text._get_ignores()
    return WEECHAT_RC_OK


def info_hook_cb(data, info_name, arguments):
    global last_buffer
    return last_buffer


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

    for opt, val in settings.iteritems():
        if not weechat.config_is_set_plugin(opt):
            weechat.config_set_plugin(opt, val)

    ignore_channel = Ignores('ignore_channel')
    ignore_nick = Ignores('ignore_nick')
    ignore_text = Ignores('ignore_text')
    weechat.hook_config('plugins.var.python.%s.ignore_*' % SCRIPT_NAME,
                        'ignore_update', '')

    weechat.hook_print('', '', '', 1, 'away_cb', '')
    w.hook_info('%s_buffer' % SCRIPT_NAME, '', '', 'info_hook_cb', '')

# vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=100:
예제 #43
0
                             "  /uotp list\n"+
                             "  /uotp add freenode 4c6fdb7d0659bae2a16d23bab99678462b9f7897\n"+
                             "  /uotp add freenode jrx5 w7ig lg5o filn eo5l tfty iyvz 66ex\n"+
                             "  /uotp remove freenode\n"+
                             "  /uotp enable freenode\n"+
                             "  /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)
예제 #44
0
        alert("Option {0} is now {1}:".format(myOption, settings[myOption]))
    except KeyError:
        errMsg("There is no option named %s" % myOption)
    return w.WEECHAT_RC_OK


if __name__ == "__main__" and import_ok:
    if w.register(SCR_NAME, SCR_AUTHOR, SCR_VERSION, SCR_LICENSE, SCR_DESC, "",
                  ""):
        # synchronize weechat- and scriptsettings
        for option, default_value in settings.items():
            if not w.config_is_set_plugin(option):
                w.config_set_plugin(option, default_value)
            else:
                settings[option] = w.config_get_plugin(option)
        w.hook_print("", "", "", 1, "fn_privmsg", "")  # catch prvmsg
        w.hook_config("plugins.var.python." + SCR_NAME + ".*",
                      "fn_configchange", "")  # catch configchanges
        w.hook_command(
            SCR_COMMAND, SCR_DESC, "[enabled] [n] [text]", """
Available options are:
- enabled:             can be "on" or "off" (controls auto responds)
- respondAfterMinutes: integer (in minutes), after which responderText is
                       sent again
- responderText:       Text to be shown when necessary conditions are met.
                       Attention: The text always has to be the last parameter.
                       It does not need to be in quotes of any kind. It can also
                       contain %s and %d. These are placeholders for your own
                       nick and the minutes set in preferences.
""", "", "fn_command", "")
예제 #45
0
    return w.WEECHAT_RC_OK


def get_option(option):
    """Returns value of w.option."""
    return w.config_string(w.config_get("{}.{}".format(plugin_config, option)))


if __name__ == "__main__" and import_ok:
    if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        #set options
        for option,value in default_options.items():
            if not w.config_is_set_plugin(option):
                w.config_set_plugin(option, value)

        options = {"enabled": get_option("enabled"),
            "units": get_option("units"), 
            "weather_trigger": get_option("weather_trigger"),
            "forecast_trigger": get_option("forecast_trigger"),
            "apikey": get_option("apikey")
        }

        if options["apikey"] == "0000000000000":
            w.prnt("", "Your API key is not set. Please sign up at www.wunderground.com/weather/api and set plugins.var.python.weatherbot.*")

        #start
        w.hook_signal("*,irc_in_privmsg", "triggerwatch", "data")
        w.hook_config("{}.*".format(plugin_config), "config_cb", "")


예제 #46
0
        for group in groups:
            weechat.completion_list_add(completion,
                                        groups[group]['name'].lower(), 0,
                                        weechat.WEECHAT_LIST_POS_SORT)
            weechat.completion_list_add(completion, groups[group]['name'], 0,
                                        weechat.WEECHAT_LIST_POS_SORT)

    return weechat.WEECHAT_RC_OK


if __name__ == "__main__":
    logger.debug("Preparing to register")
    try:
        if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                            SCRIPT_LICENSE, SCRIPT_DESC, 'shutdown', ''):
            weechat.hook_config('plugins.var.python.%s.*' % SCRIPT_NAME,
                                'config_changed', '')
            init_config()
            set_log_level()
            smsg_help = [
                "number: the full e164 number (including country code) for the contact",
            ]
            signal_help = [
                "contacts: list all contact names and numbers",
                "groups: list all group names",
            ]
            logger.debug("Registering command...")
            weechat.hook_completion('signal_contact_or_group',
                                    'Script to complete numbers',
                                    'completion_cb', '')
            weechat.hook_command(
                "smsg",
예제 #47
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", "")
예제 #48
0
    global ignore_channels, ignore_nicks
    if w.config_get_plugin('blacklist_channels'):
        ignore_channels = w.config_get_plugin('blacklist_channels').split(',')
    ignore_nicks = w.config_get_plugin('blacklist_nicks').split(',')
    return w.WEECHAT_RC_OK

if __name__ == "__main__":
    if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                        SCRIPT_DESC, "", ""):
        # Set default settings
        for option, default_value in settings.iteritems():
            if not w.config_is_set_plugin(option):
                w.config_set_plugin(option, default_value)

        for key, value in PREFIX_COLORS.iteritems():
            PREFIX_COLORS[key] = w.color(w.config_string(w.config_get('weechat.look.%s'%value)))

        update_blacklist() # Set blacklist
        populate_nicks() # Run it once to get data ready
        w.hook_signal('nicklist_nick_added', 'add_nick', '')
        w.hook_signal('nicklist_nick_removed', 'remove_nick', '')
        w.hook_modifier('weechat_print', 'colorize_cb', '')
        # Hook config for changing colors
        w.hook_config('weechat.color.chat_nick_colors', 'populate_nicks', '')
        # Hook for working togheter with other scripts (like colorize_lines)
        w.hook_modifier('colorize_nicks', 'colorize_cb', '')
        # Hook for modifying input
        w.hook_modifier('250|input_text_display', 'colorize_input_cb', '')
        # Hook for updating blacklist (this could be improved to use fnmatch)
        weechat.hook_config('plugins.var.python.%s.blacklist*' %SCRIPT_NAME, 'update_blacklist', '')
예제 #49
0
                             "       size : greater than <Kib> for log-files to purge\n"
                             "    size_ls : less than <Kib> for log-files to purge\n"
                             "        age : older than <days> for log-files to purge (maximum value: 9999)\n"
                             "     age_ls : younger than <days> for log-files to purge\n"
                             "     delete : argument for security reasons\n"
                             "\n"
#                             str_commands + "\n"
                             "Examples:\n"
                             "  show log-files older than 100 days\n"
                             "    /" + SCRIPT_NAME + " age 100\n"
                             "  purge log-files older than 100 days\n"
                             "    /" + SCRIPT_NAME + " age 100 delete\n"
                             "  show log-files younger than 10 days\n"
                             "    /" + SCRIPT_NAME + " age_ls 10\n"
                             "  purge log-files younger than 10 days\n"
                             "    /" + SCRIPT_NAME + " age_ls 10 delete\n"
                             "  show log-files greater than 100 KiB\n"
                             "    /" + SCRIPT_NAME + " size 100\n"
                             "  purge log-files greater than 100 KiB\n"
                             "    /" + SCRIPT_NAME + " size 100 delete\n",
                             "age|age_ls|size|size_ls %-",
                             "purgelogs_cb", "")
    w.hook_config('plugins.var.python.%s.blacklist' %SCRIPT_NAME, 'update_blacklist', '')

    for option, default_value in purgelogs_options.items():
#    for option, default_value in purgelogs_options.iteritems():
      if w.config_get_plugin(option) == "":
        w.config_set_plugin(option, default_value)
      else:
        blacklist = w.config_get_plugin('blacklist').split(',')
예제 #50
0
        "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"
        "\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) %-",
        "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", "")
예제 #51
0
  ignore_nick and ignore_text in plugins.var.python.%(script)s
  Each config option accepts a comma separated list of patterns.
  Wildcards '*', '?' and char groups [..] can be used.
  An ignore exception can be added by prefixing '!' in the pattern.

Examples:
  Setting 'ignore_nick' to 'troll,b[0o]t':
   will ignore notifications from troll, bot and b0t.
  Setting 'ignore_channel' to '*ubuntu*,!#ubuntu-offtopic':
   will ignore notifications from any channel with the word 'ubuntu'
   except from #ubuntu-offtopic.

Daemon:
  %(script)s script needs to connect to an external daemon for send
  notifications, which can be used in localhost or remotely.
  Download the daemon from:
  %(daemon_url)s
  and check its help with ./%(daemon)s --help.
  See also help in script file.
""" %dict(script=SCRIPT_NAME, daemon_url=DAEMON_URL, daemon=DAEMON)
            ,'test|notify|restart|quit', 'cmd_notify', '')

    weechat.hook_config('plugins.var.python.%s.ignore_*' %SCRIPT_NAME, 'ignore_update', '')
    weechat.hook_config('plugins.var.python.%s.server_*' %SCRIPT_NAME, 'server_update', '')

    weechat.hook_print('', 'notify_message', '', 1, 'notify_msg', workaround)
    weechat.hook_print('', 'notify_private', '', 1, 'notify_msg', workaround)


# vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=100:
예제 #52
0
            OPTIONS[option] = value[0]
        else:
            OPTIONS[option] = w.config_get_plugin(option)
        w.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))

def toggle_refresh(pointer, name, value):
    global OPTIONS
    option = name[len('plugins.var.python.' + SCR_NAME + '.'):]        # get optionname
    OPTIONS[option] = value                                               # save new value
    return w.WEECHAT_RC_OK

if __name__ == "__main__" and import_ok:
    if w.register(SCR_NAME, SCR_AUTHOR, SCR_VERSION, SCR_LICENSE,
                  SCR_DESC, "", ""):
        init_options()
        w.hook_config('plugins.var.python.' + SCR_NAME + '.*', 'toggle_refresh', '')
        parser = MyHTMLParser()
        fn_connected("", "", "")
        # hook to "connected to a server"-signal
        w.hook_signal("irc_server_connected", "fn_connected", "")
        w.hook_command( # help-text
           SCR_COMMAND, "",
"""

The script tries to retrieve your external IP, in three cases:
  1) When it is loaded
  2) whenever you have succesfully connected to a server
  3) when the script is called as a command ("/xfer_setip").

""",
           "",
예제 #53
0
                w.command("", cmd)

    return w.WEECHAT_RC_OK


if w.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                    SCRIPT_DESC, "", ""):
    version = w.info_get('version_number', '') or 0
    for option, default_desc in settings.iteritems():
        if not w.config_is_set_plugin(option):
            w.config_set_plugin(option, default_desc[0])
        if int(version) >= 0x00030500:
            w.config_set_desc_plugin(option, default_desc[1])

    if 'STY' in os.environ.keys():
        # We are running under screen
        cmd_output = os.popen('env LC_ALL=C screen -ls').read()
        match = re.search(r'Sockets? in (/.+)\.', cmd_output)
        if match:
            SOCK = os.path.join(match.group(1), os.environ['STY'])

    if not SOCK and 'TMUX' in os.environ.keys():
        # We are running under tmux
        socket_data = os.environ['TMUX']
        SOCK = socket_data.rsplit(',',2)[0]

    if SOCK:
        set_timer()
        w.hook_config("plugins.var.python." + SCRIPT_NAME + ".*",
            "screen_away_config_cb", "")
예제 #54
0
    global ignore_channels, ignore_nicks
    ignore_channels = w.config_string(
        colorize_config_option['blacklist_channels']).split(',')
    ignore_nicks = w.config_string(
        colorize_config_option['blacklist_nicks']).split(',')
    return w.WEECHAT_RC_OK


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

        # Run once to get data ready
        update_blacklist()
        populate_nicks()

        w.hook_signal('nicklist_nick_added', 'add_nick', '')
        w.hook_signal('nicklist_nick_removed', 'remove_nick', '')
        w.hook_modifier('weechat_print', 'colorize_cb', '')
        # Hook config for changing colors
        w.hook_config('weechat.color.chat_nick_colors', 'populate_nicks', '')
        # Hook for working togheter with other scripts (like colorize_lines)
        w.hook_modifier('colorize_nicks', 'colorize_cb', '')
        # Hook for modifying input
        w.hook_modifier('250|input_text_display', 'colorize_input_cb', '')
        # Hook for updating blacklist (this could be improved to use fnmatch)
        weechat.hook_config('%s.look.blacklist*' % SCRIPT_NAME,
                            'update_blacklist', '')
예제 #55
0
파일: bufsize.py 프로젝트: Shrews/scripts
def toggle_refresh(pointer, name, value):
    global OPTIONS
    option = name[len("plugins.var.python." + SCRIPT_NAME + ".") :]  # get optionname
    OPTIONS[option] = value  # save new value
    weechat.bar_item_update(SCRIPT_NAME)
    return weechat.WEECHAT_RC_OK


# ================================[ main ]===============================
if __name__ == "__main__":
    #    global filter_status
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        version = weechat.info_get("version_number", "") or 0

        if int(version) >= 0x00030600:
            filter_status = weechat.info_get("filters_enabled", "")
            bar_item = weechat.bar_item_new(SCRIPT_NAME, "show_item", "")
            weechat.bar_item_update(SCRIPT_NAME)
            weechat.hook_signal("buffer_line_added", "update_cb", "")
            weechat.hook_signal("window_scrolled", "update_cb", "")
            weechat.hook_signal("buffer_switch", "update_cb", "")
            weechat.hook_signal("filters_*", "filtered_update_cb", "")
            weechat.hook_command_run("/buffer clear*", "update_cb", "")
            weechat.hook_command_run("/window page*", "update_cb", "")
            weechat.hook_command_run("/input zoom_merged_buffer", "update_cb", "")
            weechat.hook_config("plugins.var.python." + SCRIPT_NAME + ".*", "toggle_refresh", "")
            init_options()
        else:
            weechat.prnt("", "%s%s %s" % (weechat.prefix("error"), SCRIPT_NAME, ": needs version 0.3.6 or higher"))
예제 #56
0
            else:
                weechat.config_set_plugin(option, value[0])
                minesweeper_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(
                    option, '%s (default: "%s")' % (value[2], value[0]))
        minesweeper_set_colors()

        # mouse support
        if int(version) >= 0x00030600:
            weechat.key_bind('mouse', minesweeper_mouse_keys)
            weechat.hook_hsignal('minesweeper_mouse', 'minesweeper_mouse_cb',
                                 '')

        # detect config changes
        weechat.hook_config('plugins.var.python.%s.*' % SCRIPT_NAME,
                            'minesweeper_config_cb', '')

        # add command
        weechat.hook_command(
            SCRIPT_COMMAND, 'Minesweeper game.', '[16col|256col]',
            '16col: set colors using basic colors (if your terminal or your WeeChat does not support 256 colors)\n'
            '256col: set colors using 256 colors mode (default)\n\n'
            '256 colors mode is highly recommended (WeeChat >= 0.3.5).\n'
            'Mouse is recommended (WeeChat >= 0.3.6).\n\n'
            'Instructions:\n'
            '- use mouse left button (or alt-space) to explore a square, if you think there is no mine under '
            '(if there is a mine, you lose!)\n'
            '- use mouse right button (or alt-f) to put/remove flag on square, if you think there is a mine under\n'
            '- you win if you put all flags on mines, of if all squares without mine are explored.\n\n'
            'Good luck!', '16col|256col', 'minesweeper_cmd_cb', '')
예제 #57
0
                twitch_settings[option] = weechat.config_get_plugin(option)
            else:
                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",
            "",
예제 #58
0
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, 'urlserver_end', ''):
        # set default settings
        version = weechat.info_get('version_number', '') or 0
        for option, value in urlserver_settings_default.items():
            if weechat.config_is_set_plugin(option):
                urlserver_settings[option] = weechat.config_get_plugin(option)
            else:
                weechat.config_set_plugin(option, value[0])
                urlserver_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(
                    option, '%s (default: "%s")' % (value[1], value[0]))

        # detect config changes
        weechat.hook_config('plugins.var.python.%s.*' % SCRIPT_NAME,
                            'urlserver_config_cb', '')

        # add command
        weechat.hook_command(
            SCRIPT_COMMAND, SCRIPT_DESC, 'start|restart|stop|status || clear',
            '  start: start server\n'
            'restart: restart server\n'
            '   stop: stop server\n'
            ' status: display status of server\n'
            '  clear: remove all URLs from list\n\n'
            'Without argument, this command opens new buffer with list of URLs.\n\n'
            'Initial setup:\n'
            '  - by default, script will listen on a random free port, you can force a port with:\n'
            '      /set plugins.var.python.urlserver.http_port "1234"\n'
            '  - you can force an IP or custom hostname with:\n'
            '      /set plugins.var.python.urlserver.http_hostname "111.22.33.44"\n'
예제 #59
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', '')
예제 #60
0
파일: keepnick.py 프로젝트: major/scripts
    weechat.prnt(
        buffer, "%s\t%s: script already running..." % (string_eval_expression(
            weechat.config_string(
                weechat.config_get("weechat.look.prefix_error"))),
                                                       SCRIPT_NAME))
    return weechat.WEECHAT_RC_OK


# ================================[ main ]===============================
if __name__ == '__main__':
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENCE, SCRIPT_DESC, '', ''):
        weechat.hook_command(
            SCRIPT_NAME, SCRIPT_DESC, '',
            'You have to edit options with: /set *keepnick*\n'
            'I suggest using /iset script or /fset plugin.\n', '',
            'print_usage', '')

        version = weechat.info_get("version_number", "") or 0
        if int(version) >= 0x00040200:
            if int(OPTIONS['delay'][0]) > 0 and int(OPTIONS['timeout'][0]) > 0:
                init_options()
                install_hooks()
                weechat.hook_config('plugins.var.python.' + SCRIPT_NAME + '.*',
                                    'toggle_refresh', '')
        else:
            weechat.prnt(
                '', '%s%s %s' % (weechat.prefix('error'), SCRIPT_NAME,
                                 ': needs version 0.4.2 or higher'))
            weechat.command('', '/wait 1ms /python unload %s' % SCRIPT_NAME)