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.

OpenEmu Discord Rich Presence provided with Python!

A simple application that provides your current OpenEmu game as an RPC state in Discord via PyPresence. How to use Unzip and open the latest x86_64 ve

Deltaion Lee 6 May 30, 2022
数字货币动态趋势网格,随着行情变动。目前实盘月化10%。目前支持币安,未来上线火币、OKEX。

数字货币动态趋势网格,随着行情变动。目前实盘月化10%。目前支持币安,未来上线火币、OKEX。

幸福村的码农 98 Dec 27, 2022
A management system designed for the employees of MIRAS (Art Gallery). It is used to sell/cancel tickets, book/cancel events and keeps track of all upcoming events.

Art-Galleria-Management-System Its a management system designed for the employees of MIRAS (Art Gallery). Backend : Python Frontend : Django Database

Areesha Tahir 8 Nov 30, 2022
This bot will pull a stream of tweets based on rules you set and automatically reply to them.

Twitter reply bot This bot will pull a stream of tweets based on rules you set and automatically reply to them. I built this bot in order to help comb

Brains 1 Feb 13, 2022
☄️ High performance, easy to use and feature-rich Solana SDK for Python.

Solathon is an high performance, easy to use and feature-rich Solana SDK for Python. Easy for beginners, powerful for real world applications.

Bolt 28 Oct 10, 2022
Monitor robot of Apple Store's products, using DingTalk notification.

概述 本项目应用主要用来监测Apple Store线下直营店货源情况,主要使用Python实现。 首先感谢iPhone-Pickup-Monitor项目带来的灵感,同时有些实现也直接使用了该项目的一些代码。 本项目在iPhone-Pickup-Monitor原有功能的基础上去掉了声音通知,但添加了多

Lennon Chin 159 Dec 09, 2022
Evernote SDK for Python

Evernote SDK for Python Evernote API version 1.28 This SDK is intended for use with Python 2.X For Evernote's beta Python 3 SDK see https://github.com

Evernote 612 Dec 30, 2022
Python based Discord Bot with a simple music player

C32 Discord Bot Discord bot that plays music Table Of Contents About the Project Built With Acknowledgements About The Project Play music using the !p

Christopher Burwell 2 Oct 17, 2021
A simple Python TDLib wrapper

Telegram Forwarder App Description pywtdlib (Python Wrapper TDLib) is a simple synchronous Python wrapper that makes you easy to create new Python Tel

Álvaro Fernández 2 Jan 04, 2023
The scope of this project will be to build a data ware house on Google Cloud Platform that will help answer common business questions as well as powering dashboards

The scope of this project will be to build a data ware house on Google Cloud Platform that will help answer common business questions as well as powering dashboards.

Shweta_kumawat 2 Jan 20, 2022
Discord heximals: More colors for your bot

DISCORD-HEXIMALS More colors for your bot ! Support : okimii#0434 COLORS ( 742 )

4 Feb 04, 2022
WhatsApp Status Tracker With Python

Warning!! This Repo is Purly educational purpose Don't use this to stalk on others, which is subjective to crime Pre-Req: Telegram bot of your own wit

Vignesh Karunagaran 10 Dec 09, 2022
A Python library for loading data from a SpaceX Starlink satellite.

Starlink Python A Python library for loading data from a SpaceX Starlink satellite. The goal is to be a simple interface for Starlink. It builds upon

Austin 2 Jan 16, 2022
Simple, yet effective moderator bot for telegram. With reports, logs, profanity filter and more :3

👹 Samurai Telegram Bot Simple, yet effective moderator bot for telegram. With reports, logs, profanity filter and more :3 Description Personal bot, m

Abraham Tugalov 106 Dec 13, 2022
This code is for a bot which will find a Twitter user's most tweeted word and tweet that word, tagging said user

max_tweeted_word This code is for a bot which will find a Twitter user's most tweeted word and tweet that word, tagging said user The program uses twe

Yasho Bapat 1 Nov 29, 2021
An attempt to make a bot that can auto-archive Danganronpa KG RPs on Discord.

Danganronpa Killing Game Archiving Bot An attempt to make a bot that can auto-archive Danganronpa KG RPs on Discord. The final format is meant to look

Astrea 1 Nov 30, 2021
Raphtory-client - The python client for the Raphtory project

Raphtory Client This is the python client for the Raphtory project Install via p

Raphtory 5 Apr 28, 2022
✨ 🐍 Python SDK for StarkNet.

✨ 🐍 starknet.py StarkNet SDK for Python 📘 Documentation Installation Quickstart Guide API Installation To install this package run pip install stark

Software Mansion 158 Jan 04, 2023
Sielzz Music adalah proyek bot musik telegram, memungkinkan Anda memutar musik di telegram grup obrolan suara.

Hi, I am: Requirements 📝 FFmpeg NodeJS nodesource.com Python 3.8 or higher PyTgCalls MongoDB Get STRING_SESSION from below: 🎖 History Features 🔮 Th

1 Nov 04, 2021
Crosschat - A bot for cross-server communication

CrossChat A bot for cross-server communication. Running the bot To run the bot y

8 May 15, 2022