tgEasy | Easy for a Brighter Shine | Monkey Patcher Addon for Pyrogram

Overview

tgEasy

tgEasy

from tgEasy import tgClient, command
from pyrogram import Client

app = tgClient(Client("my_account"))

@command("start", group_only=True)
async def start(client, message):
    await message.reply_text(f"Hello {message.from_user.mention}")

app.run()

Featurs

  • Easy: You can install tgEasy with pip and start building your applications right away.

  • Fast: With the Pyrogram, tgEasy's speed is enhanced

  • Type-hinted: Types and methods are all type-hinted, enabling excellent editor support.

  • Asynchronous: With the Asynchronous, tgEasy can handle Multiple Requests at a time.

  • Documented: All of the available methods, types and functions are well documented.

  • Comprehensive: With the help of Pyrogram, Execute any advanced action an official client is able to do, and even more.

Configuration

Make an .env or set the Following in your Environment Variables.

  • LOGS - Log Group ID
  • PLUGINS - Plugins Directory Path where your Plugins are located, By Default it is plugins Directory
  • HANDLERS - The Command Handlers, By Default it is / and !

Documatation

  • Never name tgEasy for your any files/directory

tgEasy.tgClient

  • A Class for Initialising the tgEasy and it's Methods, Types and Functions
  • Parameters:
    • client (pyrogram.Client):
      • The Pyrogram Client

Example

from tgEasy import tgClient
from pyrogram import Client

app = tgClient(Client("my_account"))

tgEasy.command

  • A decorater to Register Commands in simple way and manage errors in that Function itself, alternative for @pyrogram.Client.on_message(pyrogram.filters.command('command'))
  • Parameters:
    • command (str || list):

      • The command to be handled for a function
    • group_only (bool) optional:

      • If True, the command will only executed in Groups only, By Default False.
    • pm_only (bool) optional:

      • If True, the command will only executed in Private Messages only, By Default False.
    • self_admin (bool) optional:

      • If True, the command will only executeed if the Bot is Admin in the Chat, By Default False
    • self_only (bool) optional:

      • If True, the command will only executeed if the Bot is Admin in the Chat, By Default False
    • filter (~pyrogram.filters) optional:

      • Pyrogram Filters, hope you know about this, for Advaced usage. By Default ~pyrogram.filters.edited and this can't be changed. Use and for seaperating filters.

Example

import pyrogram
from tgEasy import command

@command("start", group_only=False, pm_only=False, self_admin=False, self_only=False, pyrogram.filters.chat("777000") and pyrogram.filters.text)
async def start(client, message):
    await message.reply_text(f"Hello {message.from_user.mention}")

tgEasy.callback

  • A decorater to Register Callback Quiries in simple way and manage errors in that Function itself, alternative for @pyrogram.Client.on_callback_query(pyrogram.filters.regex('^data.*'))
  • Parameters:
    • data (str || list):

      • The callback query to be handled for a function
    • self_admin (bool) optional:

      • If True, the command will only executeed if the Bot is Admin in the Chat, By Default False
    • filter (~pyrogram.filters) optional:

      • Pyrogram Filters, hope you know about this, for Advaced usage. Use and for seaperating filters.

Example

import pyrogram
from tgEasy import command, callback

@command("start")
async def start(client, message):
    await message.reply_text(
      f"Hello {message.from_user.mention}",
      reply_markup=pyrogram.types.InlineKeyboardMarkup([[
        pyrogram.types.InlineKeyboardButton(
          "Click Here",
          "data"
        )
      ]])
    )

@callback("data")
async def data(client, CallbackQuery):
  await CallbackQuery.answer("Hello :)", show_alert=True)

tgEasy.adminsOnly

  • A decorater for running the function only if the admin have the specified Rights.
  • We are still Working on this to make it to check Rights for Anonoymous Admins, Stay Tuned.
  • Parameters:
    • permission (str):
      • Permission which the User must have to use the Functions
    • TRUST_ANON_ADMIN (bool) optional:
      • If User is Anonymous Admin also, It Runs the Function, By Default False

Example

from tgEasy import command, adminsOnly

@command("start")
@adminsOnly("can_change_info")
async def start(client, message):
    await message.reply_text(f"Hello Admin {message.from_user.mention}")

tgEasy.tgClient.run()

  • Runs the pyrogram.Client by adding tgEasy.tgClient.run() in your main file and run [Not Recommended to use this], instead of running python3 -m tgEasy.

  • This calls pyrogram.Client.start(), pyrogram.idle() and pyrogram.Client.stop()

Example

from tgEasy import run

run()

tgEasy.get_user

  • Gets a User from Message/RepliedMessageFromUser
  • Parameters:
    • m (~pyrogram.types.Message || ~pyrogram.types.CallbackQuery)
  • Returns:
    • pyrogram.types.User on Success
    • False on Error

Example

from tgEasy import get_user, command, adminsOnly

@command("ban", group_only=True, self_admin=True)
@adminsOnly("can_restrict_members")
async def ban(client, message):
  user = await get_user(message)
  await message.chat.kick_member(user.id)

tgEasy.get_user_adv

  • A Function to Get the User from the Message/CallbackQuery, If there is None arguments, returns the From User.
  • Parameters:
    • m (pyrogram.types.Message || pyrogram.types.CallbackQuery):
      • Message or Callbackquery.
  • Returns:
    • pyrogram.types.User on Success
    • False on Error

Example

from tgEasy import command, get_user_adv

@command("id")
async def id(client, message):
  user = await get_user_adv(message)
  await message.reply_text(f"Your ID is `{user.id}`")

tgEasy.check_rights

  • Checks the Rights of an User

  • This is an Helper Function for adminsOnly

  • Parameters:

    • chat_id (int):

      • The Chat ID of Which Chat have to check the Rights.
    • user_id (int):

      • The User ID of Whose Rights have to Check.
    • rights (str):

      • The Rights have to Check.
  • Returns:

    • True if the User have the Right.
    • False if the User don't have the Right.

Example

from tgEasy import command, check_rights, get_user

@command("ban", group_only=True, self_admin=True)
async def ban(client, message):
  if not await check_rights(message.chat.id, message.from_user.id, "can_restrict_members"):
    return await message.reply_text("You don't have necessary rights to use this Command.")
  user = await get_user(message)
  await message.chat.kick_member(user.id)

tgEasy.is_admin

  • A Functions to Check if the User is Admin or not

  • Parameters:

    • chat_id (int):

      • The Chat ID of Which Chat have to check the Admin Status.
    • user_id (int):

      • The User ID of Whose Admin Status have to Check.
  • Returns:

    • True if the User is Admin.
    • False if the User is't Admin.

Example

from tgEasy import command, is_admin, adminsOnly

@command("ban", group_only=True, self_admin=True)
@adminsOnly("can_restrict_members")
async def ban(client, message):
    if await is_admin(message.chat.id, (await get_user(mesasge)).id):
        return await message.reply_text("You can't Ban Admins.")
    await message.chat.kick_member((await get_user(message)).id)
    await message.reply_text("User has been Banned.")

tgEasy.handle_error

  • A Function to Handle the Errors in Functions.

  • This Sends the Error Log to the Log Group and Replies Sorry Message for the Users.

  • This is Helper for all of the functions for handling the Errors.

  • Parameters:

    • error:

      • The Exceptation.
    • m (pyrogram.types.Message or pyrogram.types.CallbackQuery):

      • The Message or Callback Query where the Error occurred.

Exapmle

from tgEasy import command, handle_error

@command("start")
async def start(client, message):
  try:
    await message.reply_text("Hi :D') # I intentionally made an bug for Example :/
  except Exceptation as e:
    return await handle_error(e, message)

tgEasy.send_typing

  • A Function to Send the Typing Status to the Chat.

  • Parameters:

    • m (pyrogram.types.Message || pyrogram.types.CallbackQuery):
      • Message or Callbackquery.

Example

from tgEasy import command, send_typing

@command("start")
async def start(client, message):
  await send_typing(message)
  await message.reply_text("Hello")

Smart Plugins

  • The Smart Plugins Concept is't Implemented yes, It will be avaiable soon.

Pro Tip: tgEasy imports all of the pyromod Functions, Methods and Types, use `from tgEasy import [pyromod function name]`, A Pyromod Function and make it More convenient to develop

Copyright and Licence

  • tgEasy is Licenced under the Terms and Conditions of OSI Approved GNU Lesser General Public License v3 or later (LGPLv3+).
  • Copyright 2021 Jayant Hegde Kageri https://github.com/jayantkageri.
  • This Projects Codes may contain snippets or codes of Pyrogram.
  • Pyrogram - Telegram MTProto API Client Library for Python. Copyright (C) 2017-2020 Dan https://github.com/delivrance
  • This Project uses Pyromod for making it more convenient.
  • Pyromod - A monkeypatcher add-on for Pyrogram
  • Copyright (C) 2020 - 2021 Cezar https://github.com/usernein
You might also like...
Blender addon - Breakdown in object mode

Breakdowner Breakdown in object mode Download latest Demo Youtube Description Same breakdown shortcut as in armature mode in object mode Currently onl

A Blender addon to align the origin to the top, center or bottom of a mesh object
A Blender addon to align the origin to the top, center or bottom of a mesh object

Align Origin Blender Addon. Align Origin Blender Addon. What? This simple addon lets you align the origin to the top, center or bottom of a mesh objec

Blender addon that simplifies access to useful operators and adds missing functionality
Blender addon that simplifies access to useful operators and adds missing functionality

Quick Menu is a Blender addon that simplifies common tasks Compatible with Blender 3.x.x Install through Edit - Preferences - Addons - Install... -

Blender Addon for Snapping a UV to a specific part of a Tilemap

UVGridSnapper A simple Blender Addon for easier texturing. A menu in the UV editor allows a square UV to be snapped to an Atlas texture, or Tilemap. P

An AddOn storing wireguard configuration

Wireguard Database Connector Overview Development Status: 0.1.7 (alpha) First of all, I'd like to thank Jared McKnight for wireguard who inspired me t

Blender addon for executing the operator in response to the received OSC message.
Blender addon for executing the operator in response to the received OSC message.

I/F Joiner 受信したOSCメッセージに応じてオペレータ(bpy.ops)を実行するアドオンです. OSC通信に対応したコントローラやアプリをインストールしたスマートフォンを使用してBlenderを操作することが可能になります. 同時開発しているAndroidコントローラ化アプリMocopa

Easytile blender - Simple Blender 2.83 addon for tiling meshes easily

easytile_blender Dead simple, barebones Blender (2.83) addon for placing meshes as tiles. Installation In Blender, go to Edit Preferences Add-ons

A Blender addon for VSE that auto-adjusts video strip's length, if speed effect is applied.

Blender VSE Speed Adjust Addon When using Video Sequence Editor in Blender, the speed effect strip doesn't auto-adjusts clip length when changing its

Blender addon, import and update mixamo animation

This is a blender addon for import and update mixamo animations.

Releases(v1.3.3)
  • v1.3.3(Apr 25, 2022)

  • v1.3.1(Jan 18, 2022)

    What's New

    • If you wanted a custom handler for one function only, then it's now introduced, use it via a handler field in @tgClient.command which accepts list or str.
    • Bug Fixes and Improvements.

    Full Changelog: https://github.com/jayantkageri/tgEasy/compare/v1.3.0...v1.3.1

    Source code(tar.gz)
    Source code(zip)
  • v1.3.0(Jan 5, 2022)

    What's New

    • So finally, We are the first one to make Pyrogram Anonymous Admin Verification Opensource, From now tgEasy will be verifying Anonymous Admins also. A Special Thanks to @annihilatorrrr for helping with this.
    • Bug Fixes

    Full Changelog: https://github.com/jayantkageri/tgEasy/compare/v1.2.7...v1.3.0

    Source code(tar.gz)
    Source code(zip)
  • v1.2.7(Nov 19, 2021)

    What's Changed

    • Fixed the self_admin parameter.
    • Fixed the adminsOnly decorator not supporting permissions in the list and same fixed in check_rights
    • Fixed the Error Occurring with static method decorator, self is Not Defined by @dhruvx09 in https://github.com/jayantkageri/tgEasy/pull/12
    • Optimized code and file system

    Full Changelog: https://github.com/jayantkageri/tgEasy/compare/v1.2.6...v1.2.7

    Source code(tar.gz)
    Source code(zip)
  • v1.2.6(Oct 29, 2021)

    What's Changed

    • Fixed the Error Occurring with Static Method Decorator, self is not Defined by @dhruvx09 in https://github.com/jayantkageri/tgEasy/pull/12

    What's New

    • Moved Documentations to GitHub Wiki

    Full Changelog: https://github.com/jayantkageri/tgEasy/compare/v1.2.5...v1.2.6

    Source code(tar.gz)
    Source code(zip)
  • v1.2.5(Oct 26, 2021)

    tgEasy's Bug Fix Update v1.2.5

    What's Changed

    • Update decorater.py by @dhruvx09 in https://github.com/jayantkageri/tgEasy/pull/6
    • Decorating method with @staticmethod by @Awesome-RJ in https://github.com/jayantkageri/tgEasy/pull/3
    • Mis reimport of 'logging' by @Awesome-RJ in https://github.com/jayantkageri/tgEasy/pull/4
    • Update decorater.py by @dhruvx09 in https://github.com/jayantkageri/tgEasy/pull/7
    • Merge if Statements @Awesome-RJ in https://github.com/jayantkageri/tgEasy/pull/9
    • Using in by @Awesome-RJ in https://github.com/jayantkageri/tgEasy/pull/8

    New Contributors

    • @dhruvx09 made their first contribution in https://github.com/jayantkageri/tgEasy/pull/6
    • @Awesome-RJ made their first contribution in https://github.com/jayantkageri/tgEasy/pull/3

    Full Changelog: https://github.com/jayantkageri/tgEasy/compare/v1.2.4...v1.2.5

    Source code(tar.gz)
    Source code(zip)
  • v1.2.4(Oct 1, 2021)

    tgEasy v1.2.4

    What's New

    • Bug Fixes.

    Things to do

    • Anonymous Admin Rights Check, cannot assure that it will come in Next Update only.
    • Make more Stable
    Source code(tar.gz)
    Source code(zip)
  • v1.2.3(Sep 29, 2021)

    tgEasy v1.2.3

    What's New

    • Added Support for Multiple Clients.
    • Added Scaffold (For Developers Convenience)
    • Bug Fixes.

    Things to Change in Code

    • Change available methods to @tgClient.{available_methods}

    Things to do

    • Anonymous Admin Rights Check, cannot assure that it will come in Next Update only.
    • Make more Stable
    Source code(tar.gz)
    Source code(zip)
  • v1.1.3(Aug 24, 2021)

    tgEasy v1.1.3

    What's New

    • Added self_only.
    • Added Support for Userbots.
    • Added Support for Custom Plugins.
    • Added Support for Custom Command Handlers.
    • Bug Fixes.

    Things to Change in Code

    • Make your Own Client and Pass it in tgClient.

    Things to do

    • Anonymous Admin Rights Check, cannot assure that it will come in Next Update only.
    Source code(tar.gz)
    Source code(zip)
Owner
Jayant Hegde Kageri
Nothing is Easy in the Life when you are't Interested in it
Jayant Hegde Kageri
It converts ING BANK account historic into a csv file you can import in HomeBank application.

ing2homebank It converts your ING Bank account historic csv file into another csv file you can import in HomeBank application

1 Feb 14, 2022
Whole-day timezone comparison

Timezone Converter Compare a full day of your local timezone with foreign ones $ timezone-converter tijuana --zone $ timezone-converter tijuana new_yo

Iago Alonso 12 Nov 24, 2022
A student information management system in Python

Student-information-management-system 本项目是一个学生信息管理系统,这个项目是用Python语言实现的,也实现了图形化界面的显示,同时也实现了管理员端,学生端两个登陆入口,同时底层使用的是Redis做的数据持久化。 This project is a stude

liuyunfei 7 Nov 15, 2022
A python module for DeSo

DeSo.py A python package for DeSo. Developed by ItsAditya Run pip install deso to install the module! Examples of How To Use DeSo.py Getting $DeSo pri

ItsAditya 0 Jun 30, 2022
Webcash is an experimental e-cash (electronic cash)

Webcash Webcash is an experimental new electronic cash ("e-cash") that enables decentralized and instant payments to anyone, anywhere in the world. Us

Mark Friedenbach 0 Feb 26, 2022
BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset.

BloodCheck BloodCheck enables Red and Blue Teams to manage multiple Neo4j databases and run Cypher queries against a BloodHound dataset. Installation

Mr B0b 16 Nov 05, 2021
Battle-Ship - Python-console battle ship

Battle-Ship this SHOULD work in lenux(if i spelled it wrong spam issues till I fix it) the thing that maby wont work is where it clears the screen the

pl608 2 Jan 06, 2022
This wishes a mentioned users on their birthdays

BirthdayWisher Requirements: "mysqlserver", "email id and password", "Mysqlconnector" In-Built Modules: "smtplib", "datetime","imghdr" In Mysql: A tab

vellalaharshith 1 Sep 13, 2022
Spinning waffle from waffle shaped python code

waffle Spinning waffle from waffle shaped python code Based on a parametric curve: r(t) = 2 - 2*sin(t) + (sin(t)*abs(cos(t)))/(sin(t) + 1.4) projected

Viljar Femoen 5 Feb 14, 2022
A simple desktop application to scan and export Genshin Impact Artifacts.

「天目」 -- Amenoma 简体中文 | English 「天目流的诀窍就是滴水穿石的耐心和全力以赴的意志」 扫描背包中的圣遗物,并导出至 json 格式。之后可导入圣遗物分析工具( 莫娜占卜铺 、 MingyuLab 、 Genshin Optimizer 进行计算与规划等。 已支持 原神2.

夏至 475 Dec 30, 2022
log4shell pwner for vulnerable minecraft servers

Log4-hell name supposed to be Log4$hell but oh well log4shell pwner for vulnerable minecraft servers install all reqs python + a minecraft client for

1 Jan 05, 2022
python DroneCAN code generation, interface and utilities

UAVCAN v0 stack in Python Python implementation of the UAVCAN v0 protocol stack. UAVCAN is a lightweight protocol designed for reliable communication

DroneCAN 11 Dec 12, 2022
Force you (or your user) annotate Python function type hints.

Must-typing Force you (or your user) annotate function type hints. Notice: It's more like a joke, use it carefully. If you call must_typing in your mo

Konge 13 Feb 19, 2022
🤖🤖 Jarvis is an virtual assistant which can some tasks easy for you like surfing on web opening an app and much more... 🤖🤖

Jarvis 🤖 🤖 Jarvis is an virtual assistant which can some tasks easy for you like surfing on web opening an app and much more... 🤖 🤖 Developer : su

1 Nov 08, 2021
Ml-design-patterns - Source code accompanying O'Reilly book: Machine Learning Design Patterns

This is not an official Google product ml-design-patterns Source code accompanying O'Reilly book: Title: Machine Learning Design Patterns Authors: Val

Google Cloud Platform 1.5k Jan 05, 2023
Structured, dependable legos for starknet development.

Structured, dependable legos for starknet development.

Alucard 127 Nov 23, 2022
qecsim is a Python 3 package for simulating quantum error correction using stabilizer codes.

qecsim qecsim is a Python 3 package for simulating quantum error correction using stabilizer codes.

44 Dec 20, 2022
Glyph Metadata Palette

This plugin for Glyphs3 allows you to associate arbitrary structured metadata to each glyph in your font.

Simon Cozens 4 Jan 26, 2022
Streamlit apps done following data professor's course on YouTube

streamlit-twelve-apps Streamlit apps done following data professor's course on YouTube Español Curso de apps de data science hecho por Data Professor

Federico Bravin 1 Jan 10, 2022
Un script en python qui permet d'automatique bumpée (disboard.org) tout les 2h

auto-bumper Un script en python qui permet d'automatique bumpée (disboard.org) tout les 2h Pour la première utilisation, 1.Lancer Install.bat 2.(faire

!! 1 Jan 09, 2022