示例#1
0
def _end_omemo_session(jid):
    ProfActiveOmemoChats.deactivate(jid)

    # Release OMEMO from titlebar
    prof.chat_unset_titlebar_enctext(jid)

    prof.chat_unset_incoming_char(jid)
    prof.chat_unset_outgoing_char(jid)

    prof.settings_string_list_remove(SETTINGS_GROUP, 'omemo_sessions', jid)

    show_chat_info(jid, 'OMEMO Session ended.')
def _end_omemo_session(jid):
    ProfActiveOmemoChats.deactivate(jid)

    # Release OMEMO from titlebar
    prof.chat_unset_titlebar_enctext(jid)

    prof.chat_unset_incoming_char(jid)
    prof.chat_unset_outgoing_char(jid)

    prof.settings_string_list_remove(SETTINGS_GROUP, 'omemo_sessions', jid)

    show_chat_info(jid, 'OMEMO Session ended.')
示例#3
0
def _cmd_autocorrector(arg1=None, arg2=None):
    if arg1 == "on":
        prof.settings_string_set("autocorrector", "enabled", "on")
        prof.cons_show("autocorrector plugin enabled")
    elif arg1 == "off":
        prof.settings_string_set("autocorrector", "enabled", "off")
        prof.cons_show("autocorrector plugin disabled")
    elif arg1 == "clearall":
        prof.settings_string_list_clear("autocorrector", "replacements")
        prof.cons_show("autocorrector plugin replacement list cleared.")
    elif arg1 == "showlist":
        replacements = prof.settings_string_list_get("autocorrector",
                                                     "replacements")
        prof.cons_show("Replacement string list:")
        for replacement in replacements:
            prof.cons_show(replacement)
    elif arg1 == "add":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/autocorrector")
        else:
            if len(arg2.split(':')) == 2:
                prof.settings_string_list_add("autocorrector", "replacements",
                                              arg2)
                prof.cons_show("Replacement String added.")
            else:
                prof.cons_show(
                    "Invalid replacement String. Please use the following format to specify replacements: pattern:replacement."
                )
    elif arg1 == "rm":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/autocorrector")
        else:
            if len(arg2.split(':')) == 2:
                prof.settings_string_list_remove("autocorrector",
                                                 "replacements", arg2)
                prof.cons_show("Replacement String removed.")
            else:
                prof.cons_show(
                    "Invalid replacement String. Please use the following format to specify replacements: pattern:replacement."
                )
    else:
        enabled = prof.settings_string_get("autocorrector", "enabled", "on")
        if enabled == "off":
            prof.cons_show("autocorrector inactive.")
        else:
            prof.cons_show("autocorrector active.")
示例#4
0
def _cmd_presence_notify(arg1=None, arg2=None, arg3=None):
    if arg1 == "all":
        prof.settings_string_set("presence_notify", "mode", "all")
        prof.cons_show("Notifying on all presence changes")
        return

    if arg1 == "online":
        prof.settings_string_set("presence_notify", "mode", "online")
        prof.cons_show("Notifying on online/offline presence changes only")
        return

    if arg1 == "off":
        prof.settings_string_set("presence_notify", "mode", "off")
        prof.cons_show("Presence notifications disabled")
        return

    if arg1 == "ignored":
        if arg2 == "clear":
            prof.settings_string_list_clear("presence_notify", "ignored")
            prof.cons_show("Removed all ignored contacts for presence notifications")
            return

        if arg2 == "add":
            if not arg3:
                prof.cons_bad_cmd_usage("/presence_notify")
                return
            prof.settings_string_list_add("presence_notify", "ignored", arg3)
            prof.cons_show("Added {contact} to ignored contacts for presence notifications".format(contact=arg3))
            return

        if arg2 == "remove":
            if not arg3:
                prof.cons_bad_cmd_usage("/presence_notify")
                return
            res = prof.settings_string_list_remove("presence_notify", "ignored", arg3)
            if res:
                prof.cons_show("Removed {contact} from ignored contacts for presence notifications".format(contact=arg3))
            else:
                prof.cons_show("{contact} not in ignore list for presence notiications".format(contact=arg3))
            return

        prof.cons_bad_cmd_usage("/presence_notify")
        return

    if arg1 == "resource":
        if arg2 == "on":
            prof.settings_boolean_set("presence_notify", "resource", True)
            prof.cons_show("Showing resource in presence notifications")
            return;
        if arg2 == "off":
            prof.settings_boolean_set("presence_notify", "resource", False)
            prof.cons_show("Hiding resource in presence notifications")
            return;

        prof.cons_bad_cmd_usage("/presence_notify")
        return

    _show_settings()
def _string_list(op, group, key, value):
    if op != "get" and op != "add" and op != "remove" and op != "remove_all":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "get":
        if group == None or key == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        res = prof.settings_string_list_get(group, key)
        prof.win_focus(plugin_win)
        if res is None:
            prof.win_show(plugin_win, "No list found")
            return
        prof.win_show(plugin_win, "String list:")
        for el in res:
            prof.win_show(plugin_win, "  " + el)
        return

    if op == "add":
        if group == None or key == None or value == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        prof.settings_string_list_add(group, key, value)
        prof.win_focus(plugin_win)
        prof.win_show(plugin_win,
                      "Added '" + value + "' to [" + group + "]" + " " + key)
        return

    if op == "remove":
        if group == None or key == None or value == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        res = prof.settings_string_list_remove(group, key, value)
        prof.win_focus(plugin_win)
        if res:
            prof.win_show(
                plugin_win,
                "Removed '" + value + "' from [" + group + "]" + " " + key)
        else:
            prof.win_show(plugin_win, "Error removing string item from list")
        return

    if op == "remove_all":
        if group == None or key == None:
            prof.cons_bad_cmd_usage("/python-test")
            return
        res = prof.settings_string_list_clear(group, key)
        prof.win_focus(plugin_win)
        if res:
            prof.win_show(plugin_win,
                          "Removed all items from [" + group + "]" + " " + key)
        else:
            prof.win_show(plugin_win, "Error removing list")
        return
示例#6
0
def _cmd_sounds(arg1=None, arg2=None, arg3=None):
    if not arg1:
        prof.cons_show("")
        enabled = prof.settings_boolean_get("sounds", "enabled", False)
        chatsound = prof.settings_string_get("sounds", "chat", None)
        roomsound = prof.settings_string_get("sounds", "room", None)
        privatesound = prof.settings_string_get("sounds", "private", None)
        roomlist = prof.settings_string_list_get("sounds", "rooms")
        if chatsound or roomsound or privatesound:
            if enabled:
                prof.cons_show("Sounds: ON")
            else:
                prof.cons_show("Sounds: OFF")
            if chatsound:
                prof.cons_show("  Chat    : " + chatsound)
            if roomsound:
                prof.cons_show("  Room    : " + roomsound)
                if roomlist and len(roomlist) > 0:
                    for room in roomlist:
                        prof.cons_show("    " + room)
                else:
                    prof.cons_show("    All rooms")
            if privatesound:
                prof.cons_show("  Private : " + privatesound)

        else:
            prof.cons_show("No sounds set.")
        
        return

    if arg1 == "on":
        prof.settings_boolean_set("sounds", "enabled", True)
        prof.cons_show("Sounds enabled")
        return

    if arg1 == "off":
        prof.settings_boolean_set("sounds", "enabled", False)
        prof.cons_show("Sounds disabled")
        return

    if arg1 == "set":
        if arg2 == "chat":
            prof.settings_string_set("sounds", "chat", arg3)
            prof.cons_show("Set chat sound: " + arg3)
        elif arg2 == "room":
            prof.settings_string_set("sounds", "room", arg3)
            prof.cons_show("Set room sound: " + arg3)
        elif arg2 == "private":
            prof.settings_string_set("sounds", "private", arg3)
            prof.cons_show("Set private sound: " + arg3)
        else:
            prof.cons_bad_cmd_usage("/sounds")

        return

    if arg1 == "clear":
        if arg2 == "chat":
            prof.settings_string_set("sounds", "chat", "")
            prof.cons_show("Removed chat sound.")
        elif arg2 == "room":
            prof.settings_string_set("sounds", "room", "")
            prof.cons_show("Removed room sound.")
        elif arg2 == "private":
            prof.settings_string_set("sounds", "private", "")
            prof.cons_show("Removed private sound.")
        else:
            prof.cons_bad_cmd_usage("/sounds")

        return

    if arg1 == "rooms":
        if arg2 == "add":
            if not arg3:
                prof.cons_bad_cmd_usage("/sounds")
            else:
                prof.settings_string_list_add("sounds", "rooms", arg3)
                prof.cons_show("Sounds enabled for room: " + arg3)
        elif arg2 == "remove":
            if not arg3:
                prof.cons_bad_cmd_usage("/sounds")
            else:
                prof.settings_string_list_remove("sounds", "rooms", arg3)
                roomlist = prof.settings_string_list_get("sounds", "rooms")
                if roomlist and len(roomlist) > 0:
                    prof.cons_show("Sounds disabled for room: " + arg3)
                else:
                    prof.cons_show("Empty room list for sounds, playing in all rooms.")
        elif arg2 == "clear":
            prof.settings_string_list_clear("sounds", "rooms")
            prof.cons_show("Cleared sounds room list, playing in all rooms.")
        else:
            prof.cons_bad_cmd_usage("/sounds")

        return

    prof.cons_bad_cmd_usage("/sounds")