Updated prof_init hook args
This commit is contained in:
4
ascii.py
4
ascii.py
@@ -10,6 +10,7 @@ Requires 'figlet' which is available on most linux distros e.g.:
|
||||
import prof
|
||||
import subprocess
|
||||
|
||||
|
||||
def _cmd_ascii(text):
|
||||
proc = subprocess.Popen(['figlet', '--', text], stdout=subprocess.PIPE)
|
||||
ascii_out = proc.communicate()[0].decode('utf-8')
|
||||
@@ -22,7 +23,8 @@ def _cmd_ascii(text):
|
||||
elif prof.current_win_is_console():
|
||||
prof.cons_show(u'\u000A' + ascii_out)
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [ "/ascii <message>" ]
|
||||
description = "ASCIIfy a message."
|
||||
args = [
|
||||
|
||||
@@ -61,7 +61,7 @@ def _open_browser(url):
|
||||
os.dup2(saverr, 2)
|
||||
|
||||
|
||||
def prof_init(version, status):
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/browser",
|
||||
"/browser <url>"
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import prof
|
||||
from chatterbotapi import ChatterBotFactory, ChatterBotType
|
||||
|
||||
|
||||
factory = ChatterBotFactory()
|
||||
bot = factory.create(ChatterBotType.CLEVERBOT)
|
||||
# bot = factory.create(ChatterBotType.JABBERWACKY)
|
||||
@@ -8,6 +9,7 @@ bot = factory.create(ChatterBotType.CLEVERBOT)
|
||||
bot_session = {}
|
||||
bot_state = False
|
||||
|
||||
|
||||
def prof_post_chat_message_display(jid, message):
|
||||
if bot_state:
|
||||
if jid not in bot_session:
|
||||
@@ -15,6 +17,7 @@ def prof_post_chat_message_display(jid, message):
|
||||
response = bot_session[jid].think(message)
|
||||
prof.send_line("/msg " + jid + " " + response)
|
||||
|
||||
|
||||
def _cmd_chatterbot(state):
|
||||
global bot_state
|
||||
|
||||
@@ -31,7 +34,8 @@ def _cmd_chatterbot(state):
|
||||
else:
|
||||
prof.cons_show("ChatterBot is stopped - /chatterbot enable to activate.")
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/chatterbot",
|
||||
"/chatterbot enable|disable"
|
||||
|
||||
@@ -4,6 +4,7 @@ Convert smileys ( :) :( etc) to the Unicode character representation
|
||||
|
||||
import prof
|
||||
|
||||
|
||||
def _emote(input_str):
|
||||
result = input_str
|
||||
result = result.replace(":-)", u'\u263a'.encode("utf-8"))
|
||||
@@ -12,11 +13,14 @@ def _emote(input_str):
|
||||
result = result.replace(":(", u'\u2639'.encode("utf-8"))
|
||||
return result
|
||||
|
||||
|
||||
def prof_pre_chat_message_display(jid, message):
|
||||
return _emote(message)
|
||||
|
||||
|
||||
def prof_pre_room_message_display(room, nick, message):
|
||||
return _emote(message)
|
||||
|
||||
|
||||
def prof_pre_priv_message_display(room, nick, message):
|
||||
return _emote(message)
|
||||
|
||||
21
jenkins.py
21
jenkins.py
@@ -53,6 +53,7 @@ poll_fail_message = None
|
||||
job_list = None
|
||||
changes_list = None
|
||||
|
||||
|
||||
def _help():
|
||||
prof.win_show(win_tag, "Commands:")
|
||||
prof.win_show(win_tag, " /jenkins help - Show this help")
|
||||
@@ -67,6 +68,7 @@ def _help():
|
||||
prof.win_show(win_tag, " /jenkins notify on|off - Enable/disable build notifications")
|
||||
prof.win_show(win_tag, " /jenkins settings - Show current settings")
|
||||
|
||||
|
||||
def _settings():
|
||||
prof.win_show(win_tag, "Jenkins settings:")
|
||||
prof.win_show(win_tag, " Jenkins URL : " + jenkins_url)
|
||||
@@ -76,10 +78,12 @@ def _settings():
|
||||
prof.win_show(win_tag, " Notifications enabled : " + str(enable_notify))
|
||||
prof.win_show(win_tag, " Reminders enabled : " + str(enable_remind))
|
||||
|
||||
|
||||
def _safe_remove(jobname, state):
|
||||
if jobname in last_state[state]:
|
||||
last_state[state].remove(jobname)
|
||||
|
||||
|
||||
def _set_state(jobname, state):
|
||||
if not jobname in last_state[state]:
|
||||
_safe_remove(jobname, STATE_SUCCESS)
|
||||
@@ -94,6 +98,7 @@ def _set_state(jobname, state):
|
||||
else:
|
||||
return False
|
||||
|
||||
|
||||
def _open_job_url(url):
|
||||
savout = os.dup(1)
|
||||
saverr = os.dup(2)
|
||||
@@ -106,6 +111,7 @@ def _open_job_url(url):
|
||||
os.dup2(savout, 1)
|
||||
os.dup2(saverr, 2)
|
||||
|
||||
|
||||
class JobList():
|
||||
def __init__(self):
|
||||
self.jobs = []
|
||||
@@ -142,6 +148,7 @@ class JobList():
|
||||
count = count + 1
|
||||
return count
|
||||
|
||||
|
||||
class JobUpdates():
|
||||
def __init__(self):
|
||||
self.states = {}
|
||||
@@ -160,6 +167,7 @@ class JobUpdates():
|
||||
def get_in_state(self, state):
|
||||
return self.states[state]
|
||||
|
||||
|
||||
def _process_build(name, build, new_job_list, new_changes_list):
|
||||
if build.get_status() == STATE_FAILURE:
|
||||
new_job_list.add_job(name, build.get_number(), STATE_FAILURE)
|
||||
@@ -177,6 +185,7 @@ def _process_build(name, build, new_job_list, new_changes_list):
|
||||
if changed:
|
||||
new_changes_list.add_update(STATE_UNSTABLE, name, build.get_number())
|
||||
|
||||
|
||||
def _process_queued_or_running(name, job, new_job_list, new_changes_list):
|
||||
if job.is_queued():
|
||||
new_job_list.add_job(name, None, STATE_QUEUED)
|
||||
@@ -189,6 +198,7 @@ def _process_queued_or_running(name, job, new_job_list, new_changes_list):
|
||||
if changed:
|
||||
new_changes_list.add_update(STATE_RUNNING, name)
|
||||
|
||||
|
||||
def _jenkins_poll():
|
||||
global poll_fail
|
||||
global poll_fail_message
|
||||
@@ -229,6 +239,7 @@ def _jenkins_poll():
|
||||
job_list = new_job_list
|
||||
changes_list = new_changes_list
|
||||
|
||||
|
||||
def _prof_callback():
|
||||
global changes_list
|
||||
if poll_fail:
|
||||
@@ -269,9 +280,11 @@ def _prof_callback():
|
||||
|
||||
changes_list = None
|
||||
|
||||
|
||||
def _handle_input(win, line):
|
||||
pass
|
||||
|
||||
|
||||
def _list_jobs(jobs):
|
||||
for name, build_number, state in jobs:
|
||||
if state == STATE_SUCCESS:
|
||||
@@ -285,6 +298,7 @@ def _list_jobs(jobs):
|
||||
else:
|
||||
prof.win_show_themed(win_tag, None, None, "cyan", " " + name + " " + state)
|
||||
|
||||
|
||||
def _build_job(job):
|
||||
try:
|
||||
request = urllib2.Request(jenkins_url + "/job/" + job + "/build");
|
||||
@@ -299,6 +313,7 @@ def _build_job(job):
|
||||
else:
|
||||
prof.win_show(win_tag, "Build request sent for " + job)
|
||||
|
||||
|
||||
def _job_log(job):
|
||||
name = job[0]
|
||||
build_no = job[1]
|
||||
@@ -314,6 +329,7 @@ def _job_log(job):
|
||||
else:
|
||||
prof.win_show(win_tag, "No build found for " + name)
|
||||
|
||||
|
||||
def _cmd_jenkins(cmd=None, arg=None):
|
||||
global enable_remind
|
||||
global enable_notify
|
||||
@@ -411,6 +427,7 @@ def _cmd_jenkins(cmd=None, arg=None):
|
||||
else:
|
||||
prof.win_show(win_tag, "Unknown command.")
|
||||
|
||||
|
||||
def _remind():
|
||||
if enable_remind and job_list:
|
||||
notify_string = ""
|
||||
@@ -433,7 +450,8 @@ def _remind():
|
||||
if not notify_string == "":
|
||||
prof.notify(notify_string, 5000, "Jenkins")
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
last_state[STATE_SUCCESS] = []
|
||||
last_state[STATE_UNSTABLE] = []
|
||||
last_state[STATE_FAILURE] = []
|
||||
@@ -507,6 +525,7 @@ def prof_init(version, status):
|
||||
|
||||
prof.register_command("/jenkins", 0, 2, synopsis, description, args, examples, _cmd_jenkins)
|
||||
|
||||
|
||||
def prof_on_start():
|
||||
prof.win_create(win_tag, _handle_input)
|
||||
prof.win_show(win_tag, "Jenkins plugin started.")
|
||||
|
||||
4
paste.py
4
paste.py
@@ -6,13 +6,15 @@ import prof
|
||||
import sys
|
||||
import Tkinter as tk
|
||||
|
||||
|
||||
def _cmd_paste():
|
||||
root = tk.Tk(baseName="")
|
||||
root.withdraw()
|
||||
result = root.clipboard_get()
|
||||
prof.send_line(u'\u000A' + result)
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/paste"
|
||||
]
|
||||
|
||||
@@ -28,7 +28,7 @@ cmd_pid(char **args)
|
||||
}
|
||||
|
||||
void
|
||||
prof_init(const char * const version, const char * const status)
|
||||
prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid)
|
||||
{
|
||||
const char *synopsis[] = { "/pid", NULL };
|
||||
const char *description = "Show process ID and parent Process ID in the console window.";
|
||||
|
||||
@@ -10,11 +10,13 @@ line=cyan
|
||||
import prof
|
||||
import platform
|
||||
|
||||
|
||||
def _cmd_platform():
|
||||
result_summary = platform.platform()
|
||||
prof.cons_show_themed("platform", "line", None, result_summary)
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/platform"
|
||||
]
|
||||
|
||||
8
say.py
8
say.py
@@ -13,30 +13,35 @@ from sys import platform
|
||||
|
||||
enabled = False
|
||||
|
||||
|
||||
def say(message):
|
||||
if platform == "darwin":
|
||||
os.system("say '" + message + "' 2>/dev/null")
|
||||
elif platform == "linux" or platform == "linux2":
|
||||
os.system("echo '" + message + "' | espeak 2>/dev/null")
|
||||
|
||||
|
||||
def prof_post_chat_message_display(jid, message):
|
||||
global enabled
|
||||
if enabled:
|
||||
say(jid + " says " + message)
|
||||
return message
|
||||
|
||||
|
||||
def prof_post_room_message_display(room, nick, message):
|
||||
global enabled
|
||||
if enabled:
|
||||
say(nick + " says " + message + " in " + room)
|
||||
return message
|
||||
|
||||
|
||||
def prof_post_priv_message_display(room, nick, message):
|
||||
global enabled
|
||||
if enabled:
|
||||
say(nick + " says " + message)
|
||||
return message
|
||||
|
||||
|
||||
def _cmd_say(arg1=None, arg2=None):
|
||||
global enabled
|
||||
if arg1 == "on":
|
||||
@@ -51,7 +56,8 @@ def _cmd_say(arg1=None, arg2=None):
|
||||
else:
|
||||
prof.cons_bad_cmd_usage("/say")
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/say on|off",
|
||||
"/say test <message>"
|
||||
|
||||
@@ -13,9 +13,11 @@ import subprocess
|
||||
|
||||
system_win = "System"
|
||||
|
||||
|
||||
def _get_result(command):
|
||||
return subprocess.Popen(command, shell=True, stdout=subprocess.PIPE).stdout.read()
|
||||
|
||||
|
||||
def _handle_win_input(win, command):
|
||||
prof.win_show_themed(win, "system", "command", None, command)
|
||||
prof.win_show(win, "")
|
||||
@@ -25,10 +27,12 @@ def _handle_win_input(win, command):
|
||||
prof.win_show_themed(win, "system", "result", None, s)
|
||||
prof.win_show(win, "")
|
||||
|
||||
|
||||
def create_win():
|
||||
if prof.win_exists(system_win) == False:
|
||||
prof.win_create(system_win, _handle_win_input)
|
||||
|
||||
|
||||
def _cmd_system(arg1=None, arg2=None):
|
||||
if not arg1:
|
||||
create_win()
|
||||
@@ -55,7 +59,8 @@ def _cmd_system(arg1=None, arg2=None):
|
||||
else:
|
||||
prof.cons_bad_cmd_usage("/system")
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/system",
|
||||
"/system exec <comman>",
|
||||
|
||||
@@ -303,12 +303,16 @@ def timed_callback():
|
||||
_create_win()
|
||||
prof.win_show(plugin_win, "timed -> timed_callback called")
|
||||
|
||||
def prof_init(version, status):
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
t = threading.Thread(target=_inc_counter)
|
||||
t.daemon = True
|
||||
t.start()
|
||||
|
||||
prof.win_create(plugin_win, _handle_win_input)
|
||||
if account_name and fulljid:
|
||||
prof.win_show(plugin_win, "fired -> prof_init: " + version + ", " + status + ", " + account_name + ", " + fulljid)
|
||||
else:
|
||||
prof.win_show(plugin_win, "fired -> prof_init: " + version + ", " + status)
|
||||
|
||||
synopsis = [
|
||||
"/python-test consalert",
|
||||
|
||||
@@ -462,12 +462,20 @@ timed_callback(void)
|
||||
}
|
||||
|
||||
void
|
||||
prof_init(const char * const version, const char * const status)
|
||||
prof_init(const char * const version, const char * const status, const char *const account_name, const char *const fulljid)
|
||||
{
|
||||
pthread_create(&worker_thread, NULL, inc_counter, NULL);
|
||||
|
||||
prof_win_create(plugin_win, handle_win_input);
|
||||
|
||||
char buf[256];
|
||||
if (account_name != NULL && fulljid != NULL) {
|
||||
sprintf(buf, "fired -> prof_init: %s, %s, %s, %s", version, status, account_name, fulljid);
|
||||
} else {
|
||||
sprintf(buf, "fired -> prof_init: %s, %s", version, status);
|
||||
}
|
||||
prof_win_show(plugin_win, buf);
|
||||
|
||||
const char *synopsis[] = {
|
||||
"/c-test consalert",
|
||||
"/c-test consshow <message>",
|
||||
|
||||
@@ -10,11 +10,13 @@ result=bold_magenta
|
||||
import prof
|
||||
import getpass
|
||||
|
||||
|
||||
def _cmd_whoami():
|
||||
me = getpass.getuser()
|
||||
prof.cons_show_themed("whoami", "result", None, me)
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [ "/whoami" ]
|
||||
description = "Calls the system whoami command"
|
||||
args = []
|
||||
|
||||
@@ -39,6 +39,7 @@ win = "Wikipedia"
|
||||
page_ac = []
|
||||
link_ac = []
|
||||
|
||||
|
||||
def _open_browser(url):
|
||||
savout = os.dup(1)
|
||||
saverr = os.dup(2)
|
||||
@@ -51,13 +52,16 @@ def _open_browser(url):
|
||||
os.dup2(savout, 1)
|
||||
os.dup2(saverr, 2)
|
||||
|
||||
|
||||
def _handle_win_input():
|
||||
pass
|
||||
|
||||
|
||||
def create_win():
|
||||
if prof.win_exists(win) == False:
|
||||
prof.win_create(win, _handle_win_input)
|
||||
|
||||
|
||||
def _update_autocomplete():
|
||||
prof.completer_add("/wikipedia page", page_ac)
|
||||
prof.completer_add("/wikipedia summary", page_ac)
|
||||
@@ -65,6 +69,7 @@ def _update_autocomplete():
|
||||
prof.completer_add("/wikipedia links", page_ac)
|
||||
prof.completer_add("/wikipedia refs", page_ac)
|
||||
|
||||
|
||||
def _search(search_terms):
|
||||
global page_ac
|
||||
|
||||
@@ -81,6 +86,7 @@ def _search(search_terms):
|
||||
prof.win_show(win, "")
|
||||
prof.win_focus(win)
|
||||
|
||||
|
||||
def _summary(page_str):
|
||||
global link_ac
|
||||
|
||||
@@ -103,6 +109,7 @@ def _summary(page_str):
|
||||
prof.win_show(win, "")
|
||||
prof.win_focus(win)
|
||||
|
||||
|
||||
def _page(page_str):
|
||||
page = wikipedia.page(page_str)
|
||||
create_win()
|
||||
@@ -117,6 +124,7 @@ def _page(page_str):
|
||||
prof.win_show(win, "")
|
||||
prof.win_focus(win)
|
||||
|
||||
|
||||
def _images(page_str):
|
||||
global link_ac
|
||||
|
||||
@@ -136,6 +144,7 @@ def _images(page_str):
|
||||
prof.win_show(win, "")
|
||||
prof.win_focus(win)
|
||||
|
||||
|
||||
def _links(page_str):
|
||||
global page_ac
|
||||
|
||||
@@ -156,6 +165,7 @@ def _links(page_str):
|
||||
prof.win_show(win, "")
|
||||
prof.win_focus(win)
|
||||
|
||||
|
||||
def _refs(page_str):
|
||||
global link_ac
|
||||
|
||||
@@ -175,6 +185,7 @@ def _refs(page_str):
|
||||
prof.win_show(win, "")
|
||||
prof.win_focus(win)
|
||||
|
||||
|
||||
def cmd_wp(subcmd, arg):
|
||||
try:
|
||||
if subcmd == "search": _search(arg)
|
||||
@@ -195,7 +206,8 @@ def cmd_wp(subcmd, arg):
|
||||
prof.win_show(win, "")
|
||||
prof.win_focus(win)
|
||||
|
||||
def prof_init(version, status):
|
||||
|
||||
def prof_init(version, status, account_name, fulljid):
|
||||
synopsis = [
|
||||
"/wikipedia search <text>",
|
||||
"/wikipedia summary <title>",
|
||||
|
||||
Reference in New Issue
Block a user