From 7e0cd1cd74f17413f39e0cc945d8179d051b409c Mon Sep 17 00:00:00 2001 From: alexbft Date: Sat, 20 Jun 2015 16:14:43 +0200 Subject: [PATCH] Enabled Peer.fwd_msg for python scripts --- python-types.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/python-types.c b/python-types.c index d909587..da3cd5a 100644 --- a/python-types.c +++ b/python-types.c @@ -406,6 +406,34 @@ tgl_Peer_send_msg (tgl_Peer *self, PyObject *args, PyObject *kwargs) } +static PyObject * +tgl_Peer_fwd_msg (tgl_Peer *self, PyObject *args, PyObject *kwargs) +{ + static char *kwlist[] = {"callback", NULL}; + + int fwd_id = 0; + PyObject *callback = NULL; + + if(PyArg_ParseTupleAndKeywords(args, kwargs, "i|O", kwlist, &fwd_id, &callback)) { + PyObject *api_call; + + if(callback) + api_call = Py_BuildValue("OiO", (PyObject*) self, fwd_id, callback); + else + api_call = Py_BuildValue("Oi", (PyObject*) self, fwd_id); + + Py_INCREF(Py_None); + Py_XINCREF(api_call); + + return py_fwd(Py_None, api_call); + } else { + PyErr_Print(); + Py_XINCREF(Py_False); + return Py_False; + } + +} + static PyObject * tgl_Peer_send_typing (tgl_Peer *self, PyObject *args, PyObject *kwargs) { @@ -932,6 +960,7 @@ static PyMethodDef tgl_Peer_methods[] = { {"send_contact", (PyCFunction)tgl_Peer_send_contact, METH_VARARGS | METH_KEYWORDS, ""}, {"send_location", (PyCFunction)tgl_Peer_send_location, METH_VARARGS | METH_KEYWORDS, ""}, {"mark_read", (PyCFunction)tgl_Peer_mark_read, METH_VARARGS | METH_KEYWORDS, ""}, + {"fwd_msg", (PyCFunction)tgl_Peer_fwd_msg, METH_VARARGS | METH_KEYWORDS, ""}, {NULL} /* Sentinel */ };