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
3a13f800
Commit
3a13f800
authored
May 02, 2015
by
Vincent Castellano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Got on_msg_receive working
parent
b658b617
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
12 additions
and
8 deletions
+12
-8
main.c
main.c
+3
-0
pytest.py
pytest.py
+1
-1
python-tg.c
python-tg.c
+8
-7
No files found.
main.c
View file @
3a13f800
...
...
@@ -669,6 +669,9 @@ void args_parse (int argc, char **argv) {
#endif
#ifdef USE_LUA
"s:"
#endif
#ifdef USE_PYTHON
"Z:"
#endif
,
long_options
,
NULL
))
!=
-
1
)
{
...
...
test.py
→
py
test.py
View file @
3a13f800
...
...
@@ -10,7 +10,7 @@ def on_our_id():
pass
def
on_msg_receive
(
msg
):
return
"Got msg
!"
return
"Got msg
from "
+
msg
[
"from"
][
"peer"
][
"first_name"
]
def
on_secret_chat_update
(
peer
,
types
):
return
"on_secret_chat_update"
...
...
python-tg.c
View file @
3a13f800
...
...
@@ -422,7 +422,7 @@ void py_new_msg (struct tgl_message *M) {
msg
=
get_message
(
M
);
arglist
=
Py_BuildValue
(
"
O
"
,
msg
);
arglist
=
Py_BuildValue
(
"
(O)
"
,
msg
);
result
=
PyEval_CallObject
(
_py_new_msg
,
arglist
);
Py_DECREF
(
arglist
);
...
...
@@ -438,7 +438,7 @@ void py_secret_chat_update (struct tgl_secret_chat *C, unsigned flags) {
peer
=
get_peer
(
C
->
id
,
(
void
*
)
C
);
types
=
get_update_types
(
flags
);
arglist
=
Py_BuildValue
(
"
OO
"
,
peer
,
types
);
arglist
=
Py_BuildValue
(
"
(OO)
"
,
peer
,
types
);
result
=
PyEval_CallObject
(
_py_secret_chat_update
,
arglist
);
Py_DECREF
(
arglist
);
...
...
@@ -1462,11 +1462,8 @@ void py_chat_update (struct tgl_chat *C, unsigned flags) {
//}
//
//
static
void
my_python_register
(
PyObject
*
dict
,
const
char
*
name
,
PyObject
*
f
)
{
// Store callables for python functions
f
=
PyDict_GetItemString
(
dict
,
name
);
assert
(
PyCallable_Check
(
f
));
// TODO handle this
}
#define my_python_register(dict, name, f) \
f = PyDict_GetItemString(dict, name);
...
...
@@ -1479,6 +1476,10 @@ void py_init (const char *file) {
Py_Initialize
();
PyObject
*
sysPath
=
PySys_GetObject
((
char
*
)
"path"
);
PyList_Append
(
sysPath
,
PyString_FromString
(
"."
));
pName
=
PyString_FromString
(
file
);
pModule
=
PyImport_Import
(
pName
);
pDict
=
PyModule_GetDict
(
pModule
);
...
...
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