예제 #1
0
def _cmd_browser(url):
    global _lastlink
    link = None

    # use arg if supplied
    if (url is not None):
        link = url
    else:
        jid = prof.get_current_recipient()
        room = prof.get_current_muc()

        # check if in chat window
        if (jid is not None):

            # check for link from recipient
            if jid in _lastlink.keys():
                link = _lastlink[jid]
            else:
                prof.cons_show("No links found from " + jid)

        # check if in muc window
        elif (room is not None):
            if room in _lastlink.keys():
                link = _lastlink[room]
            else:
                prof.cons_show("No links found from " + room)

        # not in chat/muc window
        else:
            prof.cons_show("You must supply a URL to the /browser command")

    # open the browser if link found
    if (link is not None):
        prof.cons_show("Opening " + link + " in browser")
        _open_browser(link)
예제 #2
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")
예제 #3
0
def _cmd_browser(url):
    global _lastlink
    link = None

    # use arg if supplied
    if (url is not None):
        link = url
    else:
        jid = prof.get_current_recipient()
        room = prof.get_current_muc()

        # check if in chat window
        if (jid is not None):

            # check for link from recipient
            if jid in _lastlink.keys():
                link = _lastlink[jid]
            else:
                prof.cons_show("No links found from " + jid)

        # check if in muc window
        elif (room is not None):
            if room in _lastlink.keys():
                link = _lastlink[room]
            else:
                prof.cons_show("No links found from " + room)

        # not in chat/muc window
        else:
            prof.cons_show("You must supply a URL to the /browser command")

    # open the browser if link found
    if (link is not None):
        prof.cons_show("Opening " + link + " in browser")
        _open_browser(link)
예제 #4
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")
예제 #5
0
def prof_post_room_message_display(barejid, nick, message):
    enabled = prof.settings_string_get("say", "enabled", "off")
    current_muc = prof.get_current_muc()
    if enabled == "on":
        say(nick + " in " + barejid + " says " + message)
    elif enabled == "active" and current_muc == barejid:
        say(nick + " says " + message)

    return message
예제 #6
0
def prof_post_room_message_display(barejid, nick, message):
    enabled = prof.settings_string_get("say", "enabled", "off")
    current_muc = prof.get_current_muc()
    if enabled == "on":
        say(nick + " in " + barejid + " says " + message)
    elif enabled == "active" and current_muc == barejid:
        say(nick + " says " + message)

    return message
def prof_post_room_message_display(barejid, nick, message):
    enabled = prof.settings_string_get("termuxnotify", "enabled", "on")
    rooms = prof.settings_string_get("termuxnotify", "rooms", "off")
    current_muc = prof.get_current_muc()
    if rooms == "on":
        if enabled == "on":
            termuxnotify(nick + " in " + barejid, message)
        elif enabled == "active" and current_muc == barejid:
            termuxnotify(nick, message)

    return message
예제 #8
0
def _cmd_ascii(text):
    proc = subprocess.Popen(['figlet', '--', text], stdout=subprocess.PIPE)
    ascii_out = proc.communicate()[0].decode('utf-8')
    recipient = prof.get_current_recipient()
    room = prof.get_current_muc()
    if recipient:
        prof.send_line(u'\u000A' + ascii_out)
    elif room:
        prof.send_line(u'\u000A' + ascii_out)
    elif prof.current_win_is_console():
        prof.cons_show(u'\u000A' + ascii_out)
예제 #9
0
def _cmd_ascii(text):
    proc = subprocess.Popen(['figlet', '--', text], stdout=subprocess.PIPE)
    ascii_out = proc.communicate()[0].decode('utf-8')
    recipient = prof.get_current_recipient()
    room = prof.get_current_muc()
    if recipient:
        prof.send_line(u'\u000A' + ascii_out)
    elif room:
        prof.send_line(u'\u000A' + ascii_out)
    elif prof.current_win_is_console():
        prof.cons_show(u'\u000A' + ascii_out)
예제 #10
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")
예제 #11
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)
예제 #12
0
def _cmd_clients():
    muc = prof.get_current_muc()
    if muc == None:
        prof.cons_show("Command only valid in chat rooms.")
        return

    occupants = prof.get_current_occupants()
    if occupants == None or len(occupants) == 0:
        prof.cons_show("No occupants for /clients command.")
        return

    nick = prof.get_current_nick()

    _create_win()
    prof.win_focus(clients_win)

    for occupant in occupants:
        if nick != occupant:
            _sv_send(muc, occupant)
예제 #13
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)
예제 #14
0
def _cmd_clients():
    muc = prof.get_current_muc()
    if muc == None:
        prof.cons_show("Command only valid in chat rooms.")
        return
	
    occupants = prof.get_current_occupants()
    if occupants == None or len(occupants) == 0:
        prof.cons_show("No occupants for /clients command.")
        return

    nick = prof.get_current_nick()

    _create_win()
    prof.win_focus(clients_win)

    for occupant in occupants:
        if nick != occupant:
            _sv_send(muc, occupant)
예제 #15
0
def prof_post_room_message_display(barejid, nick, message):
    enabled = prof.settings_string_get("notifycmd", "enabled", "on")
    rooms = prof.settings_string_get("notifycmd", "rooms", "mention")
    current_muc = prof.get_current_muc()
    mynick = prof.get_room_nick(barejid)
    # Don't notify for ones own messages
    if nick != mynick:
        if rooms == "on":
            if enabled == "on":
                notifycmd(nick + " in " + barejid, message)
            elif enabled == "active" and current_muc == barejid:
                notifycmd(nick, message)
        elif rooms == "mention":
            if mynick in message:
                if enabled == "on":
                    notifycmd(nick, message)
                elif enabled == "active" and current_muc == barejid:
                    notifycmd(nick, message)
    return message
예제 #16
0
def _parse_args(arg1=None, arg2=None, arg3=None):
    """ Parse arguments given in command window

    arg1: start || end
    arg2: muc || jid (optional)

    Starts or ends an encrypted chat session

    """
    account = ProfOmemoUser().account
    fulljid = ProfOmemoUser().fulljid

    if arg1 == 'on':
        _set_omemo_enabled_setting(True)

    elif arg1 == 'off':
        _set_omemo_enabled_setting(False)

    elif arg1 == 'start':
        # ensure we are in a chat window

        current_recipient = prof.get_current_recipient()

        if not current_recipient and arg2 != current_recipient:
            log.info('Opening Chat Window for {0}'.format(arg2))
            prof.send_line('/msg {0}'.format(arg2))

        recipient = arg2 or current_recipient
        if recipient:
            log.info('Start OMEMO session with: {0}'.format(recipient))
            _start_omemo_session(recipient)

    elif arg1 == 'end':
        # ensure we are in a chat window
        jid = arg2 or prof.get_current_muc() or prof.get_current_recipient()
        log.info('Ending OMEMO session with: {0}'.format(jid))
        if jid:
            _end_omemo_session(jid)

    elif arg1 == 'set':
        if arg2 == 'message_prefix':
            if arg3 is not None:
                _set_omemo_message_char(arg3)

    elif arg1 == 'account':
        prof.cons_show('Account: {0}'.format(account))

    elif arg1 == 'status':
        enabled = _get_omemo_enabled_setting()
        prof.cons_show('OMEMO Plugin Enabled: {0}'.format(enabled))

    elif arg1 == 'fulljid':
        prof.cons_show('Current JID: {0}'.format(fulljid))

    elif arg1 == 'show_devices' and arg2 is not None:
        account = arg2
        omemo_state = ProfOmemoState()
        prof.cons_show('Requesting Devices...')
        devices = omemo_state.device_list_for(account)
        prof.cons_show('Devices: {0}'.format(devices))
        prof.cons_show('{0}: {1}'.format(account, ', '.join(devices)))

    elif arg1 == 'reset_devicelist' and arg2 is not None:
        contact_jid = arg2
        if contact_jid != ProfOmemoUser.account:
            omemo_state = ProfOmemoState()
            omemo_state.set_devices(contact_jid, [])
            _query_device_list(contact_jid)

    elif arg1 == 'fingerprints':
        if arg2:
            contact_jid = query_jid = arg2
        else:
            # The local account is identified as '-1' in the OMEMO database
            contact_jid = ProfOmemoUser.account
            query_jid = '-1'
        omemo_state = ProfOmemoState()

        fingerprints = omemo_state.getFingerprints(query_jid)
        prof.cons_show('Fingerprints for account: {0}'.format(contact_jid))

        for record in fingerprints:
            _id, recipient_id, public_key, trust = record
            fpr = binascii.hexlify(public_key)
            fpr = human_hash(fpr[2:])

            prof.cons_show(' {0}'.format(fpr))

    else:
        prof.cons_show('Argument {0} not supported.'.format(arg1))
def _parse_args(arg1=None, arg2=None, arg3=None):
    """ Parse arguments given in command window

    arg1: start || end
    arg2: muc || jid (optional)

    Starts or ends an encrypted chat session

    """
    account = ProfOmemoUser().account
    fulljid = ProfOmemoUser().fulljid

    if arg1 == 'on':
        _set_omemo_enabled_setting(True)

    elif arg1 == 'off':
        _set_omemo_enabled_setting(False)

    elif arg1 == 'start':
        # ensure we are in a chat window

        current_recipient = prof.get_current_recipient()

        if not current_recipient and arg2 != current_recipient:
            log.info('Opening Chat Window for {0}'.format(arg2))
            prof.send_line('/msg {0}'.format(arg2))

        recipient = arg2 or current_recipient
        if recipient:
            log.info('Start OMEMO session with: {0}'.format(recipient))
            _start_omemo_session(recipient)

    elif arg1 == 'end':
        # ensure we are in a chat window
        jid = arg2 or prof.get_current_muc() or prof.get_current_recipient()
        log.info('Ending OMEMO session with: {0}'.format(jid))
        if jid:
            _end_omemo_session(jid)

    elif arg1 == 'set':
        if arg2 == 'message_prefix':
            if arg3 is not None:
                _set_omemo_message_char(arg3)

    elif arg1 == 'account':
        prof.cons_show('Account: {0}'.format(account))

    elif arg1 == 'status':
        enabled = _get_omemo_enabled_setting()
        prof.cons_show('OMEMO Plugin Enabled: {0}'.format(enabled))

    elif arg1 == 'fulljid':
        prof.cons_show('Current JID: {0}'.format(fulljid))

    elif arg1 == 'show_devices' and arg2 is not None:
        account = arg2
        omemo_state = ProfOmemoState()
        prof.cons_show('Requesting Devices...')
        devices = omemo_state.device_list_for(account)
        prof.cons_show('Devices: {0}'.format(devices))
        prof.cons_show('{0}: {1}'.format(account, ', '.join(devices)))

    elif arg1 == 'reset_devicelist' and arg2 is not None:
        contact_jid = arg2
        if contact_jid != ProfOmemoUser.account:
            omemo_state = ProfOmemoState()
            omemo_state.set_devices(contact_jid, [])
            _query_device_list(contact_jid)

    elif arg1 == 'fingerprints':
        if arg2:
            contact_jid = query_jid = arg2
        else:
            # The local account is identified as '-1' in the OMEMO database
            contact_jid = ProfOmemoUser.account
            query_jid = '-1'
        omemo_state = ProfOmemoState()

        fingerprints = omemo_state.getFingerprints(query_jid)
        prof.cons_show('Fingerprints for account: {0}'.format(contact_jid))

        for record in fingerprints:
            _id, recipient_id, public_key, trust = record
            fpr = binascii.hexlify(public_key)
            fpr = human_hash(fpr[2:])

            prof.cons_show(' {0}'.format(fpr))

    else:
        prof.cons_show('Argument {0} not supported.'.format(arg1))
예제 #18
0
def prof_post_room_message_display(barejid, nick, message):
    current_jid = prof.get_current_muc()
    _process_message(barejid, current_jid, message)
예제 #19
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")
예제 #20
0
def prof_on_room_history_message(barejid, nick, message, timestamp):
    current_jid = prof.get_current_muc()
    _process_message(barejid, current_jid, message)
예제 #21
0
def prof_on_room_history_message(barejid, nick, message, timestamp):
    current_jid = prof.get_current_muc()
    _process_message(barejid, current_jid, message)
예제 #22
0
def prof_post_room_message_display(barejid, nick, message):
    current_jid = prof.get_current_muc()
    _process_message(barejid, current_jid, message)