Name | shitgram JSON |
Version |
0.1.dev5
JSON |
| download |
home_page | |
Summary | Python module based on https://core.telegram.org/bots/api |
upload_time | 2023-11-15 19:41:52 |
maintainer | |
docs_url | None |
author | ZAID |
requires_python | ~=3.6 |
license | |
keywords |
bots
bot-api
telegram
|
VCS |
|
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# Install :
```commandline
pip install shitgram==0.1.dev5
```
# How to use?
- Config your bot :
---
```python
from shitgram import Bot, types
API_TOKEN = "API_TOKEN_HERE"
bot = Bot(API_TOKEN)
```
- Add handlers to recive updates from telegram:
---
- Any update from telegram:
```python
@bot.onUpdate
async def on_updates(bot: Bot, update: types.Update):
print(update)
```
- message and edited_message:
```python
@bot.onMessage()
async def on_message(bot: Bot, message: types.Message):
print(message)
@bot.onEditedMessage()
async def on_edited_message(bot: Bot, message: types.Message):
print(message)
# Custom filter
def filter_admin(message: types.Message):
admins = [123456789, 987654321]
return bool(message.from_user.id in admins)
@bot.onMessage(func=filter_admin)
@bot.onEditedMessage(func=filter_admin)
async def on_custom_filter(bot: Bot, message: types.Message):
print(message)
# Echo Bot
@bot.onMessage(func=lambda m: m.text)
async def echo(bot: Bot, message: types.Message):
return await bot.sendMessage(
message.chat.id,
message.text,
entities=message.entities
)
```
- Callback Queries ( No CallbackQuery Methods currently )
```python
@bot.onCallbackQuery()
async def on_callback_query(bot: Bot, callback_query: types.CallbackQuery):
return await bot.sendMessage(
callback_query.message.chat.id,
callback_query.data
)
```
- Inline Queries ( No InlineQuery Methods currently )
```python
@bot.onInlineQuery()
async def on_inline_query(bot: Bot, inline_query: types.InlineQuery):
print(inline_query)
```
- Start the bot:
---
```python
import asyncio
import logging
logging.basicConfig(level=logging.INFO)
asyncio.run(bot.start_polling())
# add allowed updates:
asyncio.run(bot.start_polling(allowed_updates=["message"]))
```
- Start multiple bots:
---
```python
import asyncio
import logging
from shitgram import run_multiple_bots, Bot, types, enums
logging.basicConfig(level=logging.INFO)
bot_1 = Bot("API_TOKEN_1")
bot_2 = Bot("API_TOKEN_2")
@bot_1.onMessage()
@bot_2.onMessage()
async def on_message(bot: Bot, message: types.Message):
return await bot.sendMessage(
message.chat.id,
(await bot.getMe()).mention.markdown,
parse_mode=enums.ParseMode.MARKDOWN
)
asyncio.run(run_multiple_bots([bot_1, bot_2]))
```
# LICENSE :
- [MIT](https://github.com/x72x/shitgram/blob/master/LICENSE)
Raw data
{
"_id": null,
"home_page": "",
"name": "shitgram",
"maintainer": "",
"docs_url": null,
"requires_python": "~=3.6",
"maintainer_email": "",
"keywords": "bots,bot-api,telegram",
"author": "ZAID",
"author_email": "y8838@hotmail.com",
"download_url": "https://files.pythonhosted.org/packages/e8/b9/e94cacc62b4f4ee80d044091273f72b9a0d4f7280338b9cc4b74637eeb3d/shitgram-0.1.dev5.tar.gz",
"platform": null,
"description": "\r\n# Install :\r\n```commandline\r\npip install shitgram==0.1.dev5\r\n```\r\n\r\n# How to use?\r\n- Config your bot :\r\n---\r\n```python\r\nfrom shitgram import Bot, types\r\n\r\nAPI_TOKEN = \"API_TOKEN_HERE\"\r\n\r\nbot = Bot(API_TOKEN)\r\n```\r\n\r\n- Add handlers to recive updates from telegram:\r\n---\r\n- Any update from telegram:\r\n```python\r\n@bot.onUpdate\r\nasync def on_updates(bot: Bot, update: types.Update):\r\n print(update)\r\n```\r\n\r\n- message and edited_message:\r\n```python\r\n@bot.onMessage()\r\nasync def on_message(bot: Bot, message: types.Message):\r\n print(message)\r\n\r\n@bot.onEditedMessage()\r\nasync def on_edited_message(bot: Bot, message: types.Message):\r\n print(message)\r\n\r\n# Custom filter\r\ndef filter_admin(message: types.Message):\r\n admins = [123456789, 987654321]\r\n return bool(message.from_user.id in admins)\r\n\r\n@bot.onMessage(func=filter_admin)\r\n@bot.onEditedMessage(func=filter_admin)\r\nasync def on_custom_filter(bot: Bot, message: types.Message):\r\n print(message)\r\n\r\n# Echo Bot\r\n@bot.onMessage(func=lambda m: m.text)\r\nasync def echo(bot: Bot, message: types.Message):\r\n return await bot.sendMessage(\r\n message.chat.id,\r\n message.text,\r\n entities=message.entities\r\n )\r\n```\r\n\r\n- Callback Queries ( No CallbackQuery Methods currently )\r\n```python\r\n@bot.onCallbackQuery()\r\nasync def on_callback_query(bot: Bot, callback_query: types.CallbackQuery):\r\n return await bot.sendMessage(\r\n callback_query.message.chat.id,\r\n callback_query.data\r\n )\r\n```\r\n\r\n- Inline Queries ( No InlineQuery Methods currently )\r\n```python\r\n@bot.onInlineQuery()\r\nasync def on_inline_query(bot: Bot, inline_query: types.InlineQuery):\r\n print(inline_query)\r\n```\r\n\r\n- Start the bot:\r\n---\r\n```python\r\nimport asyncio\r\nimport logging\r\n\r\nlogging.basicConfig(level=logging.INFO)\r\n\r\nasyncio.run(bot.start_polling())\r\n\r\n# add allowed updates:\r\nasyncio.run(bot.start_polling(allowed_updates=[\"message\"]))\r\n```\r\n\r\n- Start multiple bots:\r\n---\r\n```python\r\nimport asyncio\r\nimport logging\r\n\r\nfrom shitgram import run_multiple_bots, Bot, types, enums\r\n\r\nlogging.basicConfig(level=logging.INFO)\r\n\r\nbot_1 = Bot(\"API_TOKEN_1\")\r\nbot_2 = Bot(\"API_TOKEN_2\")\r\n\r\n@bot_1.onMessage()\r\n@bot_2.onMessage()\r\nasync def on_message(bot: Bot, message: types.Message):\r\n return await bot.sendMessage(\r\n message.chat.id,\r\n (await bot.getMe()).mention.markdown,\r\n parse_mode=enums.ParseMode.MARKDOWN\r\n )\r\n\r\nasyncio.run(run_multiple_bots([bot_1, bot_2]))\r\n```\r\n\r\n# LICENSE :\r\n- [MIT](https://github.com/x72x/shitgram/blob/master/LICENSE)\r\n",
"bugtrack_url": null,
"license": "",
"summary": "Python module based on https://core.telegram.org/bots/api",
"version": "0.1.dev5",
"project_urls": null,
"split_keywords": [
"bots",
"bot-api",
"telegram"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "e838786d80fc89eb317812e2eff9cf9d92cae82a8c4a79d66968898bbcd70344",
"md5": "bd0ca88c4901c76dc3e0564058522b6b",
"sha256": "d891b7aa12e97926a3a7e9d8b84bbf0d794f470d3d0fffa70b7856574edf328c"
},
"downloads": -1,
"filename": "shitgram-0.1.dev5-py3-none-any.whl",
"has_sig": false,
"md5_digest": "bd0ca88c4901c76dc3e0564058522b6b",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "~=3.6",
"size": 37250,
"upload_time": "2023-11-15T19:41:50",
"upload_time_iso_8601": "2023-11-15T19:41:50.860181Z",
"url": "https://files.pythonhosted.org/packages/e8/38/786d80fc89eb317812e2eff9cf9d92cae82a8c4a79d66968898bbcd70344/shitgram-0.1.dev5-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "e8b9e94cacc62b4f4ee80d044091273f72b9a0d4f7280338b9cc4b74637eeb3d",
"md5": "b8abee3fab627c9c61f513f494011fa2",
"sha256": "9b25a2a99e1b2a569d04702cd36efe9d2cefbf385cdf9487b76060da59a85211"
},
"downloads": -1,
"filename": "shitgram-0.1.dev5.tar.gz",
"has_sig": false,
"md5_digest": "b8abee3fab627c9c61f513f494011fa2",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "~=3.6",
"size": 20965,
"upload_time": "2023-11-15T19:41:52",
"upload_time_iso_8601": "2023-11-15T19:41:52.681935Z",
"url": "https://files.pythonhosted.org/packages/e8/b9/e94cacc62b4f4ee80d044091273f72b9a0d4f7280338b9cc4b74637eeb3d/shitgram-0.1.dev5.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-11-15 19:41:52",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "shitgram"
}