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")
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")
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")
def _save_token(): try: file_object = open(TOKEN_FILE_NAME, 'w') except: prof.cons_show('Cannot create a new access token file for twitter') else: file_object.write(access_token + '\n') file_object.write(access_token_secret) file_object.close()
def _consshow(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.cons_show(msg) prof.win_show(plugin_win, "called -> prof.cons_show: " + msg)
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)
def _check_for_token(): global access_token global access_token_secret if os.path.isfile(TOKEN_FILE_NAME): prof.log_debug("Token file path is " + os.path.realpath(TOKEN_FILE_NAME)) prof.cons_show("You are logged in, pin is not required") _get_token_from_storage() else: access_token = token['oauth_token'] access_token_secret = token['oauth_token_secret'] _print_initial_message()
def prof_init(version, status): prof.cons_show("python-test: init, " + version + ", " + status) prof.register_command("/python", 0, 1, "/python", "python-test", "python-test", _cmd_python) prof.register_command("/upper", 0, 1, "/upper", "Uppercase input string", "Uppercase input string", _cmd_upper) prof.register_ac("/pcomplete", [ "aah", "baa", "bee" ]) prof.register_ac("/pcomplete aah", [ "one", "two", "three", "nan" ]) prof.register_ac("/pcomplete baa", [ "james", "jim", "jane", "bob" ]) prof.register_command("/pcomplete", 0, 2, "/pcomplete", "Python completion", "Python completion", _cmd_upper) prof.register_timed(_timer_test, 10)
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)
def _set_final_access_token(pin): global client global token global access_token global access_token_secret prof.log_debug(pin) if _user_entered_pin_code(pin): prof.log_debug("User entered pin") try: prof.log_debug("Try") client = UserClient(CONSUMER_KEY, CONSUMER_SECRET, access_token, access_token_secret) token = client.get_access_token(OAUTH_VERIFIER) except TwitterApiError as e: prof.log_debug("Exception") prof.cons_show("Getting final access token error: " + e.error_code) else: prof.log_debug("ELSE") prof.log_debug("Didn't enter ping") access_token = token['oauth_token'] access_token_secret = token['oauth_token_secret'] client = UserClient(CONSUMER_KEY, CONSUMER_SECRET, access_token, access_token_secret) _save_token() prof.log_debug("Saved token") prof.cons_show(" ") prof.cons_show("You have logged into twitter") prof.cons_show('Come ye, birds of different feathers, we chirp together') prof.log_debug("Authentication done")
def prof_init(version, status, account_name, fulljid): synopsis = [ "/copy", "/copy <message index>" ] description = "Copies message content to clipboard" args = [ [ "<message index>", "Defines which message to copy (if not the latest)" ] ] examples = [ "/copy", "/copy -1" ] prof.register_command("/copy", 0, 1, synopsis, description, args, examples, _cmd_copy) prof.cons_show("Command '/copy' registered successfully.")
def _cmd_chatterbot(state): global bot_state if state == "enable": prof.cons_show("ChatterBot Activated") bot_state = True elif state == "disable": prof.cons_show("ChatterBot Stopped") bot_state = False else: if bot_state: prof.cons_show("ChatterBot is running - current sessions:") prof.cons_show(str(bot_session)) else: prof.cons_show("ChatterBot is stopped - /chatterbot enable to activate.")
def _cmd_chatterbot(state): global bot_state if state == "enable": prof.cons_show("ChatterBot Activated") bot_state = True elif state == "disable": prof.cons_show("ChatterBot Stopped") bot_state = False else: if bot_state: prof.cons_show("ChatterBot is running - current sessions:") prof.cons_show(str(bot_session)) else: prof.cons_show( "ChatterBot is stopped - /chatterbot enable to activate.")
def authorize_app_for_twitter(): global client global token global access_token global access_token_secret global CONSUMER_KEY global CONSUMER_SECRET authorized = False try: client = UserClient(CONSUMER_KEY, CONSUMER_SECRET) token = client.get_authorize_token("oob") except TwitterClientError: prof.cons_show('Oops, this is embarrassing, cannot connect to twitter, could be your internet connection') else: _check_for_token() authorized = True return authorized
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)
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")
def stream(): try: #userFeed = client.userstream.user.get() #streaming api error, Unable to decode JSON response userFeed = client.api.statuses.home_timeline.get() except TwitterApiError as error: prof.cons_show("Something went wrong in getting your user feed") prof.cons_show("Please see error details below:") prof.cons_show("Status code for twitter api: " + str(error.status_code) + "\n") else: for eachtweet in userFeed.data: prof.cons_show(eachtweet['text'] + "\n")
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)
def _cmd_imgur(arg1): if arg1 == "screenshot": file_path = "/tmp/_prof_screenshot.png" if sys.platform == "darwin": subprocess.call("screencapture " + file_path, shell=True) else: subprocess.call("scrot " + file_path, shell=True) else: try: file_path = path.expanduser(arg1) except IOError as ioe: prof.cons_show('Could not find file at ' + file_path) return try: data = client.upload_from_path(file_path, config=None, anon=True) prof.send_line(data['link']) except ImgurClientError as e: prof.log_error('Could not upload to Imgur - ' + e.error_message) prof.log_error('Imgur status code - ' + e.status_code)
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)
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")
def _cmd_python(msg): if msg: prof.cons_show("python-test: /python command called, arg = " + msg) else: prof.cons_show("python-test: /python command called with no arg") prof.cons_alert() prof.notify("python-test: notify", 2000, "Plugins") prof.send_line("/vercheck") prof.cons_show("python-test: sent \"/vercheck\" command")
def prof_on_private_message_received(room, nick, message): prof.cons_show("python-test: on_private_message_received, " + room + ", " + nick + ", " + message) prof.cons_alert() return message + "[PYTHON]"
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 _set_omemo_enabled_setting(enabled): msg = 'Plugin enabled: {0}'.format(enabled) log.debug(msg) prof.cons_show(msg) prof.settings_boolean_set(SETTINGS_GROUP, 'enabled', enabled)
def _set_omemo_message_char(char): msg = 'OMEMO Message Prefix: {0}'.format(char) log.debug(msg) prof.cons_show(msg) prof.settings_string_set(SETTINGS_GROUP, 'message_char', char)
def _cmd_count(): prof.cons_show("Counter: " + str(counter))
def _cmd_platform(): result_summary = platform.platform() prof.cons_show(result_summary)
def _list_shortcuts(): global SHORTCUTS_DICTIONARY # ordered_dict = sorted(DICTIONARY.items(), key=lambda t: t[0]) prof.cons_show(u'Shortcuts: ') for key, value in SHORTCUTS_DICTIONARY.iteritems(): prof.cons_show(u':{0}: => {1}'.format(key, value))
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 _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))
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 _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 _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 prof_on_message_send(jid, message): prof.cons_show("python-test: on_message_send, " + jid + ", " + message) prof.cons_alert() return message + "[PYTHON]"
def tweet(msg): userTweet = msg try: if authorize_app_for_twitter(): tweetApiResponse = client.api.statuses.update.post(status=str(userTweet)) except TwitterApiError as error: prof.cons_show(" ") prof.cons_show("Something went wrong in tweeting that") prof.cons_show("Please see error details below:") prof.cons_show("Status code for twitter api: " + str(error.status_code) + "\n") else: prof.cons_show(" ") prof.cons_show("Your tweet '" + userTweet + "' flew away")
def prof_on_room_message_send(room, message): prof.cons_show("python-test: on_room_message_send, " + room + ", " + message) prof.cons_alert() return message + "[PYTHON]"
def _cmd_cricket(): global _score_url global _summary new_summary = None result_json = _retrieve_scores_json() if (result_json): if 'ms' in result_json.keys(): new_summary = result_json['ms'] prof.cons_show("") prof.cons_show("Cricket score:") if 't1FI' in result_json.keys(): prof.cons_show(" " + result_json['t1FI']) if 't2FI' in result_json.keys(): prof.cons_show(" " + result_json['t2FI']) if 't1SI' in result_json.keys(): prof.cons_show(" " + result_json['t1SI']) if 't2SI' in result_json.keys(): prof.cons_show(" " + result_json['t2SI']) _summary = new_summary prof.cons_show("") prof.cons_show(" " + _summary) prof.cons_alert()
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)
def prof_on_start(): prof.cons_show("python-test: on_start") prof.log_debug("python-test: logged debug") prof.log_info("python-test: logged info") prof.log_warning("python-test: logged warning") prof.log_error("python-test: logged error")
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")
def prof_on_connect(account_name, fulljid): prof.cons_show("python-test: on_connect, " + account_name + ", " + fulljid)
def _print_initial_message(): global client global token if client and token: prof.cons_show('') prof.cons_show('Logging into Chirpy') prof.cons_show('Birdy Twitter API Version used: ' + client.api_version) prof.cons_show('Author: ManiacViper') prof.cons_show('Please click the url below to give your blessings to profanity:') prof.cons_show(token['auth_url'])
def prof_on_disconnect(account_name, fulljid): prof.cons_show("python-test: on_disconnect, " + account_name + ", " + fulljid) prof.log_info("python-test: on_disconnect, " + account_name + ", " + fulljid)
def _timer_test(): prof.cons_show("python-test: timer fired.") recipient = prof.get_current_recipient() if recipient: prof.cons_show(" current recipient = " + recipient) prof.cons_alert()
def _get_scores(): global _score_url global _summary notify = None new_summary = None change = False result_json = _retrieve_scores_json() if (result_json): if 'ms' in result_json.keys(): new_summary = result_json['ms'] if new_summary != _summary: change = True if change: prof.cons_show("") prof.cons_show("Cricket score:") if 't1FI' in result_json.keys(): notify = result_json['t1FI'] prof.cons_show(" " + result_json['t1FI']) if 't2FI' in result_json.keys(): notify += "\n" + result_json['t2FI'] prof.cons_show(" " + result_json['t2FI']) if 't1SI' in result_json.keys(): notify += "\n" + result_json['t1SI'] prof.cons_show(" " + result_json['t1SI']) if 't2SI' in result_json.keys(): notify += "\n" + result_json['t2SI'] prof.cons_show(" " + result_json['t2SI']) _summary = new_summary notify += "\n\n" + _summary prof.cons_show("") prof.cons_show(" " + _summary) prof.cons_alert() prof.notify(notify, 5000, "Cricket score")
def _cmd_whoami(): me = getpass.getuser() prof.cons_show(me)