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
1b3cdff3
Commit
1b3cdff3
authored
May 15, 2015
by
Vincent Castellano
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'python-bindings' of github.com:datamachine/tg into python-bindings
Conflicts: python-tg.c
parents
aad54b4c
89e0a1e2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
24 deletions
+24
-24
python-tg.c
python-tg.c
+24
-24
No files found.
python-tg.c
View file @
1b3cdff3
...
@@ -941,62 +941,62 @@ void py_do_all (void) {
...
@@ -941,62 +941,62 @@ void py_do_all (void) {
int
len
,
limit
,
offset
;
int
len
,
limit
,
offset
;
PyObject
*
pyObj1
=
NULL
;
PyObject
*
pyObj1
=
NULL
;
PyObject
*
pyObj2
=
NULL
;
PyObject
*
pyObj2
=
NULL
;
PyObject
*
cb_extra
;
PyObject
*
cb_extra
=
NULL
;
//struct tgl_message *M;
//struct tgl_message *M;
tgl_peer_id_t
peer
,
peer1
;
tgl_peer_id_t
peer
,
peer1
;
switch
(
f
)
{
switch
(
f
)
{
case
pq_contact_list
:
case
pq_contact_list
:
PyArg_ParseTuple
(
args
,
"O"
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"
|
O"
,
&
cb_extra
);
tgl_do_update_contact_list
(
TLS
,
py_contact_list_cb
,
cb_extra
);
tgl_do_update_contact_list
(
TLS
,
py_contact_list_cb
,
cb_extra
);
break
;
break
;
case
pq_dialog_list
:
case
pq_dialog_list
:
PyArg_ParseTuple
(
args
,
"O"
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"
|
O"
,
&
cb_extra
);
tgl_do_get_dialog_list
(
TLS
,
py_dialog_list_cb
,
cb_extra
);
tgl_do_get_dialog_list
(
TLS
,
py_dialog_list_cb
,
cb_extra
);
break
;
break
;
case
pq_msg
:
case
pq_msg
:
PyArg_ParseTuple
(
args
,
"iis#O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
len
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis#
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
len
,
&
cb_extra
);
tgl_do_send_message
(
TLS
,
peer
,
str
,
len
,
py_msg_cb
,
cb_extra
);
tgl_do_send_message
(
TLS
,
peer
,
str
,
len
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_send_typing
:
case
pq_send_typing
:
PyArg_ParseTuple
(
args
,
"iiO"
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"ii
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
tgl_do_send_typing
(
TLS
,
peer
,
tgl_typing_typing
,
py_empty_cb
,
cb_extra
);
tgl_do_send_typing
(
TLS
,
peer
,
tgl_typing_typing
,
py_empty_cb
,
cb_extra
);
break
;
break
;
case
pq_send_typing_abort
:
case
pq_send_typing_abort
:
PyArg_ParseTuple
(
args
,
"iiO"
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"ii
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
tgl_do_send_typing
(
TLS
,
peer
,
tgl_typing_cancel
,
py_empty_cb
,
cb_extra
);
tgl_do_send_typing
(
TLS
,
peer
,
tgl_typing_cancel
,
py_empty_cb
,
cb_extra
);
break
;
break
;
case
pq_rename_chat
:
case
pq_rename_chat
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_rename_chat
(
TLS
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_rename_chat
(
TLS
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_send_photo
:
case
pq_send_photo
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_send_document
(
TLS
,
-
1
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_send_document
(
TLS
,
-
1
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_send_video
:
case
pq_send_video
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_send_document
(
TLS
,
FLAG_DOCUMENT_VIDEO
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_send_document
(
TLS
,
FLAG_DOCUMENT_VIDEO
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_send_audio
:
case
pq_send_audio
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_send_document
(
TLS
,
FLAG_DOCUMENT_AUDIO
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_send_document
(
TLS
,
FLAG_DOCUMENT_AUDIO
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_send_document
:
case
pq_send_document
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_send_document
(
TLS
,
0
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_send_document
(
TLS
,
0
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_send_file
:
case
pq_send_file
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_send_document
(
TLS
,
-
2
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_send_document
(
TLS
,
-
2
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_send_text
:
case
pq_send_text
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_send_text
(
TLS
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_send_text
(
TLS
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_chat_set_photo
:
case
pq_chat_set_photo
:
PyArg_ParseTuple
(
args
,
"iisO"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iis
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
str
,
&
cb_extra
);
tgl_do_set_chat_photo
(
TLS
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
tgl_do_set_chat_photo
(
TLS
,
peer
,
str
,
py_msg_cb
,
cb_extra
);
break
;
break
;
/* case pq_load_photo:
/* case pq_load_photo:
...
@@ -1039,19 +1039,19 @@ void py_do_all (void) {
...
@@ -1039,19 +1039,19 @@ void py_do_all (void) {
break;
break;
*/
*/
case
pq_history
:
case
pq_history
:
PyArg_ParseTuple
(
args
,
"iiiO"
,
&
peer
.
type
,
&
peer
.
id
,
&
limit
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iii
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
limit
,
&
cb_extra
);
tgl_do_get_history
(
TLS
,
peer
,
limit
,
0
,
py_msg_list_cb
,
cb_extra
);
tgl_do_get_history
(
TLS
,
peer
,
limit
,
0
,
py_msg_list_cb
,
cb_extra
);
break
;
break
;
case
pq_history_ext
:
case
pq_history_ext
:
PyArg_ParseTuple
(
args
,
"iiiiO"
,
&
peer
.
type
,
&
peer
.
id
,
&
offset
,
&
limit
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iiii
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
offset
,
&
limit
,
&
cb_extra
);
tgl_do_get_history_ext
(
TLS
,
peer
,
offset
,
limit
,
0
,
py_msg_list_cb
,
cb_extra
);
tgl_do_get_history_ext
(
TLS
,
peer
,
offset
,
limit
,
0
,
py_msg_list_cb
,
cb_extra
);
break
;
break
;
case
pq_chat_add_user
:
case
pq_chat_add_user
:
PyArg_ParseTuple
(
args
,
"iiiiO"
,
&
peer
.
type
,
&
peer
.
id
,
&
peer1
.
type
,
&
peer1
.
id
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iiii
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
peer1
.
type
,
&
peer1
.
id
,
&
cb_extra
);
tgl_do_add_user_to_chat
(
TLS
,
peer
,
peer1
,
100
,
py_msg_cb
,
cb_extra
);
tgl_do_add_user_to_chat
(
TLS
,
peer
,
peer1
,
100
,
py_msg_cb
,
cb_extra
);
break
;
break
;
case
pq_chat_del_user
:
case
pq_chat_del_user
:
PyArg_ParseTuple
(
args
,
"iiiiO"
,
&
peer
.
type
,
&
peer
.
id
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iiii
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
tgl_do_del_user_from_chat
(
TLS
,
peer
,
peer1
,
py_msg_cb
,
cb_extra
);
tgl_do_del_user_from_chat
(
TLS
,
peer
,
peer1
,
py_msg_cb
,
cb_extra
);
break
;
break
;
/* case pq_add_contact:
/* case pq_add_contact:
...
@@ -1071,7 +1071,7 @@ void py_do_all (void) {
...
@@ -1071,7 +1071,7 @@ void py_do_all (void) {
break;
break;
*/
*/
case
pq_mark_read
:
case
pq_mark_read
:
PyArg_ParseTuple
(
args
,
"iiO"
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"ii
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
cb_extra
);
tgl_do_mark_read
(
TLS
,
peer
,
py_empty_cb
,
cb_extra
);
tgl_do_mark_read
(
TLS
,
peer
,
py_empty_cb
,
cb_extra
);
break
;
break
;
/*
/*
...
@@ -1101,11 +1101,11 @@ void py_do_all (void) {
...
@@ -1101,11 +1101,11 @@ void py_do_all (void) {
break;
break;
*/
*/
case
pq_status_online
:
case
pq_status_online
:
PyArg_ParseTuple
(
args
,
"O"
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"
|
O"
,
&
cb_extra
);
tgl_do_update_status
(
TLS
,
1
,
py_empty_cb
,
cb_extra
);
tgl_do_update_status
(
TLS
,
1
,
py_empty_cb
,
cb_extra
);
break
;
break
;
case
pq_status_offline
:
case
pq_status_offline
:
PyArg_ParseTuple
(
args
,
"O"
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"
|
O"
,
&
cb_extra
);
tgl_do_update_status
(
TLS
,
0
,
py_empty_cb
,
cb_extra
);
tgl_do_update_status
(
TLS
,
0
,
py_empty_cb
,
cb_extra
);
break
;
break
;
/* case pq_extf:
/* case pq_extf:
...
@@ -1113,7 +1113,7 @@ void py_do_all (void) {
...
@@ -1113,7 +1113,7 @@ void py_do_all (void) {
break;
break;
*/
*/
case
pq_send_location
:
case
pq_send_location
:
PyArg_ParseTuple
(
args
,
"iiOOO"
,
&
peer
.
type
,
&
peer
.
id
,
&
pyObj1
,
&
pyObj2
,
&
cb_extra
);
PyArg_ParseTuple
(
args
,
"iiOO
|
O"
,
&
peer
.
type
,
&
peer
.
id
,
&
pyObj1
,
&
pyObj2
,
&
cb_extra
);
tgl_do_send_location
(
TLS
,
peer
,
PyFloat_AsDouble
(
pyObj1
),
PyFloat_AsDouble
(
pyObj2
),
py_msg_cb
,
cb_extra
);
tgl_do_send_location
(
TLS
,
peer
,
PyFloat_AsDouble
(
pyObj1
),
PyFloat_AsDouble
(
pyObj2
),
py_msg_cb
,
cb_extra
);
Py_XDECREF
(
pyObj1
);
Py_XDECREF
(
pyObj1
);
Py_XDECREF
(
pyObj2
);
Py_XDECREF
(
pyObj2
);
...
@@ -1317,10 +1317,10 @@ void py_init (const char *file) {
...
@@ -1317,10 +1317,10 @@ void py_init (const char *file) {
PyList_Append
(
sysPath
,
PyUnicode_FromString
(
dirname
(
filename
)));
PyList_Append
(
sysPath
,
PyUnicode_FromString
(
dirname
(
filename
)));
// remove .py extension from file, if any
// remove .py extension from file, if any
char
*
dot
=
strrchr
(
file
name
,
'.'
);
char
*
dot
=
strrchr
(
file
,
'.'
);
if
(
dot
&&
strcmp
(
dot
,
".py"
)
==
0
)
if
(
dot
&&
strcmp
(
dot
,
".py"
)
==
0
)
*
dot
=
0
;
*
dot
=
0
;
pModule
=
PyImport_Import
(
PyUnicode_FromString
(
basename
(
file
name
)));
pModule
=
PyImport_Import
(
PyUnicode_FromString
(
basename
(
file
)));
if
(
pModule
==
NULL
||
PyErr_Occurred
())
{
// Error loading script
if
(
pModule
==
NULL
||
PyErr_Occurred
())
{
// Error loading script
logprintf
(
"Failed to load python script
\n
"
);
logprintf
(
"Failed to load python script
\n
"
);
...
...
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