Jump to content

[Answered] Telegram Bot With Long Polling


denkorzh

Recommended Posts

Hello.

I want to host Telegram bot written in python 3 which uses long polling at Ricky server.

So, I uploaded files to my public_html.

I have written #!/usr/bin/python3.6 as the first line of my main file bot.py and have given 755 permission to it.

So, my question is how to run my bot for ever on Heliohost?

 

Cron jobs don't seem to be a solutiuon or I just don't understand how to use them for my case.

Any answers are appreciate.

Link to comment
Share on other sites

In the cron job field put something like:

/usr/bin/python3.6 /home/denkorzh/path/to/script/telegram.py
If you don't want to get emails containing the output of the script you can tack this to the end:

/usr/bin/python3.6 /home/denkorzh/path/to/script/telegram.py >/dev/null 2>&1
That extra bit at the end redirects stdout and stderr to /dev/null which essentially means it gets deleted.
Link to comment
Share on other sites

Keep in mind that we do monitor for cpu load and memory usage. We allow unlimited usage of both until you begin to slow down the other sites on your server or cause downtime. When that starts to happen we look at the log files of who is using the most and suspend them first. Running a process continually like this has a tendency to put you on the top of the list.

 

Another option that might cause less load is I can set up a remote cron for you. Basically what that means is you make a script that is visible through a browser like http://denkorzh.heliohost.org/cgi-bin/telegram.py that runs for a finite amount of time and then exits. Then I set it up so that script gets executed remotely as often as every 5 minutes.

 

Let us know if you need any help with anything.

 

How should I run cronjob once and for ever?

Just set the cron to run sometime in the next five minutes or whatever, and then wait until it starts. Once it's going delete the cron job.
Link to comment
Share on other sites

That sounds good. My script doesn't seem to use much cpu or memory but if it occurs to do I would definitely limit its execution time.

By the way could you say is there python 3 installed at Ricky? And coul you install pytelegrambotapi python package for Ricky?

Thanks a lot.

Link to comment
Share on other sites

You would have to ask an admin or run another cron. Actually that is a common thing for people to do is leave the cronjob set up to run once or twice a day, and when the new cron fires the script looks for previous versions of itself and kills them prior to running the main loop. This is especially useful if there is a bug in the code that causes it to hang for some reason. The next cron will stop the broken script and start a new version. Here is how I would stop the script with a cron:

killall -u denkorzh >/dev/null 2>&1
  • Like 1
Link to comment
Share on other sites

Python 3.6.1 has been installed on Ricky at /usr/bin/python3.6 just like Tommy.

 

pyTelegramBotAPI has been installed on python 3.6.1 on Ricky.

 

Just make sure you don't violate the spam line in our terms of service:

Your site will not email, personal message, instant message, or communicate any kind of "spam," or unsolicited bulk advertising of any kind.

ToS: http://wiki.helionet.org/Terms
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...