Example #1
0
def search_cb(data, buffer, args):
    w.hook_hsignal("irc_redirection_search_whois", "search_whois_cb", "")
    w.hook_hsignal_send(
        "irc_redirect_command",
        {
            "server": w.buffer_get_string(buffer, "name").split(".")[0],  # <- server name
            "pattern": "whois",
            "signal": "search",
            "string": "",
        },
    )
    w.command(w.current_buffer(), "/whois {}".format(args))
    return w.WEECHAT_RC_OK
Example #2
0
def stalker_cmd(data, buffer, args):
    args = args.strip()
    if ' ' in args:
        return w.WEECHAT_RC_ERROR

    server = w.buffer_get_string(buffer, "localvar_server")

    # it's a hostname
    if '@' in args:
        stalker_cmd_bottom(buffer, server, args.split('@')[-1])
    else:
        # Check if the user's in our database already.
        cur = conn.cursor()
        cur.execute('SELECT host_id FROM nicks WHERE nick = "%s"' % (args))
        rows = cur.fetchall()
        cur.close()

        if len(rows):
            host_id = rows[0][0]
            cur = conn.cursor()
            cur.execute('SELECT host FROM hosts WHERE id = %d' % host_id)
            hostnames = [c[0] for c in cur.fetchall()]
            for hostname in hostnames:
                who_cache_update(args, server, hostname)
            stalker_cmd_bottom(buffer, server, hostnames)
            cur.close()
        else:
            if (args + server) in who_cache:
                stalker_cmd_bottom(buffer, server, who_cache[args + server])
            else:
                w.hook_hsignal ("irc_redirection_stalker_who", "stalker_cmd_cb", buffer)
                w.hook_hsignal_send("irc_redirect_command",
                                          { "server": server, "pattern": "who", "signal": "stalker" })
                w.hook_signal_send("irc_input_send", w.WEECHAT_HOOK_SIGNAL_STRING,
                                         ("%s;;2;;/who %s") % (server, args))
        
    return w.WEECHAT_RC_OK
Example #3
0
def install_hooks():
    global HOOK,OPTIONS

    if HOOK['timer'] != '' or HOOK['redirect'] != '':                                     # should not happen, but...
        return

    if not OPTIONS['delay'] or not OPTIONS['timeout']:
        return
    HOOK['timer'] = weechat.hook_timer(int(OPTIONS['delay']) * 1000, 0, 0, 'checknicks', '')
    HOOK['redirect'] = weechat.hook_hsignal('irc_redirection_%s_ison' % SCRIPT_NAME, 'redirect_isonhandler', '' )

    if HOOK['timer'] == 0:
        weechat.prnt('',"%s: can't enable %s, hook_timer() failed" % (weechat.prefix('error'), SCRIPT_NAME))
    if HOOK['redirect'] == 0:
        weechat.prnt('',"%s: can't enable %s, hook_signal() failed" % (weechat.prefix('error'), SCRIPT_NAME))
Example #4
0
def install_hooks():
    global HOOK, OPTIONS

    if HOOK["timer"] != "" or HOOK["redirect"] != "":  # should not happen, but...
        return

    if not OPTIONS["delay"] or not OPTIONS["timeout"]:
        return
    HOOK["timer"] = weechat.hook_timer(int(OPTIONS["delay"]) * 1000, 0, 0, "check_nicks", "")
    HOOK["redirect"] = weechat.hook_hsignal("irc_redirection_%s_ison" % SCRIPT_NAME, "redirect_isonhandler", "")

    if HOOK["timer"] == 0:
        weechat.prnt("", "%s: can't enable %s, hook_timer() failed" % (weechat.prefix("error"), SCRIPT_NAME))
    if HOOK["redirect"] == 0:
        weechat.prnt("", "%s: can't enable %s, hook_signal() failed" % (weechat.prefix("error"), SCRIPT_NAME))
Example #5
0
def install_hooks():
    global HOOK,OPTIONS

    # Should never happen
    if any([HOOK[k] != '' for k in HOOK]):
        return

    if not OPTIONS['delay'] or not OPTIONS['timeout']:
        return

    debug_print("Installing timer with delay %s seconds" % OPTIONS['delay'])
    HOOK['timer'] = weechat.hook_timer(int(OPTIONS['delay']) * 1000, 0, 0, 'check_nicks', '')
    HOOK['redirect'] = weechat.hook_hsignal('irc_redirection_%s_ison' % SCRIPT_NAME, 'redirect_isonhandler', '' )
    HOOK['quit'] = weechat.hook_signal('*,irc_raw_in_quit', 'check_quit', '')
    HOOK['nick'] = weechat.hook_signal('*,irc_raw_in_nick', 'check_nick_change', '')

    for k in HOOK:
        if HOOK[k] == 0:
            weechat.prnt('', "%s: can't enable %s, hook_timer() failed" %
                         (weechat.prefix('error'), SCRIPT_NAME))
Example #6
0
def install_hooks():
    global HOOK,OPTIONS

    # Should never happen
    if any([HOOK[k] != '' for k in HOOK]):
        return

    if not OPTIONS['delay'] or not OPTIONS['timeout']:
        return

    debug_print("Installing timer with delay %s seconds" % OPTIONS['delay'])
    HOOK['timer'] = weechat.hook_timer(int(OPTIONS['delay']) * 1000, 0, 0, 'check_nicks', '')
    HOOK['redirect'] = weechat.hook_hsignal('irc_redirection_%s_ison' % SCRIPT_NAME, 'redirect_isonhandler', '' )
    HOOK['quit'] = weechat.hook_signal('*,irc_raw_in_quit', 'check_quit', '')
    HOOK['nick'] = weechat.hook_signal('*,irc_raw_in_nick', 'check_nick_change', '')

    for k in HOOK:
        if HOOK[k] == 0:
            weechat.prnt('', "%s: can't enable %s, hook_timer() failed" %
                         (weechat.prefix('error'), SCRIPT_NAME))
Example #7
0
def install_hooks():
    global HOOK, OPTIONS

    if HOOK['timer'] != '' or HOOK[
            'redirect'] != '':  # should not happen, but...
        return

    if not OPTIONS['delay'] or not OPTIONS['timeout']:
        return
    HOOK['timer'] = weechat.hook_timer(
        int(OPTIONS['delay']) * 1000, 0, 0, 'check_nicks', '')
    HOOK['redirect'] = weechat.hook_hsignal(
        'irc_redirection_%s_ison' % SCRIPT_NAME, 'redirect_isonhandler', '')

    if HOOK['timer'] == 0:
        weechat.prnt(
            '', "%s: can't enable %s, hook_timer() failed" %
            (weechat.prefix('error'), SCRIPT_NAME))
    if HOOK['redirect'] == 0:
        weechat.prnt(
            '', "%s: can't enable %s, hook_signal() failed" %
            (weechat.prefix('error'), SCRIPT_NAME))
Example #8
0
        # set default settings
        version = weechat.info_get('version_number', '') or 0
        for option, value in minesweeper_settings_default.items():
            if weechat.config_is_set_plugin(option):
                minesweeper_settings[option] = weechat.config_get_plugin(option)
            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'
Example #9
0
        # set default settings
        version = weechat.info_get("version_number", "") or 0
        for option, value in floodit_settings_default.items():
            if weechat.config_is_set_plugin(option):
                floodit_settings[option] = weechat.config_get_plugin(option)
            else:
                weechat.config_set_plugin(option, value[0])
                floodit_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))
        floodit_set_colors()

        # mouse support
        if int(version) >= 0x00030600:
            weechat.key_bind('mouse', floodit_mouse_keys)
            weechat.hook_hsignal('floodit_mouse', 'floodit_mouse_cb', '')

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

        # add command
        weechat.hook_command(SCRIPT_COMMAND, 'Flood''it game.', '[single|versus]',
                             'single: play in single mode (default)\n'
                             'versus: play versus computer\n\n'
                             'Single mode:\n'
                             '- Choose a color for the upper left square, this will paint '
                             'this square and all squares next to this one (having same color) '
                             'with your color.\n'
                             '- You win if all squares are same color.\n'
                             '- Maximum number of floods is 25, 35 or 50 (according to size).\n\n'
                             'Versus mode:\n'
Example #10
0
    elif args[0] == 'disable':
        pass
    else:
        weechat.prnt('', 'owl: unknown argument "{}"'.format(args[0]))
    return weechat.WEECHAT_RC_OK


if __name__ == '__main__' and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        # initialize
        owl_config_set()
        optimize_configs()

        # register hooks
        weechat.hook_hsignal('irc_redirection_owl_userhost', 'owl_userhost_cb',
                             '')
        weechat.hook_signal('buffer_switch', 'owl_buff_switch', '')
        weechat.hook_signal('nicklist_nick_added', 'owl_nick_added', '')
        weechat.hook_signal('nicklist_nick_changed', 'owl_nick_changed', '')
        weechat.hook_signal('nicklist_nick_removed', 'owl_nick_removed', '')
        weechat.hook_config('plugins.var.python.owl.*', 'owl_config_update',
                            '')

        # check every buffer at start up
        ilb = weechat.infolist_get('buffer', '', '')
        while weechat.infolist_next(ilb):
            buff_ptr = weechat.infolist_pointer(ilb, 'pointer')
            owl_init(buff_ptr)
        weechat.infolist_free(ilb)

        # add command
Example #11
0
        version = weechat.info_get("version_number", "") or 0
        for option, value in floodit_settings_default.items():
            if weechat.config_is_set_plugin(option):
                floodit_settings[option] = weechat.config_get_plugin(option)
            else:
                weechat.config_set_plugin(option, value[0])
                floodit_settings[option] = value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(
                    option, '%s (default: "%s")' % (value[1], value[0]))
        floodit_set_colors()

        # mouse support
        if int(version) >= 0x00030600:
            weechat.key_bind('mouse', floodit_mouse_keys)
            weechat.hook_hsignal('floodit_mouse', 'floodit_mouse_cb', '')

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

        # add command
        weechat.hook_command(
            SCRIPT_COMMAND, 'Flood'
            'it game.', '[single|versus]',
            'single: play in single mode (default)\n'
            'versus: play versus computer\n\n'
            'Single mode:\n'
            '- Choose a color for the upper left square, this will paint '
            'this square and all squares next to this one (having same color) '
            'with your color.\n'
Example #12
0
if __name__ == "__main__" and import_ok:
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE, SCRIPT_DESC, "", ""):
        # set default settings
        for option, value in samegame_settings_default.items():
            if weechat.config_is_set_plugin(option):
                samegame_settings[option] = weechat.config_get_plugin(option)
            else:
                weechat.config_set_plugin(option, value[0])
                samegame_settings[option] = value[0]
            weechat.config_set_desc_plugin(option, '%s (default: "%s")' % (value[1], value[0]))
        samegame_set_colors()

        # mouse support
        weechat.key_bind("mouse", samegame_mouse_keys)
        weechat.hook_hsignal("samegame_mouse", "samegame_mouse_cb", "")

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

        # add command
        weechat.hook_command(
            SCRIPT_COMMAND,
            "Samegame.",
            "",
            "Instructions:\n"
            "- click on a group of adjoining blocks of the same color to remove them from the screen\n"
            "- blocks that are no longer supported will fall down, and a column without any blocks will be trimmed away by other columns sliding to the left\n"
            "- your score is increased by (N-1)², where N is the number of blocks removed by your click\n"
            "- the game ends when you can not play any more.",
            "",
Example #13
0
        for option, value in minesweeper_settings_default.items():
            if weechat.config_is_set_plugin(option):
                minesweeper_settings[option] = weechat.config_get_plugin(
                    option)
            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'
Example #14
0
# (this script requires WeeChat 0.3.6 or newer)
#
# Quick hack, to get to know hsignals
# THIS SCRIPT HAS NO USE AT ALL!!! 

import weechat

SCRIPT_NAME = "whois"
SCRIPT_AUTHOR = "Banton"
SCRIPT_VERSION = "0.1"
SCRIPT_LICENSE = "GPL3"
SCRIPT_DESC = "whois via mouse in chat area"

keys = { "@chat(irc.*):w": "hsignal:chat_whois;/cursor stop" }

def whois_hsignal(data, signa, myhash):
    if not myhash["_chat_line_nick"]:
        return weechat.WEECHAT_RC_OK

    whois = "/whois %s" % myhash["_chat_line_nick"]
    weechat.command(myhash["_buffer_name"], whois)
    return weechat.WEECHAT_RC_OK

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

weechat.key_bind("cursor", keys)

weechat.hook_hsignal("chat_whois", "whois_hsignal", "")

Example #15
0
        version = weechat.info_get("version_number", "") or 0
        for ttt_option, ttt_value in tictactoe_settings_default.items():
            if weechat.config_is_set_plugin(ttt_option):
                tictactoe_settings[ttt_option] = weechat.config_get_plugin(
                    ttt_option)
            else:
                weechat.config_set_plugin(ttt_option, ttt_value[0])
                tictactoe_settings[ttt_option] = ttt_value[0]
            if int(version) >= 0x00030500:
                weechat.config_set_desc_plugin(
                    ttt_option,
                    '%s (default: "%s")' % (ttt_value[1], ttt_value[0]))

        # mouse support
        weechat.key_bind('mouse', tictactoe_mouse_keys)
        weechat.hook_hsignal('tictactoe_mouse', 'tictactoe_mouse_cb', '')

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

        # add command
        weechat.hook_command(
            SCRIPT_COMMAND, 'Tic-tac-toe game.', '', 'Instructions:\n'
            '  - enter one digit, or click with mouse in an empty cell to '
            'play\n'
            '  - you must align 3 symbols: horizontally, vertically or '
            'diagonally\n'
            '  - you win if you align the symbols before the computer\n'
            '  - there is a draw game if 3 symbols are not aligned at the end '
            '(for you or computer).\n'
Example #16
0
    if weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION,
                        SCRIPT_LICENSE, SCRIPT_DESC, '', ''):
        # set default settings
        for option, value in samegame_settings_default.items():
            if weechat.config_is_set_plugin(option):
                samegame_settings[option] = weechat.config_get_plugin(option)
            else:
                weechat.config_set_plugin(option, value[0])
                samegame_settings[option] = value[0]
            weechat.config_set_desc_plugin(
                option, '%s (default: "%s")' % (value[1], value[0]))
        samegame_set_colors()

        # mouse support
        weechat.key_bind('mouse', samegame_mouse_keys)
        weechat.hook_hsignal('samegame_mouse', 'samegame_mouse_cb', '')

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

        # add command
        weechat.hook_command(
            SCRIPT_COMMAND, 'Samegame.', '', 'Instructions:\n'
            '- click on a group of adjoining blocks of the same color to remove them from the screen\n'
            '- blocks that are no longer supported will fall down, and a column without any blocks will be trimmed away by other columns sliding to the left\n'
            '- your score is increased by (N-1)², where N is the number of blocks removed by your click\n'
            '- the game ends when you can not play any more.', '',
            'samegame_cmd_cb', '')

        # if buffer already exists (after /upgrade), init samegame
Example #17
0
                                                       "buffer_name")
                    full_name = "{}.{}".format(plugin_name, buffer_name)

                    buffer = weechat.buffer_search("==", full_name)
                    if not buffer:
                        buffer_open_full_name(full_name, noswitch=True)

                    layout_buffer = weechat.hdata_move(hdata_layout_buffer,
                                                       layout_buffer, 1)
    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_hsignal("10000|buffer_open_full_name",
                             "buffer_open_full_name_opened_cb", "")
        weechat.hook_hsignal("0|buffer_open_full_name",
                             "buffer_open_full_name_unhandled_cb", "")

        weechat.hook_hsignal("500|buffer_open_full_name",
                             "buffer_open_full_name_table_cb", "")

        weechat.hook_hsignal("500|buffer_open_full_name",
                             "buffer_open_full_name_irc_cb", "")
        weechat.hook_signal("irc_server_connected", "irc_server_connected_cb",
                            "")

        weechat.hook_command(
            SCRIPT_COMMAND, SCRIPT_DESC, """closed [-noswitch|-list]
  || [-noswitch] <full name>""",
            """      closed: open most recently closed buffer
Example #18
0
SCRIPT_NAME = 'aban'
SCRIPT_AUTHOR = 'NetSysFire'
SCRIPT_VERSION = '0.1'
SCRIPT_LICENSE = 'GPL'
SCRIPT_DESC = 'Script which makes banning/quieting users via account name ($a:) faster'

weechat.register(SCRIPT_NAME, SCRIPT_AUTHOR, SCRIPT_VERSION, SCRIPT_LICENSE,
                 SCRIPT_DESC, '', '')

weechat.hook_command("aban", "ban users with $a", "[<nick> [<nick>...]]",
                     "nick: the nick to ban", "%(irc_channel_nicks_hosts)",
                     "aban", "")
weechat.hook_command("aquiet", "quiet users with $a", "[<nick> [<nick>...]]",
                     "nick: the nick to quiet", "%(irc_channel_nicks_hosts)",
                     "aquiet", "")
weechat.hook_hsignal('irc_redirection_action_who', 'action_cb', '')

PENDING_ACTIONS = {}


def get_buffer(server, channel):
    buffer = weechat.info_get("irc_buffer", f"{server},{channel}")
    return buffer


def log_warning(text):
    weechat.prnt("", f"{weechat.prefix('error')}[aban] {text}")


def aban(data, buffer, arglist):
    for nick in arglist.split(" "):