Closed cun closed 9 years ago
I have to do a "cron" that every X mins call the subscribed plugins. Maybe I will code it today.
Thanks to you.
Cool Cheers Yagop, Yeah that's exactly all it needs, a crontab of its own. As soon as you have one you can make this really robust.
E.G :-
... If you want to extend this you could add a listen port to allow almost any API with a "message", "target" that way you can push anything external to the process too if you ever wanted the other way around from a CRON job, Just a thought.
Love this little app though its totally cool. I've just added the fork for the Plugin reload that voiser added, Well handy, Thanks! :+1:
There you have https://github.com/yagop/telegram-bot/commit/8b04aefd4571b21265aae89a265e938b99404e88 !
This is a basic version using postpone (cb_function, cb_extra, timeout)
with 5mins I did an example for service status notification.
I will work more on it to add custom callback time, not 5 mins.
The API sounds interesting I will think about that.
Yes, @voiser work is always amazing. I am working on disabling / enabling plugins and he gave me a hand.
Thanks again to you! :smile:
Cool, this looks like it's going to be fun! :dancer:
-- Just got an error though *Used google as an example of what I'm getting. It fails to see the URL and crashes the bot out completely.
[21:15] DGHQ <<< ALERT: http://www.google.co.uk is offline
SIGNAL received h./tg/bin/telegram-cli(print_backtrace+0x1c)[0x4402bc] ./tg/bin/telegram-cli(termination_signal_handler+0x64)[0x440344] /lib/x86_64-linux-gnu/libc.so.6(+0x36150)[0x7f3af8705150] ./tg/bin/telegram-cli[0x4615f2] ./tg/bin/telegram-cli(tglq_query_result+0xf4)[0x45ac04] ./tg/bin/telegram-cli[0x4545f9] ./tg/bin/telegram-cli[0x47e8fd] /usr/lib/libevent-2.0.so.5(event_base_loop+0x20c)[0x7f3af991494c] ./tg/bin/telegram-cli(net_loop+0x7b)[0x44164b] ./tg/bin/telegram-cli(main_loop+0x10)[0x441830] ./tg/bin/telegram-cli(loop+0x4cd)[0x442d1d] ./tg/bin/telegram-cli(main+0x283)[0x43ee73] /lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7f3af86f076d] ./tg/bin/telegram-cli[0x43ef5d]
hang on, it's because I included http i believe!
This definitely is not working. If it goes down, (Or if you switch it around so its messaging when online) It fires one message and then the above error happens and it crashes out.
Not sure why, but I thought I'd let you know.
Dont include http. Use only domain names or IPs. Did you try with www.google.co.uk
?
Yeah it works for about 20 seconds then It crashes out with the above issue.
OK, bit of debugging, if you set the if statement to if not socket.connect(addr, 80) and start it, it works fine... then if you switch it to if socket.connect(addr, 80) and !reload the plugins it works OK, but if you set it to if socket.connect(addr, 80) and restart the bot, it crashes after 1 message (20 seconds ish).
Might help you a little?
You are right, the behavior isn't right, sometimes it crashes. I think using socket.try()
inside socket.protect(func)
will control the error and fix it. http://w3.impa.br/~diego/software/luasocket/socket.html#protect I will do this afternoon.
OK Brilliant yagop, It's OK, I'm going to be testing and using this a fair bit and hopefully release some plugins when I get better with LUA! :) - first time I've used it.
I finally fixed thaf f*cking bug. https://github.com/yagop/telegram-bot/commit/aa7ac75d312ac260a9751f1ab556f43cffc64c0f
It was caused because I was calling cron_plugins()
inside on_binlog_replay_end ()
and it was necessary a postpone
ahhh Great news! :+1: I will give this a test this week. Thankyou for your effort! - I'll hopefully be back with postive results too!
This is working perfectly now, and has been for a week. Thanks yagop!
I close the issue, at the moment cron is disabled by default.
Hi there!
Firstly, seriously nice work with this, It's totally reliable and simple to script for. However I have a small issue. I'm wanting to push alerts to the process, and have the bot read them.
I've started by creating an API where the bot can check the alerts and if one exists it posts it in the chat however I need to make this check every n'th minute or second.
How can i create a plugin that checks every x, without it looking for a users interaction or input via the chat.
Cheers Dan.