Telegram Integration - Printable Version +- TACTIC Open Source (http://forum.southpawtech.com) +-- Forum: TACTIC Open Source (http://forum.southpawtech.com/forumdisplay.php?fid=3) +--- Forum: TACTIC Discussion (http://forum.southpawtech.com/forumdisplay.php?fid=4) +--- Thread: Telegram Integration (/showthread.php?tid=3) |
Telegram Integration - listy - 10-01-2019 Hi All! Today i was played a little with telegram bots and notifications from tactic. Want to share some raw code, to anyone who's interesting. This trigger on change|sthpw/task Code: import telegram Also, wanted to ask devs. Does it possible to run telegram bot polling from inside tactic or it is not recommended? It would be great to have ability to access all TACTIC from itself, not through slow xmlrpc api. And some code for mass notifications: Code: # **** making mass notification about free episode **** RE: Telegram Integration - Diego - 10-04-2019 Hi listy, nice idea to use telegram! I do a similar thing with rocketchat I think you don't have to use the xmlrpc API in your trigger, you should be able to do something like: Code: from pyasm.search import Search RE: Telegram Integration - listy - 10-04-2019 Hi, Diego. When i run telegram bot polling script outside of tactic there is the only option - use xmlrpc api. So thats why i asking about how to run bot, not just sender from inside of TACTIC itself My goal is to make smart messages, where supervisor can push the button from his messenger and for example approve/disapprove task RE: Telegram Integration - Diego - 10-04-2019 I see, I misunderstood you question, what about putting your main script in the tactic script editor or in the custom python_path specified in tactic-conf.xml and then call it from an outside script using the xmlrpc api only to fire up up you main script inside tactic. The external script would just do: Code: server.execute_python_script("path_in_tactic_script_editor/mass_notification", kwargs={'test_arg': 'test'}) this should launch "path_in_tactic_script_editor/mass_notification" server side in tactic. RE: Telegram Integration - remkonoteboom - 10-16-2019 When you say "inside TACTIC", do you mean as a library that Python code can access or do you mean to run as a separate thread or do you mean as a separate process running beside TACTIC? How do you "run" this bot? If there is a library that allows for internal running of the bot, then you can access it in process. We do this with numerous interal services. CherryPy is a good example. We also use a sheduler which runs internally, which can fire off threads to do separate tasks. RE: Telegram Integration - listy - 10-16-2019 (10-16-2019, 01:07 PM)remkonoteboom Wrote: When you say "inside TACTIC", do you mean as a library that Python code can access or do you mean to run as a separate thread or do you mean as a separate process running beside TACTIC? How do you "run" this bot? If there is a library that allows for internal running of the bot, then you can access it in process. We do this with numerous interal services. CherryPy is a good example. We also use a sheduler which runs internally, which can fire off threads to do separate tasks.Hi! Thank you for answering me. By running inside a TACTIC, I mean running a process that can be started, closed, or restarted by a TACTIC, and this process would have access to all the objects that the current TACTIC server-instance operates on. At the moment, the bot is running as a separate python process that accesses the tactic through tactic_server_stub via localhost RE: Telegram Integration - remkonoteboom - 10-16-2019 If the process is running on a TACTIC server, for any process to have full access to TACTIC, you can simply initialize the process in Batch mode. ie: test_script.py import tacticenv from pyasm.security import Batch Batch(project_code=project_code) import sys project_code = sys.args[1] from pyasm.search import Search animators_logins = Search.eval("@SOBJECT(sthpw/login_in_group['login_group','animator'].sthpw/login)") .... This will run natively and have the same speed as the TACTIC services. You can run this code with a separate thread (TACTIC is thread-safe) or you can run it in a separate process. From what I can tell, this process can be heavy so you would want to run it as a separate process. You can use a native subprocess to run this as a non-blocking daemon. RE: Telegram Integration - listy - 10-16-2019 Wow! This is really awesome! I will test it with my Bot RE: Telegram Integration - listy - 05-20-2020 Hi, again! Don't know why, but i have some errors when try to use Search.eval It puts me to this assert Code: def get_login(): I have tried to pass login_code to batch, no luck. In newer version of TACTIC there is also ticket keyword, but it is missing in 4.5 I am doing something wrong? RE: Telegram Integration - remkonoteboom - 05-21-2020 The ticket keyword just allows you to reuse login ticket on batch scripts. The login_code keyword allows you to run as a particular user, however if none is specified, it will run as "admin". Other than that, if this is run on the TACTIC server, it should just work. Here is a full script example: Code: import tacticenv This produces: Code: python ~/test.py |