示例#1
0
def _cmd_say(arg1=None, arg2=None):
    if arg1 == "on":
        prof.settings_string_set("say", "enabled", "on")
        prof.cons_show("Say plugin enabled")
    elif arg1 == "off":
        prof.settings_string_set("say", "enabled", "off")
        prof.cons_show("Say plugin disabled")
    elif arg1 == "active":
        prof.settings_string_set("say", "enabled", "active")
        prof.cons_show("Say plugin enabled for active window only")
    elif arg1 == "args":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/say")
        else:
            prof.settings_string_set("say", "args", arg2)
            prof.cons_show("Say plugin arguments set to: " + arg2)
    elif arg1 == "clearargs":
        prof.settings_string_set("say", "args", "")
        prof.cons_show("Say plugin arguments cleared")
    elif arg1 == "test":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/say")
        else:
            say(arg2)
    else:
        enabled = prof.settings_string_get("say", "enabled", "off")
        args = prof.settings_string_get("say", "args", "")
        prof.cons_show("Say plugin settings:")
        prof.cons_show("enabled : " + enabled)
        if args != "":
            prof.cons_show("args    : " + args)
def _cmd_say(arg1=None, arg2=None):
    if arg1 == "on":
        prof.settings_string_set("termuxnotify", "enabled", "on")
        prof.cons_show("Termuxnotify plugin enabled")
    elif arg1 == "off":
        prof.settings_string_set("termuxnotify", "enabled", "off")
        prof.cons_show("Termuxnotify plugin disabled")
    elif arg1 == "active":
        prof.settings_string_set("termuxnotify", "enabled", "active")
        prof.cons_show("Termuxnotify plugin enabled for active window only")
    elif arg1 == "vibrate":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/termuxnotify")
        else:
            prof.settings_string_set("termuxnotify", "vibrate", arg2)
            prof.cons_show("termuxnotify plugin vibrate set to: " + arg2)
    elif arg1 == "rooms":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/termuxnotify")
        else:
            prof.settings_string_set("termuxnotify", "rooms", arg2)
            prof.cons_show(
                "termuxnotify plugin notifications for rooms set to: " + arg2)
    else:
        enabled = prof.settings_string_get("termuxnotify", "enabled", "on")
        rooms = prof.settings_string_get("termuxnotify", "rooms", "off")
        vibrate = prof.settings_string_get("termuxnotify", "vibrate", "off")
        prof.cons_show("Termuxnotify plugin settings:")
        prof.cons_show("enabled : " + enabled)
        prof.cons_show("vibrate : " + vibrate)
        prof.cons_show("rooms : " + rooms)
def _log(level, msg):
    if not level or not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if level == "debug":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_debug(msg)
        prof.win_show(plugin_win, "called -> prof.log_debug: " + msg)
    elif level == "info":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_info(msg)
        prof.win_show(plugin_win, "called -> prof.log_info: " + msg)
    elif level == "warning":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_warning(msg)
        prof.win_show(plugin_win, "called -> prof.log_warning: " + msg)
    elif level == "error":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.log_error(msg)
        prof.win_show(plugin_win, "called -> prof.log_error: " + msg)
    else:
        prof.cons_bad_cmd_usage("/python-test")
示例#4
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")
示例#5
0
def _cmd_notifycmd(arg1=None, arg2=None):
    if arg1 == "on":
        prof.settings_string_set("notifycmd", "enabled", "on")
        prof.cons_show("Notifycmd plugin enabled")
    elif arg1 == "off":
        prof.settings_string_set("notifycmd", "enabled", "off")
        prof.cons_show("Notifycmd plugin disabled")
    elif arg1 == "active":
        prof.settings_string_set("notifycmd", "enabled", "active")
        prof.cons_show("Notifycmd plugin enabled for active window only")
    elif arg1 == "command":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/notifycmd")
        else:
            prof.settings_string_set("notifycmd", "command", arg2)
            prof.cons_show("notifycmd plugin command set to: " + arg2)
    elif arg1 == "rooms":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/notifycmd")
        else:
            prof.settings_string_set("notifycmd", "rooms", arg2)
            prof.cons_show(
                "notifycmd plugin notifications for rooms set to: " + arg2)
    else:
        enabled = prof.settings_string_get("notifycmd", "enabled", "on")
        rooms = prof.settings_string_get("notifycmd", "rooms", "mention")
        command = prof.settings_string_get("notifycmd", "command", "")
        prof.cons_show("Notifycmd plugin settings:")
        prof.cons_show("enabled : " + enabled)
        prof.cons_show("command : " + command)
        prof.cons_show("rooms : " + rooms)
示例#6
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")
示例#7
0
def _cmd_say(arg1=None, arg2=None):
    if arg1 == "on":
        prof.settings_string_set("say", "enabled", "on")
        prof.cons_show("Say plugin enabled")
    elif arg1 == "off":
        prof.settings_string_set("say", "enabled", "off")
        prof.cons_show("Say plugin disabled")
    elif arg1 == "active":
        prof.settings_string_set("say", "enabled", "active")
        prof.cons_show("Say plugin enabled for active window only")
    elif arg1 == "args":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/say")
        else:
            prof.settings_string_set("say", "args", arg2)
            prof.cons_show("Say plugin arguments set to: " + arg2)
    elif arg1 == "clearargs":
        prof.settings_string_set("say", "args", "")
        prof.cons_show("Say plugin arguments cleared")
    elif arg1 == "test":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/say")
        else:
            say(arg2)
    else:
        enabled = prof.settings_string_get("say", "enabled", "off")
        args = prof.settings_string_get("say", "args", "")
        prof.cons_show("Say plugin settings:")
        prof.cons_show("enabled : " + enabled)
        if args != "":
            prof.cons_show("args    : " + args)
示例#8
0
def _handle_exec(command=None):
    if command == None:
        prof.cons_bad_cmd_usage("/system")
        return;

    create_win()
    prof.win_focus(system_win)
    _handle_win_input(system_win, command)
示例#9
0
def _handle_exec(command=None):
    if command == None:
        prof.cons_bad_cmd_usage("/system")
        return

    create_win()
    prof.win_focus(system_win)
    _handle_win_input(system_win, command)
示例#10
0
def _cmd_enc(arg1=None, arg2=None, arg3=None, arg4=None, arg5=None):
    global chat_msg_hook
    global room_msg_hook

    if arg1 == "end":
        prof.encryption_reset(arg2)

    elif arg1 == "chat_title" and arg2 == "set":
        prof.chat_set_titlebar_enctext(arg3, arg4)

    elif arg1 == "chat_title" and arg2 == "reset":
        prof.chat_unset_titlebar_enctext(arg3)

    elif arg1 == "chat_ch" and arg2 == "set" and arg3 == "in":
        prof.chat_set_incoming_char(arg4, arg5)

    elif arg1 == "chat_ch" and arg2 == "reset" and arg3 == "in":
        prof.chat_unset_incoming_char(arg4)

    elif arg1 == "chat_ch" and arg2 == "set" and arg3 == "out":
        prof.chat_set_outgoing_char(arg4, arg5)

    elif arg1 == "chat_ch" and arg2 == "reset" and arg3 == "out":
        prof.chat_unset_outgoing_char(arg4)

    elif arg1 == "room_title" and arg2 == "set":
        prof.room_set_titlebar_enctext(arg3, arg4)

    elif arg1 == "room_title" and arg2 == "reset":
        prof.room_unset_titlebar_enctext(arg3)

    elif arg1 == "room_ch" and arg2 == "set":
        prof.room_set_message_char(arg3, arg4)

    elif arg1 == "room_ch" and arg2 == "reset":
        prof.room_unset_message_char(arg3)

    elif arg1 == "chat_show":
        prof.chat_show(arg2, arg3)

    elif arg1 == "chat_show_themed":
        prof.chat_show_themed(arg2, "enc_py", "chat_msg", None, "p", arg3)

    elif arg1 == "room_show":
        prof.room_show(arg2, arg3)

    elif arg1 == "room_show_themed":
        prof.room_show_themed(arg2, "enc_py", "room_msg", None, "P", arg3)

    elif arg1 == "chat_msg":
        chat_msg_hook = arg2

    elif arg1 == "room_msg":
        room_msg_hook = arg2

    else:
        prof.cons_bad_cmd_usage("/enc_py")
示例#11
0
def _sendline(line):
    if not line:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.send_line(line)
    prof.win_show(plugin_win, "called -> prof.send_line: " + line)
示例#12
0
def _notify(msg):
    if not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.notify(msg, 5000, "python-test plugin")
    prof.win_show(plugin_win, "called -> prof.notify: " + msg)
示例#13
0
def _winshow(msg):
    if not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    prof.win_show(plugin_win, msg)
    prof.win_show(plugin_win, "called -> prof.win_show: " + msg)
示例#14
0
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
示例#15
0
def _get(subject):
    if subject == "recipient":
        prof.win_create(plugin_win, _handle_win_input)
        recipient = prof.get_current_recipient()
        if recipient:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof.get_current_recipient: " + recipient)
        else:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_recipient: <none>")
    elif subject == "room":
        prof.win_create(plugin_win, _handle_win_input)
        room = prof.get_current_muc()
        if room:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_muc: " + room)
            nick = prof.get_room_nick(room)
            if nick:
                prof.win_focus(plugin_win)
                prof.win_show(
                    plugin_win,
                    "called -> prof_get_room_nick('" + room + "'): " + nick)
        else:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win, "called -> prof_get_current_muc: <none>")
    elif subject == "nick":
        prof.win_create(plugin_win, _handle_win_input)
        nick = prof.get_current_nick()
        if nick:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_nick: " + nick)
        else:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_nick: <none>")
    elif subject == "occupants":
        prof.win_create(plugin_win, _handle_win_input)
        occupants = prof.get_current_occupants()
        if occupants:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win, "called -> prof_get_current_occupants:")
            for occupant in occupants:
                prof.win_show(plugin_win, occupant)
        else:
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win,
                          "called -> prof_get_current_occupants: <none>")
    else:
        prof.cons_bad_cmd_usage("/python-test")
示例#16
0
def _cmd_say(arg1=None, arg2=None):
    global enabled
    if arg1 == "on":
        enabled = True
    elif arg1 == "off":
        enabled = False
    elif arg1 == "test":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/say")
        else:
            say(arg2)
    else:
        prof.cons_bad_cmd_usage("/say")
示例#17
0
def _winshow_t(group, key, dflt, msg):
    if not group or not key or not dflt or not msg:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    groupval = None if group == "none" else group
    keyval = None if key == "none" else key
    dfltval = None if dflt == "none" else dflt
    prof.win_show_themed(plugin_win, groupval, keyval, dfltval, msg)
    prof.win_show(
        plugin_win, "called -> prof_win_show_themed: " + group + ", " + key +
        ", " + dflt + ", " + msg)
示例#18
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()
示例#19
0
def _ping(jid):
    global ping_id

    if not jid:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.win_create(plugin_win, _handle_win_input)
    prof.win_focus(plugin_win)
    res = prof.send_stanza("<iq to='" + jid + "' id='pythonplugin-" +
                           str(ping_id) +
                           "' type='get'><ping xmlns='urn:xmpp:ping'/></iq>")
    ping_id = ping_id + 1
    if res:
        prof.win_show(plugin_win, "Ping sent successfully")
    else:
        prof.win_show(plugin_win, "Error sending ping")
示例#20
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.")
示例#21
0
def _cmd_system(arg1=None, arg2=None):
    if arg1 == "send":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/system")
        else:
            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()
            else:
                result = _get_result(arg2)
                prof.send_line(u'\u000A' + result)
    else:
        create_win()
        prof.win_focus(system_win)
        if arg1:
            _handle_win_input(system_win, arg1)
def _cmd_shortcuts(arg1=None, arg2=None, arg3=None):
    global ENABLED

    if arg1 == None:
        prof.cons_show("Shortcuts Plugin is {}.".format("ON" if ENABLED else "OFF"))
    elif arg1 == "on":
        ENABLED = True
    elif arg1 == "off":
        ENABLED = False
    elif arg1 == "list":
        _list_shortcuts()
    elif arg1 == "set":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/shortcuts")
        else:
            save(arg2, arg3)
    else:
        prof.cons_bad_cmd_usage("/shortcuts")
示例#23
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)
示例#24
0
def _cmd_system(arg1=None, arg2=None):
    if not arg1:
        create_win()
        prof.win_focus(system_win)
        return

    if arg1 == "newline":
        _handle_newline(arg2)
        return

    if arg1 == "send":
        _handle_send(arg2)
        return

    if arg1 == "exec":
        _handle_exec(arg2)
        return

    prof.cons_bad_cmd_usage("/system")
示例#25
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)
示例#26
0
def _cmd_system(arg1=None, arg2=None):
    if not arg1:
        create_win()
        prof.win_focus(system_win)
        return;

    if arg1 == "newline":
        _handle_newline(arg2)
        return

    if arg1 == "send":
        _handle_send(arg2)
        return

    if arg1 == "exec":
        _handle_exec(arg2)
        return

    prof.cons_bad_cmd_usage("/system")
示例#27
0
def _int(op, group, key, value):
    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 == "get":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        res = prof.settings_int_get(group, key, 0)
        prof.win_show(plugin_win, "Integer setting: " + str(res))
    elif op == "set":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.settings_int_set(group, key, int(value))
        prof.win_show(plugin_win,
                      "Set [" + group + "] " + key + " to " + str(value))
示例#28
0
def _cmd_pythontest(subcmd=None, arg1=None, arg2=None, arg3=None, arg4=None):
    if subcmd == "consalert": _consalert()
    elif subcmd == "consshow": _consshow(arg1)
    elif subcmd == "consshow_t": _consshow_t(arg1, arg2, arg3, arg4)
    elif subcmd == "constest": _constest()
    elif subcmd == "winshow": _winshow(arg1)
    elif subcmd == "winshow_t": _winshow_t(arg1, arg2, arg3, arg4)
    elif subcmd == "sendline": _sendline(arg1)
    elif subcmd == "notify": _notify(arg1)
    elif subcmd == "get": _get(arg1)
    elif subcmd == "log": _log(arg1, arg2)
    elif subcmd == "count": _count()
    elif subcmd == "ping": _ping(arg1)
    elif subcmd == "boolean": _boolean(arg1, arg2, arg3, arg4)
    elif subcmd == "string": _string(arg1, arg2, arg3, arg4)
    elif subcmd == "string_list": _string_list(arg1, arg2, arg3, arg4)
    elif subcmd == "int": _int(arg1, arg2, arg3, arg4)
    elif subcmd == "incoming": _incoming(arg1, arg2, arg3)
    elif subcmd == "completer": _completer(arg1, arg2)
    else: prof.cons_bad_cmd_usage("/python-test")
示例#29
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")
示例#30
0
def _completer(op, item):
    if not item:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "add":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.completer_add("/python-test", [item])
        prof.win_show(plugin_win,
                      "Added \"" + item + "\" to /python-test completer")
        prof.completer_add("/python-test completer remove", [item])
    elif op == "remove":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.completer_remove("/python-test", [item])
        prof.win_show(plugin_win,
                      "Removed \"" + item + "\" to /python-test completer")
        prof.completer_remove("/python-test completer remove", [item])
    else:
        prof.cons_bad_cmd_usage("/python-test")
示例#31
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")
示例#32
0
def _cmd_system(arg1=None, arg2=None):
    if not arg1:
        create_win()
        prof.win_focus(system_win)
    elif arg1 == "send":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/system")
        else:
            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()
            else:
                result = _get_result(arg2)
                prof.send_line(u'\u000A' + result)
    elif arg1 == "exec":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/system")
        else:
            create_win()
            prof.win_focus(system_win)
            _handle_win_input(system_win, arg2)
    else:
        prof.cons_bad_cmd_usage("/system")
示例#33
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))
示例#34
0
def _string(op, group, key, value):
    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 not value:
        prof.cons_bad_cmd_usage("/python-test")
        return

    if op == "get":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        res = prof.settings_string_get(group, key, None)
        if res:
            prof.win_show(plugin_win, "String setting: " + res)
        else:
            prof.win_show(plugin_win, "String setting: None")
    elif op == "set":
        prof.win_create(plugin_win, _handle_win_input)
        prof.win_focus(plugin_win)
        prof.settings_string_set(group, key, value)
        prof.win_show(plugin_win,
                      "Set [" + group + "] " + key + " to " + value)
示例#35
0
def cmd_pythontest(arg1=None, arg2=None, arg3=None, arg4=None, arg5=None):
    if arg1 == "consalert":
        create_win()
        prof.win_focus(plugin_win)
        prof.cons_alert()
        prof.win_show(plugin_win, "called -> prof.cons_alert")
    elif arg1 == "consshow":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.cons_show(arg2)
            prof.win_show(plugin_win, "called -> prof.cons_show: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "consshow_t":
        if arg2 == None or arg3 == None or arg4 == None or arg5 == None:
            prof.cons_bad_cmd_usage("/python-test");
        else:
            group = None if arg2 == "none" else arg2
            key = None if arg3 == "none" else arg3
            dflt = None if arg4 == "none" else arg4
            message = arg5
            create_win()
            prof.win_focus(plugin_win)
            prof.cons_show_themed(group, key, dflt, message)
            prof.win_show(plugin_win, "called -> prof.cons_show_themed: " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5)
    elif arg1 == "constest":
        res = prof.current_win_is_console()
        create_win()
        prof.win_focus(plugin_win)
        if res:
            prof.win_show(plugin_win, "called -> prof.current_win_is_console: true")
        else:
            prof.win_show(plugin_win, "called -> prof.current_win_is_console: false")
    elif arg1 == "winshow":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.win_show(plugin_win, arg2)
            prof.win_show(plugin_win, "called -> prof.win_show: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "winshow_t":
        if arg2 == None or arg3 == None or arg4 == None or arg5 == None:
            prof.cons_bad_cmd_usage("/python-test");
        else:
            group = None if arg2 == "none" else arg2
            key = None if arg3 == "none" else arg3
            dflt = None if arg4 == "none" else arg4
            message = arg5
            create_win()
            prof.win_focus(plugin_win)
            prof.win_show_themed(plugin_win, group, key, dflt, message)
            prof.win_show(plugin_win, "called -> prof_win_show_themed: " + arg2 + ", " + arg3 + ", " + arg4 + ", " + arg5)
    elif arg1 == "sendline":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.send_line(arg2)
            prof.win_show(plugin_win, "called -> prof.send_line: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "notify":
        if arg2 != None:
            create_win()
            prof.win_focus(plugin_win)
            prof.notify(arg2, 5000, "python-test plugin")
            prof.win_show(plugin_win, "called -> prof.notify: " + arg2)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "get":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/python-test")
        elif arg2 == "recipient":
            create_win()
            recipient = prof.get_current_recipient();
            if recipient != None:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof.get_current_recipient: " + recipient)
            else:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof_get_current_recipient: <none>")
        elif arg2 == "room":
            create_win()
            room = prof.get_current_muc()
            if room != None:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof_get_current_muc: " + room)
            else:
                prof.win_focus(plugin_win)
                prof.win_show(plugin_win, "called -> prof_get_current_muc: <none>")
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "log":
        if arg2 == None:
            prof.cons_bad_cmd_usage("/python-test")
        elif arg2 == "debug":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_debug(arg3)
                prof.win_show(plugin_win, "called -> prof.log_debug: " + arg3)
        elif arg2 == "info":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_info(arg3)
                prof.win_show(plugin_win, "called -> prof.log_info: " + arg3)
        elif arg2 == "warning":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_warning(arg3)
                prof.win_show(plugin_win, "called -> prof.log_warning: " + arg3)
        elif arg2 == "error":
            if arg3 == None:
                prof.cons_bad_cmd_usage("/python-test")
            else:
                create_win()
                prof.win_focus(plugin_win)
                prof.log_error(arg3)
                prof.win_show(plugin_win, "called -> prof.log_error: " + arg3)
        else:
            prof.cons_bad_cmd_usage("/python-test")
    elif arg1 == "count":
        create_win()
        prof.win_focus(plugin_win)
        prof.win_show(plugin_win, "Count: " + str(count))
    else:
        prof.cons_bad_cmd_usage("/python-test")
示例#36
0
def _incoming(barejid, resource, message):
    if not barejid or not resource or not message:
        prof.cons_bad_cmd_usage("/python-test")
        return

    prof.incoming_message(barejid, resource, message)
示例#37
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")