Telegant


NameTelegant JSON
Version 0.2.5 PyPI version JSON
download
home_pagehttps://github.com/kotov584/Telegant
SummaryAn Elegant Modern Bot Framework for Python
upload_time2023-05-30 05:31:10
maintainer
docs_urlNone
authorKotov584
requires_python>=3.6
licenseMIT
keywords python telegram bot api async asynchronous elegant modern
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            <h1 align="center">
    <code>Telegant</code>
</h1>
<p align="center">
    <a href="https://github.com/psf/black">
        <img alt="Code style: black" src="https://img.shields.io/badge/code%20style-black-000000.svg">
    </a>
    <a href="https://t.me/telegant_group">
        <img src="https://img.shields.io/badge/Telegram-Group-blue.svg?logo=telegram">
    </a>
    <a href="https://t.me/telegant_official">
        <img src="https://img.shields.io/badge/Telegram-Channel-blue.svg?logo=telegram">
    </a> 
    <a href="https://pypistats.org/packages/telegant">
        <img src="https://img.shields.io/pypi/dm/telegant.svg">
    </a>
</p>

# Telegant 
Telegant is an elegant modern bot framework for Python, designed to provide developers with simple and elegant access to the Telegram bot API.
This project is now in Beta phase. 
All Telegram bot api methods are now supported automatically.

# Features and highlights
* Automated coverage of all Telegram bot api methods
* Support of snake_case, camelCase and PascalCase for methods
* Asynchronous bot
* Lightweight
* Fast
* Simple
* Bot Helpers 
* Regex Expressions for text messages 

# Installation 
To install the project, simply run:

```python 
pip install telegant
```

# Contribution 

For contribution to this project you have to open discussion under Contribution section.
It will be decided if your request is going to be accepted or not. 

# Example 

```python
from telegant import Bot

bot = Bot("YOUR_BOT_TOKEN_HERE")

@bot.hear("hello")
async def say_hello(bot, update): 
    await bot.send_message(text="What's up?")

#Your code here (Recommended to write your functions in order)

bot.start_polling()
```

# Usage 

## On text 

If you need your bot to respond to specified text just use @bot.hear()

```python 
@bot.hear("hello")
async def say_hello(bot, update): 
    await bot.send_message(text="What's up?")
```

Or many texts 

```python 
@bot.hears(["hello"])
async def say_hello(bot, update): 
    await bot.send_message(text="What's up?")
```
## Case styles

Ability to use different case styles

### snake_case

```python 
@bot.hear("hello")
async def say_hello(bot, update): 
    await bot.send_message(text="What's up?")
```

### camelCase 

```python 
@bot.hear("hello")
async def say_hello(bot, update): 
    await bot.sendMessage(text="What's up?")
```

### PascalCase 

```python 
@bot.hear("hello")
async def say_hello(bot, update): 
    await bot.SendMessage(text="What's up?")
```

## Sending bot with buttons

### Inline buttons example
```python 
@bot.hear("hello")
async def say_hello(bot, update): 
    buttons = [
        [
            {"text": "Option 1 (inline)", "callback_data": "option1"},  
        ]
    ]

    #snake_case example
    await bot.send_message(text="What's up?", reply_markup=buttons)
```

### Reply buttons example

```python 
@bot.hear("hello")
async def say_hello(bot, update): 
    buttons = [
        [
            {"text": "Option 1 (reply)"},  
        ]
    ]

    await bot.send_message(text="What's up?", reply_markup=buttons)
```

Bot always detects your buttons type automatically by callback_data key. 
If you want to use inline buttons you have to write text and data values for each button.
As it is detects your inline button when you have "data" key in your button.
Otherwise, it will detect as reply keyboard.

## Commands

You can assign to one function one command or many commands as needed.
For single command use @bot.command() decorator.

```python 
@bot.command("start")
async def say_hello(bot, update):  
    await bot.send_message(text="Sup I'm start")
```
For several commands use @bot.commands() decorator.

```python 
@bot.commands(['help', 'ask'])
async def say_hello(bot, update):  
    await bot.send_message(text="You've reached for help")
```

Export data after command by your keys

```python 
@bot.commands(['usernameandage'])
@bot.with_args(['username', 'age'])
async def handler(bot, update, data): 
    await bot.send_message(text=f"Hello {data['username']}, you are {data['age']} years old.")
```

## Callbacks
Telegant also offers to you simply detect your callbacks where you able to assign many or one callback to your function

### Many callbacks example 

```python 
@bot.callbacks(['option1', 'option2'])
async def say_hello(bot, update):  
    await bot.send_message(text="Callbacks are perfect!")
```

### Single callback example

```python 
@bot.callback('option1')
async def say_hello(bot, update):  
    await bot.send_message(text="Callback is perfect")
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/kotov584/Telegant",
    "name": "Telegant",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "python,telegram,bot,api,async,asynchronous,elegant,modern",
    "author": "Kotov584",
    "author_email": "",
    "download_url": "https://files.pythonhosted.org/packages/8e/d5/734b4928900ee6b91a4e136e8308dea696bdae10527240d42b03e682347f/Telegant-0.2.5.tar.gz",
    "platform": null,
    "description": "<h1 align=\"center\">\r\n    <code>Telegant</code>\r\n</h1>\r\n<p align=\"center\">\r\n    <a href=\"https://github.com/psf/black\">\r\n        <img alt=\"Code style: black\" src=\"https://img.shields.io/badge/code%20style-black-000000.svg\">\r\n    </a>\r\n    <a href=\"https://t.me/telegant_group\">\r\n        <img src=\"https://img.shields.io/badge/Telegram-Group-blue.svg?logo=telegram\">\r\n    </a>\r\n    <a href=\"https://t.me/telegant_official\">\r\n        <img src=\"https://img.shields.io/badge/Telegram-Channel-blue.svg?logo=telegram\">\r\n    </a> \r\n    <a href=\"https://pypistats.org/packages/telegant\">\r\n        <img src=\"https://img.shields.io/pypi/dm/telegant.svg\">\r\n    </a>\r\n</p>\r\n\r\n# Telegant \r\nTelegant is an elegant modern bot framework for Python, designed to provide developers with simple and elegant access to the Telegram bot API.\r\nThis project is now in Beta phase. \r\nAll Telegram bot api methods are now supported automatically.\r\n\r\n# Features and highlights\r\n* Automated coverage of all Telegram bot api methods\r\n* Support of snake_case, camelCase and PascalCase for methods\r\n* Asynchronous bot\r\n* Lightweight\r\n* Fast\r\n* Simple\r\n* Bot Helpers \r\n* Regex Expressions for text messages \r\n\r\n# Installation \r\nTo install the project, simply run:\r\n\r\n```python \r\npip install telegant\r\n```\r\n\r\n# Contribution \r\n\r\nFor contribution to this project you have to open discussion under Contribution section.\r\nIt will be decided if your request is going to be accepted or not. \r\n\r\n# Example \r\n\r\n```python\r\nfrom telegant import Bot\r\n\r\nbot = Bot(\"YOUR_BOT_TOKEN_HERE\")\r\n\r\n@bot.hear(\"hello\")\r\nasync def say_hello(bot, update): \r\n    await bot.send_message(text=\"What's up?\")\r\n\r\n#Your code here (Recommended to write your functions in order)\r\n\r\nbot.start_polling()\r\n```\r\n\r\n# Usage \r\n\r\n## On text \r\n\r\nIf you need your bot to respond to specified text just use @bot.hear()\r\n\r\n```python \r\n@bot.hear(\"hello\")\r\nasync def say_hello(bot, update): \r\n    await bot.send_message(text=\"What's up?\")\r\n```\r\n\r\nOr many texts \r\n\r\n```python \r\n@bot.hears([\"hello\"])\r\nasync def say_hello(bot, update): \r\n    await bot.send_message(text=\"What's up?\")\r\n```\r\n## Case styles\r\n\r\nAbility to use different case styles\r\n\r\n### snake_case\r\n\r\n```python \r\n@bot.hear(\"hello\")\r\nasync def say_hello(bot, update): \r\n    await bot.send_message(text=\"What's up?\")\r\n```\r\n\r\n### camelCase \r\n\r\n```python \r\n@bot.hear(\"hello\")\r\nasync def say_hello(bot, update): \r\n    await bot.sendMessage(text=\"What's up?\")\r\n```\r\n\r\n### PascalCase \r\n\r\n```python \r\n@bot.hear(\"hello\")\r\nasync def say_hello(bot, update): \r\n    await bot.SendMessage(text=\"What's up?\")\r\n```\r\n\r\n## Sending bot with buttons\r\n\r\n### Inline buttons example\r\n```python \r\n@bot.hear(\"hello\")\r\nasync def say_hello(bot, update): \r\n    buttons = [\r\n        [\r\n            {\"text\": \"Option 1 (inline)\", \"callback_data\": \"option1\"},  \r\n        ]\r\n    ]\r\n\r\n    #snake_case example\r\n    await bot.send_message(text=\"What's up?\", reply_markup=buttons)\r\n```\r\n\r\n### Reply buttons example\r\n\r\n```python \r\n@bot.hear(\"hello\")\r\nasync def say_hello(bot, update): \r\n    buttons = [\r\n        [\r\n            {\"text\": \"Option 1 (reply)\"},  \r\n        ]\r\n    ]\r\n\r\n    await bot.send_message(text=\"What's up?\", reply_markup=buttons)\r\n```\r\n\r\nBot always detects your buttons type automatically by callback_data key. \r\nIf you want to use inline buttons you have to write text and data values for each button.\r\nAs it is detects your inline button when you have \"data\" key in your button.\r\nOtherwise, it will detect as reply keyboard.\r\n\r\n## Commands\r\n\r\nYou can assign to one function one command or many commands as needed.\r\nFor single command use @bot.command() decorator.\r\n\r\n```python \r\n@bot.command(\"start\")\r\nasync def say_hello(bot, update):  \r\n    await bot.send_message(text=\"Sup I'm start\")\r\n```\r\nFor several commands use @bot.commands() decorator.\r\n\r\n```python \r\n@bot.commands(['help', 'ask'])\r\nasync def say_hello(bot, update):  \r\n    await bot.send_message(text=\"You've reached for help\")\r\n```\r\n\r\nExport data after command by your keys\r\n\r\n```python \r\n@bot.commands(['usernameandage'])\r\n@bot.with_args(['username', 'age'])\r\nasync def handler(bot, update, data): \r\n    await bot.send_message(text=f\"Hello {data['username']}, you are {data['age']} years old.\")\r\n```\r\n\r\n## Callbacks\r\nTelegant also offers to you simply detect your callbacks where you able to assign many or one callback to your function\r\n\r\n### Many callbacks example \r\n\r\n```python \r\n@bot.callbacks(['option1', 'option2'])\r\nasync def say_hello(bot, update):  \r\n    await bot.send_message(text=\"Callbacks are perfect!\")\r\n```\r\n\r\n### Single callback example\r\n\r\n```python \r\n@bot.callback('option1')\r\nasync def say_hello(bot, update):  \r\n    await bot.send_message(text=\"Callback is perfect\")\r\n```\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "An Elegant Modern Bot Framework for Python",
    "version": "0.2.5",
    "project_urls": {
        "Homepage": "https://github.com/kotov584/Telegant"
    },
    "split_keywords": [
        "python",
        "telegram",
        "bot",
        "api",
        "async",
        "asynchronous",
        "elegant",
        "modern"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9681e385f91be331b9b44e4decad95ebae2bf6cd768ec2ab5ed70c8be116bec7",
                "md5": "c9d339fae5b0c1bb7b7c103d87707bdb",
                "sha256": "2fe8fde4f05ab712bc8f8bda518ddd1c9d8c285da5b2ab087361b7a36283a099"
            },
            "downloads": -1,
            "filename": "Telegant-0.2.5-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c9d339fae5b0c1bb7b7c103d87707bdb",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 8491,
            "upload_time": "2023-05-30T05:31:07",
            "upload_time_iso_8601": "2023-05-30T05:31:07.928157Z",
            "url": "https://files.pythonhosted.org/packages/96/81/e385f91be331b9b44e4decad95ebae2bf6cd768ec2ab5ed70c8be116bec7/Telegant-0.2.5-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8ed5734b4928900ee6b91a4e136e8308dea696bdae10527240d42b03e682347f",
                "md5": "e70f6778b65e4af13424acce866593d0",
                "sha256": "ea81203aee3a86bc6d18bf600000eb061d815993c99cffda3b631767fde4c15f"
            },
            "downloads": -1,
            "filename": "Telegant-0.2.5.tar.gz",
            "has_sig": false,
            "md5_digest": "e70f6778b65e4af13424acce866593d0",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 6583,
            "upload_time": "2023-05-30T05:31:10",
            "upload_time_iso_8601": "2023-05-30T05:31:10.078531Z",
            "url": "https://files.pythonhosted.org/packages/8e/d5/734b4928900ee6b91a4e136e8308dea696bdae10527240d42b03e682347f/Telegant-0.2.5.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-30 05:31:10",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "kotov584",
    "github_project": "Telegant",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "telegant"
}
        
Elapsed time: 0.15602s