All Projects → Alkesst → Pytelbot

Alkesst / Pytelbot

Licence: mit
A playful bot in telegram

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Pytelbot

Informer
A Telegram Mass Surveillance Bot in Python
Stars: ✭ 745 (+6108.33%)
Mutual labels:  bot, telegram-bot, telegram
Java Telegram Bot Api
Telegram Bot API for Java
Stars: ✭ 819 (+6725%)
Mutual labels:  bot, telegram-bot, telegram
Swiftybot
How to create a Telegram, Facebook Messenger, and Google Assistant bot with Swift using Vapor on Ubuntu / macOS.
Stars: ✭ 247 (+1958.33%)
Mutual labels:  bot, telegram-bot, telegram
Example Bot
[WIP] An A-Z example of a PHP Telegram Bot.
Stars: ✭ 211 (+1658.33%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Bot
Ruby gem for building Telegram Bot with optional Rails integration
Stars: ✭ 433 (+3508.33%)
Mutual labels:  bot, telegram-bot, telegram
Urban Bot
🤖 The universal chatbot library based on React. Write once, launch Telegram, Facebook, Slack, ... every messenger with chatbots
Stars: ✭ 223 (+1758.33%)
Mutual labels:  bot, telegram-bot, telegram
Zabbix In Telegram
Zabbix Notifications with graphs in Telegram
Stars: ✭ 710 (+5816.67%)
Mutual labels:  bot, telegram-bot, telegram
Telebot
Write Telegram bots in Rust with Tokio and Futures
Stars: ✭ 179 (+1391.67%)
Mutual labels:  bot, telegram-bot, telegram
Groupbutler
This bot can help you in managing your group with rules, anti-flood, description, custom triggers, and much more!
Stars: ✭ 399 (+3225%)
Mutual labels:  bot, telegram-bot, telegram
Pytg
Python package that wraps around Telegram messenger CLI. Send and receive messages, and more.
Stars: ✭ 365 (+2941.67%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Bot Api
First Telegram Bot API node.js library
Stars: ✭ 205 (+1608.33%)
Mutual labels:  bot, telegram-bot, telegram
Telegraf
Modern Telegram Bot Framework for Node.js
Stars: ✭ 5,178 (+43050%)
Mutual labels:  bot, telegram-bot, telegram
Telegram Rat
Windows Remote Administration Tool via Telegram. Written in Python
Stars: ✭ 201 (+1575%)
Mutual labels:  bot, telegram-bot, telegram
Tlg joincaptchabot
Telegram Bot to verify if users that join a group, are humans. The Bot send an image captcha for each new user, and kick any of them that can't solve the captcha in a specified time.
Stars: ✭ 226 (+1783.33%)
Mutual labels:  bot, telegram-bot, telegram
Icopy
fclone telegram interface.Send commands to Telegram BOT for get a convience way to control fclone resources copy missions.
Stars: ✭ 188 (+1466.67%)
Mutual labels:  bot, telegram-bot, telegram
The Guard Bot
The Guard, a Telegram bot to moderate groups.
Stars: ✭ 299 (+2391.67%)
Mutual labels:  bot, telegram-bot, telegram
Java Telegram Bot Tutorial
Java Telegram Bot Tutorial. Feel free to submit issue if you found a mistake.
Stars: ✭ 165 (+1275%)
Mutual labels:  bot, telegram-bot, telegram
Micro Bot
🤖 Zero-configuration Telegram bot runner
Stars: ✭ 173 (+1341.67%)
Mutual labels:  bot, telegram-bot, telegram
Shieldy
@shieldy_bot Telegram bot repository
Stars: ✭ 351 (+2825%)
Mutual labels:  bot, telegram-bot, telegram
Tgbot Cpp
C++ library for Telegram bot API
Stars: ✭ 439 (+3558.33%)
Mutual labels:  bot, telegram-bot, telegram

PyTel-Bot

A playful telegram bot.

Requirements

Python3 or Docker. Not both!

Introduction

A telegram bot that interacts with the users in telegram groups. It sends photos, videos and stickers.

TOKENS

The tokens are saved using environment variables:

VARIABLE DESCRIPTION
PYTEL_TELEGRAM Telegram API key
PYTEL_CONSUMER_KEY Twitter Consumer Key
PYTEL_CONSUMER_SECRET Twitter Consumer Secret
PYTEL_ACCESS_TOKEN Twitter's user Access Token
PYTEL_ACCES_TOKEN_SECRET Twitter's user Access Token Secret
PYTEL_PATH Optional variable that points to where the files and database are stored
WEBHOOK_PATH_PREFIX Defines the public url to enable the webhook mode

Abstract

To enable the webhook mode, the environment variable WEBHOOK_URL must be defined with the public URL (it supposes that there is a reverse proxy that enables HTTPS for the public part). By default, expects to receive all the requests without any path prefix, but you can define one using the env var WEBHOOK_PATH_PREFIX. Both env vars can contain the token {token} that will be replaced with the real token if needed.

Example 1

  • WEBHOOK_URL: https://casita.melchor9000.me/pytelbot
  • WEBHOOK_PATH_PREFIX: pytelbot

This will receive updates to https://casita.melchor9000.me/pytelbot, where the reverse proxy will send them to the bot under the path /pytelbot.

Example 2

  • WEBHOOK_URL: https://casita.melchor9000.me/pytelbot
  • WEBHOOK_PATH_PREFIX: (empty string)

This will receive updates to https://casita.melchor9000.me/pytelbot, where the reverse proxy will send them to the bot under the path / (removing the pytelbot path prefix).

Example 3

  • WEBHOOK_URL: https://casita.melchor9000.me/bots/{token}
  • WEBHOOK_PATH_PREFIX: {token} (empty string)

This will receive updates to https://casita.melchor9000.me/bots/ (where <TOKEN> is the bot token), where the reverse proxy will send them to the bot under the path /<TOKEN> (removing the bots path prefix and where <TOKEN> is the bot token).

More information: https://github.com/python-telegram-bot/python-telegram-bot/wiki/Webhooks#using-nginx-with-one-domainport-for-all-bots

AUTOMATE THE BOT

Using Docker

Before creating the image with docker, we need to create the .env with the next content:

PYTEL_TELEGRAM=*REPLACE WITH YOUR TOKEN*
PYTEL_CONSUMER_KEY=*REPLACE WITH YOUR TOKEN*
PYTEL_CONSUMER_SECRET=*REPLACE WITH YOUR TOKEN*
PYTEL_ACCESS_TOKEN=*REPLACE WITH YOUR TOKEN*
PYTEL_ACCES_TOKEN_SECRET=*REPLACE WITH YOUR TOKEN*
PYTEL_PATH=*REPLACE WITH YOUR CUSTOM PATH*

By default, PYTEL_PATH is equals to ../pytel_stuff All the images you want to use will need to be in the docker image.

First create the image with docker image build -t *tag_name* . and will create an image from the Dockerfile.

Once created your image, just run with docker run -it --rm -v *pytel_files_path*:/pytel_stuff --env-file .env *tag_name*.

Using Services

Script:

To run the bot when turning on the raspberry we must create a service.

First of all we need to create a script that pulls the changes from git, and then, runs the bot

#!/usr/bin/env bash
cd /home/pi/Documentos/PyTel-Bot # Path to where the source code is

#  ... SET THE TOKENS VARIABLES HERE ...
export PYTEL_TELEGRAM=*REPLACE WITH YOUR TOKEN*
export PYTEL_CONSUMER_KEY=*REPLACE WITH YOUR TOKEN*
export PYTEL_CONSUMER_SECRET=*REPLACE WITH YOUR TOKEN*
export PYTEL_ACCESS_TOKEN=*REPLACE WITH YOUR TOKEN*
export PYTEL_ACCES_TOKEN_SECRET=*REPLACE WITH YOUR TOKEN*
export PYTEL_PATH=*REPLACE WITH YOUR CUSTOM PATH*

STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error)
while [  $STATE == "error" ]; do
    #do a ping and check that its not a default message or change to grep for something else
    STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error)

    #sleep for 2 seconds and try again
    sleep 2
done
echo "Pulling PyTel-Bot..."
echo
git pull
echo
echo "Pull done..."
echo "Initializating PyTel-Bot..."
python3 main.py

It is requiered to use the following code, because the service will start immediatly when the rpi turns on, so, we need to check if there is internet conection before trying to pull from git.

STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error)
while [  $STATE == "error" ]; do
    #do a ping and check that its not a default message or change to grep for something else
    STATE=$(ping -q -w 1 -c 1 `ip r | grep default | cut -d ' ' -f 3` > /dev/null && echo ok || echo error)

    #sleep for 2 seconds and try again
    sleep 2
done

Service:

Made the script, now you need to create a .service file with the following code:

[Unit]
Description=PyTwe-Bot

[Service]
ExecStart=/home/pi/rpi_pytwe_script.sh
User=pi
Group=pi

[Install]
WantedBy=multi-user.target

Enabling service and moving to the path:

When you have your .service file, you need to move the file into /etc/systemd/system/ and use the following command:

sudo systemctl enable pytwe.service

Spoiler: you will need to move first your service where you want and then use sudo mv pytwe_service /etc/systemd/system

Don't forget this:

chmod a+x rpi_pytwe_script.sh

And now your bot will run when the rpi powers on.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].