1
0
mirror of https://github.com/Tha14/toxic.git synced 2024-11-14 05:23:01 +01:00

get_status returns a string rather than an integer.

This commit is contained in:
jakob 2017-05-17 08:37:05 -04:00
parent 7d3d129624
commit 02ea0fac44
3 changed files with 20 additions and 7 deletions

View File

@ -31,9 +31,9 @@ State
.. function:: get_status()
Return the user's current status. 0 indicates online and available, 1 indicates away, and 2 indicates busy.
Return a string representing the user's current status. Can be either "online", "away", or "busy".
:rtype: int
:rtype: string
.. function:: get_status_message()

View File

@ -82,6 +82,7 @@ char *api_get_status_message(void)
return NULL;
tox_self_get_status_message(user_tox, status);
status[len] = '\0';
return (char *) status;
}
@ -92,12 +93,13 @@ void api_send(const char *msg)
char *name = api_get_nick();
char timefrmt[TIME_STR_SIZE];
get_time_str(timefrmt, sizeof(timefrmt));
self_window = get_active_window();
get_time_str(timefrmt, sizeof(timefrmt));
line_info_add(self_window, timefrmt, name, NULL, OUT_MSG, 0, 0, "%s", msg);
free(name);
cqueue_add(self_window->chatwin->cqueue, msg, strlen(msg), OUT_MSG,
self_window->chatwin->hst->line_end->id + 1);
free(name);
}
void api_execute(const char *input, int mode)

View File

@ -64,14 +64,25 @@ static PyObject *python_api_get_nick(PyObject *self, PyObject *args)
static PyObject *python_api_get_status(PyObject *self, PyObject *args)
{
TOX_USER_STATUS status;
PyObject *ret;
if (!PyArg_ParseTuple(args, ""))
return NULL;
status = api_get_status();
ret = Py_BuildValue("i", status);
switch (api_get_status()) {
case TOX_USER_STATUS_NONE:
ret = Py_BuildValue("s", "online");
break;
case TOX_USER_STATUS_AWAY:
ret = Py_BuildValue("s", "away");
break;
case TOX_USER_STATUS_BUSY:
ret = Py_BuildValue("s", "busy");
break;
}
return ret;
}