Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
tg
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
tg
Commits
1b013146
Commit
1b013146
authored
May 28, 2015
by
Vincent Castellano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added reply= and preview= to tgl.Peer.send_msg()
parent
1a112a90
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
11 deletions
+28
-11
python-tg.c
python-tg.c
+16
-4
python-types.c
python-types.c
+11
-4
tg-test.py
tg-test.py
+1
-3
No files found.
python-tg.c
View file @
1b013146
...
...
@@ -744,7 +744,10 @@ void py_do_all (void) {
PyObject
*
args
=
(
PyObject
*
)
py_ptr
[
p
++
];
const
char
*
str
,
*
str1
,
*
str2
,
*
str3
;
int
preview
=
0
;
int
reply_id
=
0
;
unsigned
long
long
flags
=
0
;
Py_ssize_t
i
;
tgl_user_id_t
*
ids
;
...
...
@@ -772,10 +775,19 @@ void py_do_all (void) {
PyErr_Print
();
break
;
case
pq_msg
:
if
(
PyArg_ParseTuple
(
args
,
"O!s#|O"
,
&
tgl_PeerType
,
&
peer
,
&
str
,
&
len
,
&
cb_extra
))
tgl_do_send_message
(
TLS
,
PY_PEER_ID
(
peer
),
str
,
len
,
0
,
py_msg_cb
,
cb_extra
);
else
if
(
PyArg_ParseTuple
(
args
,
"O!s#|OO"
,
&
tgl_PeerType
,
&
peer
,
&
str
,
&
len
,
&
cb_extra
,
&
pyObj1
))
{
if
(
PyArg_ParseTuple
(
pyObj1
,
"ii"
,
&
preview
,
&
reply_id
))
{
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
();
Py_XDECREF
(
pyObj1
);
break
;
case
pq_send_typing
:
if
(
PyArg_ParseTuple
(
args
,
"O!|O"
,
&
tgl_PeerType
,
&
peer
,
&
cb_extra
))
...
...
python-types.c
View file @
1b013146
...
...
@@ -375,21 +375,28 @@ static PyMemberDef tgl_Peer_members[] = {
static
PyObject
*
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
;
int
preview
=
1
;
int
reply
=
0
;
PyObject
*
callback
=
NULL
;
if
(
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"s|O
"
,
kwlist
,
&
message
,
&
callback
))
{
if
(
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"s|O
pi"
,
kwlist
,
&
message
,
&
callback
,
&
preview
,
&
reply
))
{
PyObject
*
api_call
;
PyObject
*
flags
;
flags
=
Py_BuildValue
(
"(ii)"
,
preview
,
reply
);
if
(
callback
)
api_call
=
Py_BuildValue
(
"OsO
"
,
(
PyObject
*
)
self
,
message
,
callback
);
api_call
=
Py_BuildValue
(
"OsO
O"
,
(
PyObject
*
)
self
,
message
,
callback
,
flags
);
else
api_call
=
Py_BuildValue
(
"Os
"
,
(
PyObject
*
)
self
,
message
);
api_call
=
Py_BuildValue
(
"Os
OO"
,
(
PyObject
*
)
self
,
message
,
Py_None
,
flags
);
Py_INCREF
(
Py_None
);
Py_XINCREF
(
api_call
);
Py_XINCREF
(
flags
);
return
py_send_msg
(
Py_None
,
api_call
);
}
else
{
...
...
tg-test.py
View file @
1b013146
...
...
@@ -46,9 +46,7 @@ def on_msg_receive(msg):
pp
.
pprint
(
msg
)
if
msg
.
text
.
startswith
(
"!ping"
):
print
(
"SENDING PONG"
)
peer
.
send_msg
(
"PONG!"
,
msg_cb
)
peer
.
send_contact
(
msg
.
src
.
phone
,
msg
.
src
.
first_name
,
msg
.
src
.
last_name
,
cb
)
peer
.
send_msg
(
"PONG! google.com"
,
preview
=
False
,
reply
=
msg
.
id
)
def
on_secret_chat_update
(
peer
,
types
):
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment