Пример #1
0
def _cmd_paste(arg1=None, arg2=None):
    if not arg1:
        root = tk.Tk(baseName="")
        root.withdraw()
        result = root.clipboard_get()
        newline = prof.settings_boolean_get("paste", "newline", True)
        if len(result.splitlines()) > 1 and newline:
            prof.send_line(u'\u000A' + result)
        else:
            prof.send_line(result)

        return

    if arg1 == "newline":
        if not arg2:
            prof.cons_show("")
            newline = prof.settings_boolean_get("paste", "newline", True)
            if newline:
                prof.cons_show("paste.py newline: on")
            else:
                prof.cons_show("paste.py newline: off")
        elif arg2 == "on":
            prof.settings_boolean_set("paste", "newline", True)
            prof.cons_show("paste.py newline enabled.")
        elif arg2 == "off":
            prof.settings_boolean_set("paste", "newline", False)
            prof.cons_show("paste.py newline disabled.")
        else:
            prof.cons_bad_cmd_usage("/paste")

        return

    prof.cons_bad_cmd_usage("/paste")
Пример #2
0
def _cmd_paste(arg1=None, arg2=None):
    if not arg1:
        root = tk.Tk(baseName="")
        root.withdraw()
        result = root.clipboard_get()
        newline = prof.settings_boolean_get("paste", "newline", True)
        if len(result.splitlines()) > 1 and newline:
            prof.send_line(u'\u000A' + result)
        else:
            prof.send_line(result)

        return

    if arg1 == "newline":
        if not arg2:
            prof.cons_show("")
            newline = prof.settings_boolean_get("paste", "newline", True)
            if newline:
                prof.cons_show("paste.py newline: on")
            else:
                prof.cons_show("paste.py newline: off")
        elif arg2 == "on":
            prof.settings_boolean_set("paste", "newline", True)
            prof.cons_show("paste.py newline enabled.")
        elif arg2 == "off":
            prof.settings_boolean_set("paste", "newline", False)
            prof.cons_show("paste.py newline disabled.")
        else:
            prof.cons_bad_cmd_usage("/paste")

        return

    prof.cons_bad_cmd_usage("/paste")
Пример #3
0
def _boolean(op, group, key, value_str):
    if op != "get" and op != "set":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if group == None or key == None:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "set" and value_str != "true" and value_str != "false":
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "get":
        dflt = False
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        res = prof.settings_boolean_get(group, key, dflt)
        if res:
            prof.win_show(plugin_win, "Boolean setting: TRUE")
        else:
            prof.win_show(plugin_win, "Boolean setting: FALSE")
    elif op == "set":
        value = False
        if value_str == "true":
            value = True
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.settings_boolean_set(group, key, value)
        prof.win_show(plugin_win,
                      "Set [" + group + "] " + key + " to " + str(value))
Пример #4
0
def prof_post_priv_message_display(barejid, nick, message):
    enabled = prof.settings_boolean_get("sounds", "enabled", False)
    if not enabled:
        return

    soundfile = prof.settings_string_get("sounds", "private", None)
    if soundfile:
        _play_sound(soundfile)
Пример #5
0
def prof_post_chat_message_display(barejid, resource, message):
    enabled = prof.settings_boolean_get("sounds", "enabled", False)
    if not enabled:
        return

    soundfile = prof.settings_string_get("sounds", "chat", None)
    if not soundfile:
        return

    _play_sound(soundfile)
Пример #6
0
def prof_on_contact_offline(barejid, resource, status):
    if _do_notify(barejid, "offline"):
        jid = barejid
        if prof.settings_boolean_get("presence_notify", "resource", False):
            jid = jid + "/" + resource
        message = "{jid} is offline".format(jid=jid)
        if status:
            message = message + ", \"{status}\"".format(status=status)
        prof.notify(message, 5000, "Presence")
        return
Пример #7
0
def _handle_send(command=None):
    if command == None:
        prof.cons_bad_cmd_usage("/system")
        return

    room = prof.get_current_muc()
    recipient = prof.get_current_recipient()
    if room == None and recipient == None:
        prof.cons_show("You must be in a chat or muc window to send a system command")
        prof.cons_alert()
        return

    result = _get_result(command)
    newline = prof.settings_boolean_get("system", "newline", True)
    if len(result.splitlines()) > 1 and newline:
        prof.send_line(u'\u000A' + result)
    else:
        prof.send_line(result)
Пример #8
0
def _show_settings():
    prof.cons_show("")
    prof.cons_show("Presence notify plugin settings:")

    mode = prof.settings_string_get("presence_notify", "mode", "all")
    prof.cons_show("Mode: {mode}".format(mode=mode))

    resource = prof.settings_boolean_get("presence_notify", "resource", False)
    if resource:
        prof.cons_show("Resource: ON")
    else:
        prof.cons_show("Resource: OFF")

    ignored_list = prof.settings_string_list_get("presence_notify", "ignored")
    if ignored_list and len(ignored_list) > 0:
        prof.cons_show("Ignored:")
        for contact in ignored_list:
            prof.cons_show("  {barejid}".format(barejid=contact))
Пример #9
0
def _handle_send(command=None):
    if command == None:
        prof.cons_bad_cmd_usage("/system")
        return

    room = prof.get_current_muc()
    recipient = prof.get_current_recipient()
    if room == None and recipient == None:
        prof.cons_show(
            "You must be in a chat or muc window to send a system command")
        prof.cons_alert()
        return

    result = _get_result(command)
    newline = prof.settings_boolean_get("system", "newline", True)
    if len(result.splitlines()) > 1 and newline:
        prof.send_line(u'\u000A' + result)
    else:
        prof.send_line(result)
Пример #10
0
def _handle_newline(setting=None):
    if not setting:
        prof.cons_show("")
        newline = prof.settings_boolean_get("system", "newline", True)
        if newline:
            prof.cons_show("syscmd.py newline: on")
        else:
            prof.cons_show("syscmd.py newline: off")
        return

    if setting == "on":
        prof.settings_boolean_set("system", "newline", True)
        prof.cons_show("syscmd.py newline enabled.")
        return

    if setting == "off":
        prof.settings_boolean_set("system", "newline", False)
        prof.cons_show("syscmd.py newline disabled.")
        return

    prof.cons_bad_cmd_usage("/paste")
Пример #11
0
def _handle_newline(setting=None):
    if not setting:
        prof.cons_show("")
        newline = prof.settings_boolean_get("system", "newline", True)
        if newline:
            prof.cons_show("syscmd.py newline: on")
        else:
            prof.cons_show("syscmd.py newline: off")
        return

    if setting == "on":
        prof.settings_boolean_set("system", "newline", True)
        prof.cons_show("syscmd.py newline enabled.")
        return

    if setting == "off":
        prof.settings_boolean_set("system", "newline", False)
        prof.cons_show("syscmd.py newline disabled.")
        return

    prof.cons_bad_cmd_usage("/paste")
Пример #12
0
def prof_post_room_message_display(barejid, nick, message):
    my_nick = prof.get_room_nick(barejid)
    if not my_nick:
        return

    if my_nick == nick:
        return;

    enabled = prof.settings_boolean_get("sounds", "enabled", False)
    if not enabled:
        return

    soundfile = prof.settings_string_get("sounds", "room", None)
    if not soundfile:
        return

    roomlist = prof.settings_string_list_get("sounds", "rooms")
    if roomlist and (barejid not in roomlist):
        return

    _play_sound(soundfile)
Пример #13
0
def _get_omemo_enabled_setting():
    return prof.settings_boolean_get(SETTINGS_GROUP, 'enabled',
                                     OMEMO_DEFAULT_ENABLED)
Пример #14
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")
def _get_omemo_enabled_setting():
    return prof.settings_boolean_get(
        SETTINGS_GROUP, 'enabled', OMEMO_DEFAULT_ENABLED)