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
f1c8af60
Commit
f1c8af60
authored
May 06, 2015
by
Vincent Castellano
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Complete basic API implementation. Callbacks and various functions TODO
parent
96325e2e
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
110 additions
and
62 deletions
+110
-62
loop.c
loop.c
+8
-0
pytest.py
pytest.py
+24
-3
python-tg.c
python-tg.c
+78
-59
No files found.
loop.c
View file @
f1c8af60
...
...
@@ -656,6 +656,10 @@ void on_started (struct tgl_state *TLS) {
lua_diff_end
();
#endif
#ifdef USE_PYTHON
py_diff_end
();
#endif
if
(
start_command
)
{
safe_quit
=
1
;
while
(
*
start_command
)
{
...
...
@@ -708,6 +712,10 @@ int loop (void) {
lua_binlog_end
();
#endif
#ifdef USE_PYTHON
py_binlog_end
();
#endif
if
(
sfd
>=
0
)
{
struct
event
*
ev
=
event_new
(
TLS
->
ev_base
,
sfd
,
EV_READ
|
EV_PERSIST
,
accept_incoming
,
0
);
event_add
(
ev
,
0
);
...
...
pytest.py
View file @
f1c8af60
import
tgl
import
geopy
import
pprint
from
geopy.geocoders
import
Nominatim
our_id
=
0
pp
=
pprint
.
PrettyPrinter
(
indent
=
4
)
binlog_done
=
False
;
def
on_binlog_replay_end
():
pass
binlog_done
=
True
;
def
on_get_difference_end
():
pass
...
...
@@ -16,10 +20,27 @@ def on_our_id(id):
return
"Set ID: "
+
str
(
our_id
)
def
on_msg_receive
(
msg
):
if
msg
[
"out"
]:
if
msg
[
"out"
]
and
not
binlog_done
:
return
;
tgl
.
send_msg
(
msg
[
"from"
][
"type"
],
msg
[
"from"
][
"id"
],
"PONG!"
)
if
msg
[
"to"
][
"id"
]
==
our_id
:
# direct message
ptype
=
msg
[
"from"
][
"type"
]
pid
=
msg
[
"from"
][
"id"
]
else
:
# chatroom
ptype
=
msg
[
"to"
][
"type"
]
pid
=
msg
[
"to"
][
"id"
]
text
=
msg
[
"text"
]
if
text
.
startswith
(
"!ping"
):
tgl
.
send_msg
(
ptype
,
pid
,
"PONG!"
)
d
if
text
.
startswith
(
"!location"
):
geolocator
=
Nominatim
()
location
=
geolocator
.
geocode
(
msg
[
"text"
][
9
:])
pp
.
pprint
(
location
)
tgl
.
send_location
(
ptype
,
pid
,
location
.
latitude
,
location
.
longitude
)
def
on_secret_chat_update
(
peer
,
types
):
return
"on_secret_chat_update"
...
...
python-tg.c
View file @
f1c8af60
This diff is collapsed.
Click to expand it.
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