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
7c9f0978
Commit
7c9f0978
authored
May 28, 2015
by
vvaltman
Browse files
Options
Browse Files
Download
Plain Diff
Merge github.com:vysheng/tg
parents
0305e38f
e14cf95a
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 @
7c9f0978
...
@@ -744,7 +744,10 @@ void py_do_all (void) {
...
@@ -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) {
...
@@ -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
))
...
...
python-types.c
View file @
7c9f0978
...
@@ -375,21 +375,28 @@ static PyMemberDef tgl_Peer_members[] = {
...
@@ -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|O
pi"
,
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
(
"OsO
O"
,
(
PyObject
*
)
self
,
message
,
callback
,
flags
);
else
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_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
{
...
...
tg-test.py
View file @
7c9f0978
...
@@ -46,9 +46,7 @@ def on_msg_receive(msg):
...
@@ -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
):
...
...
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