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.

Tools used by Ada Health's internal IT team to deploy and manage a serverless Munki setup.

Serverless Munki This repository contains cross platform code to deploy a production ready Munki service, complete with AutoPkg, that runs entirely fr

Ada Health 17 Dec 05, 2022
alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API.

alpaca-trade-api-python is a python library for the Alpaca Commission Free Trading API. It allows rapid trading algo development easily, with support for both REST and streaming data interfaces

Alpaca 1.5k Jan 09, 2023
An Python SDK for QQ based on mirai-api-http v2.

Argon 一个基于 graia-broadcast 和 mirai-api-http v2 的 Python SDK。 本项目适用于 mirai-api-http 2.0 以上版本。 目前仍处于开发阶段,内部接口可能会有较大的变化。 The Stasis / 停滞 为维持 GraiaProject

BlueGlassBlock 1 Oct 29, 2021
Python3 library that can retrieve Chrome-based browser's saved login info.

Passax EDUCATIONAL PURPOSES ONLY Python3 library that can retrieve Chrome-based browser's saved login info. Requirements secretstorage~=3.3.1 pywin32=

Auax 1 Jan 25, 2022
Invites link generator for telegram(made for channel referral links)

InviteLinkGen Invites link generator for telegram(for channel referral links) made for @HelakuruEsana channel Spotify Giveaway

Jaindu Charindith 7 Feb 01, 2022
This is Pdisk Upload Bot made using Python with Pyrogram Framework. Its capable of uploading direct download link with thumbnail or without thumbnail & with Title Support.

Pdisk-Upload-Bot Introduction This Is PDisk Upload Bot Used To Upload Direct Link To Pdisk With Thumb Support Deploy Heroku Deploy Local Deploy pip in

HEIMAN PICTURES 32 Oct 21, 2022
Mazda Connected Service API wrapper based on pymazda and Flask.

Mazda Connected Service Relay Mazda Connected Service API wrapper based on pymazda and Flask. Usage Make POST calls to https://mymazda.herokuapp.com/{

Alan Chen 10 Jan 05, 2023
🐍 VerificaC19 SDK implementation for Python

VerificaC19 Python SDK 🐍 VerificaC19 SDK implementation for Python. Requirements Python version = 3.7 Make sure zbar is installed in your system For

Lotrèk 10 Jan 14, 2022
DadBot 2.0 is an interactive bot that reflects the personality of a typical dad

DadBot 2.0 is an interactive bot that reflects the personality of a typical dad! You can start by running main while all directories are maintained as they are on this GitHub.

1 Dec 04, 2021
Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially maintained by the Tuya Developer Team.

Tuya Home Assistant Integration Home Assistant custom integration for controlling Powered by Tuya (PBT) devices using Tuya Open API, officially mainta

Tuya 704 Jan 03, 2023
Unofficial Coinbase Python Library

Unofficial Coinbase Python Library Python Library for the Coinbase API for use with three legged oAuth2 and classic API key usage Version 0.3.0 Requir

George Sibble 104 Dec 01, 2022
Using multiple API sources, create an app that allows users to filter through random locations based on their temperature range choices.

World_weather_analysis Overview Using multiple API sources, create an app that allows users to filter through random locations based on their temperat

Jason Boyer 2 Sep 16, 2022
Python functions for opentargets.org API

What is opy_Targets? Opentargets.org uses GraphQL API to explore it's content via coding. This ensemble of functions aim is to make it easy to use the

1 Jan 10, 2022
ServiceX DID Finder Girder

ServiceX_DID_Finder_Girder Access datasets for ServiceX from yt Hub Finding datasets This DID finder is designed to take a collection id (https://gird

1 Dec 07, 2021
A stock information collector and parser for Taiwan and US market. Automatically send LINE message if the pre-defined rules are triggered.

agastock 開發動機 就在海運飆漲的2021年7月,差點跪在地上喜迎財富自由的當下,EPS超高好消息不斷的長榮竟然套在202元一去不回,有圖有真相(哭) 忽然體會到追高殺低不是辦法,魯蛇我得靠邏輯分析也能出頭天,經過三個月無數個不出門的周末,產出簡單的爬蟲和分析工具。 上過金融研訓院的量化交易

Gavin Lee 12 Nov 16, 2022
How to make a QR Code of your own in python

QR CODE Bilgilendirme! " pip install qrcode pillow " kurmalısınız.

Aktali 1 Dec 24, 2021
The AWS Lambda Serverless Blind XSS App

Ass The AWS Lambda Serverless Blind XSS App 利用VPS配置XSS平台太麻烦了,如果利用AWS的Lambda那不就是一个域名的事情么?剩下的环境配置、HTTPS证书、隐私性、VPS续费都不用管了, 所以根据xless重写了Lambda平台的XSS,利用sla

cocokey 2 Dec 27, 2021
YouTube-Discord-Bot - Discord Bot to Search YouTube

YouTube Bot Info YouTube Bot is a discord bot where you can search for anything

Riceblades11 10 Mar 05, 2022
A Telegram bot for personal utilities

Aqua Aqua is a Telegram bot for personal utilities. Installation Prerequisites: Install Poetry for managing dependencies and fork/clone the repository

Guilherme Vasconcelos 2 Mar 30, 2022
A tool to build scripts to toggle between minimal & default services in Windows based on user defined lists.

A tool to build scripts to toggle between minimal & default services in Windows based on user defined lists.

AMIT 29 Jan 01, 2023