Giter Site home page Giter Site logo

controller_bot's Introduction

controller_bot

Bot to use as a terminal for your computer when this is on. It can be useful to control a Raspbery Pi from the phone without programs or static IPs.

How it works

First of all, you must create your own Telegram bot and look for your Telegram User Id.

Getting your token

To get a token for a new Telegram Bot, in Telegram look for the @BotFather and create a new one with the command '/newbot' then just follow the instructions and you will get a token (YourTokenId).

Getting your user id

Look for the bot https://t.me/JsonDumpBot , and you will receive a message that will include the parameter "message"{"chat":{"id"}}". This number is you user id (YourUserId).

After getting these items, create a file ids.py and add the lines:

userId = YourUserId # This DOES NOT NEED quotation marks
tokenId =  "YourTokenId" # This needs the quotation marks 

And save it in the same folder as the project. Now you can run it. If something fails, you can contact me throught my Twitter.

Taking advantage in a Raspberry Pi (or any computer).

First create a folder called .controller in your folder /home/YOUR-USER-DIRECTORY. Now run the command sudo nano /etc/systemd/system/controller.service and write in it

[Unit]
Description=Telegram Terminal Bot
Wants=network-online.target
After=network.target network-online.target
StartLimitIntervalSec=0

[Service]
Type=idle
WorkingDirectory=/home/YOUR-USER-DIRECTORY
ExecStart=/usr/bin/python3 /home/YOUR-USER-DIRECTORY/.controller/main.py
Restart=on-failure
RestartSec=3s

[Install]
WantedBy=multi-user.target

Then save it. Now type in the terminal

sudo -m pip install pyTelegramBotAPI

Because probably you ran this program in your user, not as the sudo user, and you need to install it this way to be able to use the program correctly as a daemon. After it, now run in the terminal

systemctl enable controller
systemctl daemon-reload

Finally reboot your computer and you will be able to run this in your Telegram bot.

Notice that this will only work if you're connecting to a network already registered in your computer. If not, the systemd program will continue trying to conncet until it achieves it.

controller_bot's People

Contributors

gfant avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.