mirror of
https://github.com/profanity-im/profanity.git
synced 2024-12-04 14:46:46 -05:00
Added cons_alert to python API
This commit is contained in:
parent
084b03691e
commit
9bbe8def98
@ -8,7 +8,7 @@ score_url = "http://api.scorescard.com/?type=score&teamone=Australia&teamtwo=Eng
|
||||
# hooks
|
||||
|
||||
def prof_init(version, status):
|
||||
prof.register_timed(get_scores, 10)
|
||||
prof.register_timed(get_scores, 5)
|
||||
|
||||
def get_scores():
|
||||
req = urllib2.Request(score_url, None, {'Content-Type': 'application/json'})
|
||||
@ -17,26 +17,35 @@ def get_scores():
|
||||
f.close()
|
||||
result_json = json.loads(response);
|
||||
summary = None
|
||||
change = False
|
||||
|
||||
if 't1FI' in result_json.keys():
|
||||
change = True
|
||||
summary = result_json['t1FI']
|
||||
prof.cons_show(result_json['t1FI'])
|
||||
|
||||
if 't2FI' in result_json.keys():
|
||||
change = True
|
||||
summary += "\n" + result_json['t2FI']
|
||||
prof.cons_show(result_json['t2FI'])
|
||||
|
||||
if 't1SI' in result_json.keys():
|
||||
change = True
|
||||
summary += "\n" + result_json['t1SI']
|
||||
prof.cons_show(result_json['t1SI'])
|
||||
|
||||
if 't2SI' in result_json.keys():
|
||||
change = True
|
||||
summary += "\n" + result_json['t2SI']
|
||||
prof.cons_show(result_json['t2SI'])
|
||||
|
||||
if 'ms' in result_json.keys():
|
||||
change = True
|
||||
summary += "\n\n" + result_json['ms']
|
||||
prof.cons_show("")
|
||||
prof.cons_show(result_json['ms'])
|
||||
|
||||
if change:
|
||||
prof.cons_alert()
|
||||
|
||||
prof.notify(summary, 5000, "Cricket score")
|
||||
|
@ -6,16 +6,8 @@ import platform
|
||||
def prof_init(version, status):
|
||||
prof.register_command("/platform", 0, 0, "/platform", "Output system information.", "Output system information", cmd_platform)
|
||||
|
||||
# local functions
|
||||
# commands
|
||||
|
||||
def cmd_platform():
|
||||
result_summary = platform.platform()
|
||||
# result_machine = plaform.machine()
|
||||
# result_node = platform,node()
|
||||
# result_processor = platform.processor()
|
||||
# result_release = platform.release()
|
||||
# result_system = platform.system()
|
||||
# result_version = platform.version()
|
||||
|
||||
# prof.cons_show(result_machine + " " + result_node + " " + result_processor + " " + result_release + " " + result_release + " " + result_system + " " + result_version)
|
||||
prof.cons_show(result_summary)
|
||||
|
@ -28,6 +28,13 @@
|
||||
#include "ui/notifier.h"
|
||||
#include "ui/ui.h"
|
||||
|
||||
static PyObject*
|
||||
api_cons_alert(PyObject *self, PyObject *args)
|
||||
{
|
||||
cons_alert();
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
|
||||
static PyObject*
|
||||
api_cons_show(PyObject *self, PyObject *args)
|
||||
{
|
||||
@ -37,6 +44,7 @@ api_cons_show(PyObject *self, PyObject *args)
|
||||
return NULL;
|
||||
}
|
||||
cons_show("%s", message);
|
||||
ui_current_page_off();
|
||||
|
||||
return Py_BuildValue("");
|
||||
}
|
||||
@ -111,6 +119,7 @@ api_notify(PyObject *self, PyObject *args)
|
||||
}
|
||||
|
||||
static PyMethodDef apiMethods[] = {
|
||||
{ "cons_alert", api_cons_alert, METH_NOARGS, "Highlight the console window in the status bar." },
|
||||
{ "cons_show", api_cons_show, METH_VARARGS, "Print a line to the console." },
|
||||
{ "register_command", api_register_command, METH_VARARGS, "Register a command." },
|
||||
{ "register_timed", api_register_timed, METH_VARARGS, "Register a timed function." },
|
||||
|
Loading…
Reference in New Issue
Block a user