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")
def add(cls, contact_jid): raw_jid = cls.as_raw_jid(contact_jid) if raw_jid not in cls._active: cls._active[raw_jid] = {'deactivated': False} prof.log_info('Added {0} to active chats'.format(raw_jid)) else: cls.activate(raw_jid) prof.log_info('Chat with {0} re-activated.')
def account_is_active(cls, contact_jid): raw_jid = cls.as_raw_jid(contact_jid) prof.log_info('Active Chats: [{0}]'.format(', '.join(cls._active))) active_user = cls._active.get(raw_jid) if not active_user: return False return not active_user['deactivated']
def prof_pre_chat_message_send(barejid, message): if chat_msg_hook == "modify": return "[py modified] " + message elif chat_msg_hook == "block": prof.chat_show_themed(barejid, None, None, "bold_red", "!", "Python plugin blocked message") return None else: prof.log_info("none") return message
def _retrieve_scores_json(): req = urllib2.Request(_score_url, None, {'Content-Type': 'application/json'}) try: f = urllib2.urlopen(req) except: prof.log_info("cricket-score.py: Error getting scores.") return None else: response = f.read() f.close() return json.loads(response)
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_shutdown(): prof.log_info("python-test: on_shutdown")
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 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 account_is_registered(cls, contact_jid): raw_jid = cls.as_raw_jid(contact_jid) prof.log_info('Active Chats: [{0}]'.format(', '.join(cls._active))) active_user = cls._active.get(raw_jid) return active_user is not None