Esempio n. 1
0
def unload():
    """This function disconects all module functions"""
    # Store all pending changes to the database
    helper.gatodb_commit()
    # Disconnect everything else
    xchat.unhook(HOOKANTISPAM)
    xchat.unhook(HOOKANTIADD)
    xchat.unhook(HOOKANTILIST)
    xchat.unhook(HOOKANTIDEL)
Esempio n. 2
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. 3
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