Added reply= and preview= to tgl.Peer.send_msg()
This commit is contained in:
parent
1a112a90fd
commit
1b01314689
20
python-tg.c
20
python-tg.c
@ -744,7 +744,10 @@ void py_do_all (void) {
|
|||||||
PyObject *args = (PyObject *)py_ptr[p ++];
|
PyObject *args = (PyObject *)py_ptr[p ++];
|
||||||
|
|
||||||
const char *str, *str1, *str2, *str3;
|
const char *str, *str1, *str2, *str3;
|
||||||
|
|
||||||
|
int preview = 0;
|
||||||
|
int reply_id = 0;
|
||||||
|
unsigned long long flags = 0;
|
||||||
Py_ssize_t i;
|
Py_ssize_t i;
|
||||||
tgl_user_id_t *ids;
|
tgl_user_id_t *ids;
|
||||||
|
|
||||||
@ -772,10 +775,19 @@ void py_do_all (void) {
|
|||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
break;
|
break;
|
||||||
case pq_msg:
|
case pq_msg:
|
||||||
if(PyArg_ParseTuple(args, "O!s#|O", &tgl_PeerType, &peer, &str, &len, &cb_extra))
|
if(PyArg_ParseTuple(args, "O!s#|OO", &tgl_PeerType, &peer, &str, &len, &cb_extra, &pyObj1)) {
|
||||||
tgl_do_send_message (TLS, PY_PEER_ID(peer), str, len, 0, py_msg_cb, cb_extra);
|
if(PyArg_ParseTuple(pyObj1, "ii", &preview, &reply_id)) {
|
||||||
else
|
if(preview)
|
||||||
|
flags |= TGL_SEND_MSG_FLAG_ENABLE_PREVIEW;
|
||||||
|
else
|
||||||
|
flags |= TGL_SEND_MSG_FLAG_DISABLE_PREVIEW;
|
||||||
|
flags |= TGL_SEND_MSG_FLAG_REPLY (reply_id);
|
||||||
|
}
|
||||||
|
tgl_do_send_message (TLS, PY_PEER_ID(peer), str, len, flags, py_msg_cb, cb_extra);
|
||||||
|
} else
|
||||||
PyErr_Print();
|
PyErr_Print();
|
||||||
|
|
||||||
|
Py_XDECREF(pyObj1);
|
||||||
break;
|
break;
|
||||||
case pq_send_typing:
|
case pq_send_typing:
|
||||||
if(PyArg_ParseTuple(args, "O!|O", &tgl_PeerType, &peer, &cb_extra))
|
if(PyArg_ParseTuple(args, "O!|O", &tgl_PeerType, &peer, &cb_extra))
|
||||||
|
@ -375,21 +375,28 @@ static PyMemberDef tgl_Peer_members[] = {
|
|||||||
static PyObject *
|
static PyObject *
|
||||||
tgl_Peer_send_msg (tgl_Peer *self, PyObject *args, PyObject *kwargs)
|
tgl_Peer_send_msg (tgl_Peer *self, PyObject *args, PyObject *kwargs)
|
||||||
{
|
{
|
||||||
static char *kwlist[] = {"message", "callback", NULL};
|
static char *kwlist[] = {"message", "callback", "preview", "reply", NULL};
|
||||||
|
|
||||||
char *message;
|
char *message;
|
||||||
|
int preview = 1;
|
||||||
|
int reply = 0;
|
||||||
PyObject *callback = NULL;
|
PyObject *callback = NULL;
|
||||||
|
|
||||||
if(PyArg_ParseTupleAndKeywords(args, kwargs, "s|O", kwlist, &message, &callback)) {
|
if(PyArg_ParseTupleAndKeywords(args, kwargs, "s|Opi", kwlist, &message, &callback, &preview, &reply)) {
|
||||||
PyObject *api_call;
|
PyObject *api_call;
|
||||||
|
PyObject *flags;
|
||||||
|
|
||||||
|
flags = Py_BuildValue("(ii)", preview, reply);
|
||||||
|
|
||||||
|
|
||||||
if(callback)
|
if(callback)
|
||||||
api_call = Py_BuildValue("OsO", (PyObject*) self, message, callback);
|
api_call = Py_BuildValue("OsOO", (PyObject*) self, message, callback, flags);
|
||||||
else
|
else
|
||||||
api_call = Py_BuildValue("Os", (PyObject*) self, message);
|
api_call = Py_BuildValue("OsOO", (PyObject*) self, message, Py_None, flags);
|
||||||
|
|
||||||
Py_INCREF(Py_None);
|
Py_INCREF(Py_None);
|
||||||
Py_XINCREF(api_call);
|
Py_XINCREF(api_call);
|
||||||
|
Py_XINCREF(flags);
|
||||||
|
|
||||||
return py_send_msg(Py_None, api_call);
|
return py_send_msg(Py_None, api_call);
|
||||||
} else {
|
} else {
|
||||||
|
@ -46,9 +46,7 @@ def on_msg_receive(msg):
|
|||||||
|
|
||||||
pp.pprint(msg)
|
pp.pprint(msg)
|
||||||
if msg.text.startswith("!ping"):
|
if msg.text.startswith("!ping"):
|
||||||
print("SENDING PONG")
|
peer.send_msg("PONG! google.com", preview=False, reply=msg.id)
|
||||||
peer.send_msg("PONG!", msg_cb)
|
|
||||||
peer.send_contact(msg.src.phone, msg.src.first_name, msg.src.last_name , cb)
|
|
||||||
|
|
||||||
|
|
||||||
def on_secret_chat_update(peer, types):
|
def on_secret_chat_update(peer, types):
|
||||||
|
Loading…
Reference in New Issue
Block a user