Esempio n. 1
0
def highlight_collect_cb(word, word_eol, userdata):
    """Looks for highlighted words (set on HexChat/X-Chat settings) and copy
    the entire line who contains it to the "GatoScript" tab.
    Arguments:
    word     -- array of strings sent by HexChat/X-Chat to every hook
    word_eol -- array of strings sent by HexChat/X-Chat to every hook
    userdata -- optional variable that can be sent to a hook (ignored)
    """
    if xchat.get_prefs("irc_extra_hilight") != '':
        highlight = xchat.get_prefs("irc_extra_hilight").split(",")
        # Extract some text to compose the output string
        channel = word[2]
        nick = word[0].split("!")[0][1:]
        text = word_eol[3][1:]
        # If there is any highlighted word, compose the string and write it to
        # the script query
        for highlighted in highlight:
            exp = re.compile(highlighted, re.IGNORECASE)
            if exp.search(text):
                if word[3] in action_txt:
                    helper.query_line("".join([
                        nick, "has mentioned \003", color(),
                        highlighted, "\003 in a query: <", nick, "> ",
                        word_eol[4][:-1]]))
                else:
                    helper.query_line("".join([
                        nick, " has mentioned \003", color(), highlighted,
                        "\003 in ", channel, ": <", nick, "> ", text]))
    return xchat.EAT_NONE
Esempio n. 2
0
def antispam_list_cb(word, word_eol, userdata):
    """Shows the list of currently active AntiSapm filters.
    Arguments:
    word     -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    word_eol -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    userdata -- optional variable that can be sent to a hook (ignored)
    """
    sql = "SELECT id, filter FROM filters"
    for item in helper.gatodb_cursor_execute(sql):
        message = "".join([str(item[0]), ": ", item[1]])
        helper.query_line(message)
    del message
    return xchat.EAT_ALL
Esempio n. 3
0
def antispam_del_cb(word, word_eol, userdata):
    """Removes one filter from the current antispam filters.
    This function doesnt check for duplicates, it removes every instance of the
    selected filter.
    Arguments:
    word     -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    word_eol -- array of strings sent by HexChat/X-Chat to every hook
    userdata -- optional variable that can be sent to a hook (ignored)
    """
    if helper.CONNECTED == 1:
        sql = "".join(["DELETE FROM filters WHERE filter='", word_eol[1], "'"])
        helper.gatodb_cursor_execute(sql)
        helper.gatodb_commit()
        message = "".join([word_eol[1], " has been deleted from AntiSpam",
                           " filters"])
        helper.query_line(message)
        antispam_reload()
    else:
        helper.gprint("Enable the AntiSpam system before deleting filters")
    return xchat.EAT_ALL
Esempio n. 4
0
def antispam_add_cb(word, word_eol, userdata):
    """Adds a new filter to the end of the current antispam filters list.
    This function doesn't check for duplicates, just adds at the end.
    Arguments:
    word     -- array of strings sent by HexChat/X-Chat to every hook
    word_eol -- array of strings sent by HexChat/X-Chat to every hook (ignored)
    userdata -- optional variable that can be sent to a hook (ignored)
    """
    if helper.CONNECTED == 1:
        sql = "".join(['INSERT INTO filters ("id", "filter")',
                       ' VALUES (null, "', word[1], '")'])
        helper.gatodb_cursor_execute(sql)
        helper.gatodb_commit()
        message = "".join([word[1], " filter has been added to AntiSpam",
                           " filters"])
        helper.query_line(message)
        del message
        antispam_reload()
    else:
        helper.gprint("Enable the AntiSpam system before adding filters")
    return xchat.EAT_ALL