Tidied python plugins
Use private naming convention Move local callback functions to top
This commit is contained in:
@@ -1,12 +1,42 @@
|
||||
import prof
|
||||
|
||||
win_tag = "Upper echo";
|
||||
_win_tag = "Upper echo";
|
||||
|
||||
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 _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 _cmd_upper(line):
|
||||
global _win_tag;
|
||||
if prof.win_exists(_win_tag) == False:
|
||||
prof.win_create(_win_tag, _handle_upper)
|
||||
|
||||
prof.win_focus(_win_tag)
|
||||
|
||||
if line:
|
||||
prof.win_process_line(_win_tag, line)
|
||||
|
||||
def _handle_upper(win, line):
|
||||
prof.win_show(win, line.upper())
|
||||
|
||||
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_timed(timer_test, 10)
|
||||
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_timed(_timer_test, 10)
|
||||
|
||||
def prof_on_start():
|
||||
prof.cons_show("python-test: on_start")
|
||||
@@ -54,33 +84,3 @@ def prof_on_room_message_send(room, message):
|
||||
|
||||
def prof_on_shutdown():
|
||||
prof.log_info("python-test: on_shutdown")
|
||||
|
||||
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 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 cmd_upper(line):
|
||||
global win_tag;
|
||||
if prof.win_exists(win_tag) == False:
|
||||
prof.win_create(win_tag, handle_upper)
|
||||
|
||||
prof.win_focus(win_tag)
|
||||
|
||||
if line:
|
||||
prof.win_process_line(win_tag, line)
|
||||
|
||||
def handle_upper(win, line):
|
||||
prof.win_show(win, line.upper())
|
||||
|
||||
Reference in New Issue
Block a user