send_msg implemented

This commit is contained in:
Vincent Castellano 2015-05-03 22:42:11 -07:00
parent 5994d34eef
commit 30f0a3b128
4 changed files with 370 additions and 646 deletions

5
loop.c
View File

@ -57,6 +57,7 @@
#include "telegram.h"
#include "loop.h"
#include "lua-tg.h"
#include "python-tg.h"
#include <tgl/tgl.h>
#include <tgl/tgl-binlog.h>
#include <tgl/tgl-net.h>
@ -215,6 +216,10 @@ void net_loop (void) {
lua_do_all ();
#endif
#ifdef USE_PYTHON
py_do_all ();
#endif
if (safe_quit && !TLS->active_queries) {
printf ("All done. Exit\n");
do_halt (0);

View File

@ -16,9 +16,10 @@ def on_our_id(id):
return "Set ID: " + str(our_id)
def on_msg_receive(msg):
pp.pprint(msg)
if msg["out"]:
return;
tgl.send_msg(msg["from"]["type"], msg["from"]["id"], "PONG!")
return "Got msg from " + msg["from"]["peer"]["first_name"]
def on_secret_chat_update(peer, types):
return "on_secret_chat_update"

File diff suppressed because it is too large Load Diff

View File

@ -57,17 +57,6 @@ function get_title (P, Q)
end
end
local lgi = require ('lgi')
local notify = lgi.require('Notify')
notify.init ("Telegram updates")
local icon = os.getenv("HOME") .. "/.telegram-cli/telegram-pics/telegram_64.png"
function do_notify (user, msg)
local n = notify.Notification.new(user, msg, icon)
n:show ()
end
-- }}}
function on_msg_receive (msg)
if started == 0 then
@ -76,7 +65,6 @@ function on_msg_receive (msg)
if msg.out then
return
end
do_notify (get_title (msg.from, msg.to), msg.text)
if (msg.text == 'ping') then
if (msg.to.id == our_id) then