Telegram Bot For Screenshot Generation.

Overview

Screenshotit_bot

Telegram Bot For Screenshot Generation.

Description

An attempt to implement the screenshot generation of telegram files without downloading the entire file. Live version can be found here @screenshotit_bot.

Installation Guide

Prerequisites

  • FFmpeg.
  • Python3 (3.6 or higher).

Local setup

The setup given here is for a linux environment (Debian/Ubuntu).

  • Clone to local machine.
$ git clone https://github.com/odysseusmax/animated-lamp.git
$ cd animated-lamp
  • Create and activate virtual environment.
$ python3 -m venv venv
$ source venv/bin/activate
  • Install dependencies.
$ pip3 install -U -r requirements.txt

Deploy on Heroku

Press the below button to Fast deply to Heroky

Deploy

Environment Variables

Properly setup the environment variables or populate config.py with the values. Setting up environment variables is advised as some of the values are sensitive data, and should be kept secret.

  • API_ID(required) - Get your telegram API_ID from https://my.telegram.org/.
  • API_HASH(required) - Get your telegram API_HASH from https://my.telegram.org/.
  • BOT_TOKEN(required) - Obtain your bot token from Bot Father.
  • LOG_CHANNEL(required) - Log channel's id.
  • DATABASE_URL(required) - Mongodb database URI.
  • AUTH_USERS(required) - Admin(s) of the bot. User's telegram id separated by space. Atleast one id should be specified.
  • HOST(required) - Public URL of file streaming service (See Setting up Streaming Service).
  • SESSION_NAME(optional) - Name you want to call your bot's session, Eg: bot's username.
  • MAX_PROCESSES_PER_USER(optional) - Number of parallel processes each user can have, defaults to 2.
  • MAX_TRIM_DURATION(optional) - Maximum allowed video trim duration in seconds. Defaults to 600s.
  • TRACK_CHANNEL(optional) - User activity tracking channel's id. Only needed if you want to track and block any user. Disabled by default.
  • SLOW_SPEED_DELAY(optional) - Delay required between each interaction from users in seconds. Defaults to 5s.
  • TIMEOUT (optional) - Maximum time alloted to each process in seconds, after which process will be cancelled. Defaults to 1800s(30 mins).
  • DEBUG (optional) - Set some value to use DEBUG logging level. INFO by default.
  • IAM_HEADER (optional) - Authentication token for streaming service. Defaults to ''.
  • WORKER_COUNT (optional) - Number of process to be handled at a time. Defaults to 20.

Run bot

$ python3 -m bot

Now go and /start the bot. If everything went right, bot will respond with welcome message.

Setting up Streaming Service

The streaming service can be a custom version of TgFileStream, modded to work with this setup. The mod basicaly is adding a type of header based authentication and changing the endpoints. The authentication part is optional and the endpoint used here is /file/:chat_id/:message_id. Make sure to note these changes when deploying your own instance. The streaming service used for @screenshotit_bot is not related to TgFileStream and I do not plan to make it OSS.

Supported commands and functions

Commands

General commands

  • /start - Command to start bot or check whether bot is alive.
  • /settings - Command to configure bot's behavior'
  • /set_watermark - Command to add custom watermark text to screenshots. Usage: /set_watermark watermark_text.

Admin commands

Any user specified in AUTH_USERS can use these commands.

  • /status - Returns number of total users.
  • /ban_user - Command to ban any user. Usage: /ban_user user_id ban_duration ban_reason. user_id - telegram id of the user, ban_duration - ban duration in days, ban_reason - reason for ban. All 3 parameters are required.
  • /unban_user - Command to unban any banned user. Usage: /unban_user user_id. user_id - telegram id of the user. The parameter is required.
  • /banned_users - Command to view all banned users. Usage: /banned_users. This takes no parameters.
  • /broadcast - Command to broadcast some message to all users. Usage: reply /broadcast to the message you want to broadcast.

Functions

  • Screenshot Generation - Generates screenshots from telegram video files or streaming links. Number of screenshots range from 2-10.
  • Sample Video Generation - Generates sample video from telegram video files or streaming links. Video duration range from 30s to 150s. Configurable in /settings.
  • Video Trimming - Trims any telegram video files or streaming links.

Settings

In bot settings.

  • Upload Mode - Screenshot upload mode. Either as image file or as document file. Defaults to as image file.
  • Watermark - Watermark text to be embedded to screenshots. Texts upto 30 characters supported. Disabled by default.
  • Watermark Color - Font color to be used for watermark. Any of white, black, red, blue, green, yellow, orange, purple, brown, gold, silver, pink. Defaults to white.
  • Watermark Font Size - Font size to be used for watermarks. Any of small(30), medium(40), large(50). Defaults to medium.
  • Watermark Position - Watermark text's position. Defaults to bottom left.
  • Sample Video Duration - Sample video's duration. Any of 30s, 60s, 90s, 120s, 150s. Defaults to 30s.
  • Screenshot Genetation Mode - Either random or equally spaced. Defaults to equally spaced.

Contributions

Contributions are welcome.

Contact

You can contact me @odysseusmax.

Thanks

Thanks to Dan for his Pyrogram library.

Thanks to Tulir Asokan for his TgFileStream Bot.

Dependencies

  • pyrogram
  • tgcrypto
  • motor
  • dnspython
  • async-timeout
  • aiohttp

License

Code released under The GNU General Public License.

Takes upcoming items from a Google Calendar and posts them to Slack.

Google Calendar to Slack by Jason Snell - [email protected] This Python s

6 Aug 21, 2022
Mixcloud API wrapper for Python and Async IO

aiomixcloud Mixcloud API wrapper for Python and Async IO aiomixcloud is a wrapper library for the HTTP API of Mixcloud. It supports asynchronous opera

Aristotelis Mikropoulos 26 Dec 31, 2022
An all-in-one discord bot!

Interbot Interbot is a do-it-all bot originally made for the Interbyte Studios discord server. This repo contains the code for this bot, allowing you

Logan 5 Aug 03, 2021
The most versatile torrent leecher and youtube-dl bot for telegram

TorToolkit Telegram So basically Tortoolkit is aimed to be the most versatile torrent leecher and youtube-dl bot for telegram. This bot is highly cust

αвιנтн 1 Nov 11, 2021
A.I and game for gomoku, working only on windows

Gomoku (A.I of gomoku) The goal of the project is to create an artificial intelligence of gomoku. Goals Beat the opponent. Requirements Python 3.7+ Wo

Luis Rosario 13 Jun 20, 2021
N3RP (the NFT Rental Protocol) allows users to trustlessly rent out their ERC721-based assets.

N3RP • N3RP - An NFT Rental Protocol (pronounced "nerp") Smart Contracts Passing Tests, Frontend Functional But Is Being Beautified. 🛠 Introduction T

Grant Stenger 56 Dec 07, 2022
Braintree Python library

Braintree Python library The Braintree Python library provides integration access to the Braintree Gateway. TLS 1.2 required The Payment Card Industry

Braintree 230 Dec 18, 2022
Scrapping malaysianpaygap & Extracting data from the Instagram posts

Scrapping malaysianpaygap & Extracting data from the posts Recently @malaysianpaygap has gotten quite famous as a platform that enables workers throug

Yudhiesh Ravindranath 65 Nov 09, 2022
A python package to easy the integration with Direct Online Pay (Mpesa, TigoPesa, AirtelMoney, Card Payments)

A python package to easy the integration with Direct Online Pay (DPO) which easily allow you easily integrate with payment options once without having to deal with each of them individually;

Jordan Kalebu 2 Nov 25, 2021
A Very Simple Telegram Files Rename Bot by @AbirHasan2005

Rename-Bot This is a very simple Telegram Files Rename Bot by @AbirHasan2005. Features Rename Videos, Files or Audios. Permanent Custom Thumbnail Supp

Abir Hasan 124 Dec 25, 2022
Pdisk Uploader Bot

pdisk-bot pdisk uploader telegram bot How To Use Configs TG_BOT_TOKEN - Get bot token from @BotFather API_ID - From my.telegram.org API_HASH - From my

lokaman chendekar 25 Oct 21, 2022
Web3 Pancakeswap Sniper & honeypot detector Take Profit/StopLose bot written in python3, For ANDROID WIN MAC & LINUX

🏆 Pancakeswap BSC Sniper Bot web3 with honeypot detector (ANDROID WINDOWS MAC LINUX) 🥇 ⭐️ ⭐️ ⭐️ First SNIPER BOT for ANDROID & WINDOWS with honeypot

HYDRA 2 Dec 24, 2021
Simple library for logging to Loggly

#Hoover A python wrapper used to hit the Loggly. API For more information on Hoover see http://wiki.loggly.com/hooverguide ##Install With this git rep

Hoover Loggly 34 May 19, 2021
Vladilena Mirize Music - Bot Music Telegram By @zenfrans

Vladilena Mirize Music - Bot Music Telegram By @zenfrans

Wahyusaputra 3 Feb 12, 2022
See trending stock tickers on Reddit and check Stock perfomance

See trending stock tickers on Reddit and check Stock perfomance

Abbas 1.5k Jan 06, 2023
❤️ Hi There Im EzilaX ❤️ A next gen powerful telegram group manager bot 😱 for manage your groups and have fun with other cool modules Made By Sadew Jayasekara 🔥

❤️ EzilaX v1 ❤️ Unmaintained. The new repo of @EzilaXBot is Public. (It is no longer based on this source code. The completely rewritten bot available

Sadew Jayasekara 18 Nov 24, 2021
Monitor your Binance portfolio

Binance Report Bot The intent of this bot is to take a snapshot of your binance wallet, e.g. the current balances and store it for further plotting. I

37 Oct 29, 2022
EduuRobot Telegram bot source code.

EduuRobot A multipurpose Telegram Bot made with Pyrogram and asynchronous programming. Requirements Python 3.6+ An Unix-like operating system (Running

Amano Team 119 Dec 23, 2022
Ig-Crackv2 - Crack Instagram Version 2.9

★★ Information ★★ ★★Menu Special Crack Melalui Pengikut Crack Melalui Mengikuti

Risky [ Zero Tow ] 11 Aug 30, 2022
Plataforma para atendimento a outras empresas que necessitam de atendimento técnico.

Plataforma para atendimento a outras empresas que necessitam de atendimento técnico. É possível que os usuarios de empresas parceiras registrem solici

Kelvin Alisson Cantarino 2 Jun 29, 2022