# simplybot
**A python library to create telegram bots simply and easily**
**Get started**
- First install the main bot library
```
pip install simplybot
```
# Example
```python
# initialize bot token
from simplybot import startBot
bot = startBot('token here')
# example send plain text message
def start(message, chat_id):
bot.send_text(chat_id, "Hello %username! I'm your friendly telegram bot.", message=message)
# quoted message
bot.handle_command('start', start)
def quotedMessage(message, chat_id):
bot.send_text(chat_id, "This is quoted message", quoted=message.message_id)
bot.handle_command('start', start)
bot.handle_command('quoted', quotedMessage)
bot.start_polling() # start the bot
```
# sending media
```python
def send_media_messages(message, chat_id):
# Send an image from a URL
image_url = "https://example.com/path/to/image.jpg"
bot.send_img(chat_id, image_url, caption="Here is an image from a URL!")
# Send an image from a local file path
local_image_path = "path/to/local/image.jpg"
bot.send_img(chat_id, local_image_path, caption="Here is an image from a local file!")
# Send a video from a local file path
local_video_path = "path/to/local/video.mp4"
bot.send_video(chat_id, local_video_path, caption="Check out this video!")
# Send an audio file from a local file path
local_audio_path = "path/to/local/audio.mp3"
bot.send_audio(chat_id, local_audio_path, caption="Listen to this audio!")
# Send a document from a local file path
local_doc_path = "path/to/local/document.pdf"
bot.send_docs(chat_id, local_doc_path, mimetype="application/pdf")
```
# markup/callback message
```python
def start(message, chat_id):
# Define the buttons
payloads = {
'button': [
{
'rows': [
{
'type': 'inline',
'displayText': 'Option 1',
'callback': 'option_1'
},
{
'type': 'inline',
'displayText': 'Option 2',
'callback': 'option_2'
},
]
}
]
}
# Send the message with buttons
bot.send_message_with_buttons(chat_id, "Click button below", payloads)
def handle_option_1(call, chat_id):
# Respond to Option 1 button press
bot.send_text(chat_id, "You selected Option 1!")
def handle_option_2(call, chat_id):
# Respond to Option 2 button press
bot.send_text(chat_id, "You selected Option 2!")
```
# other
```python
# send quiz & polling message
def quiz(message, chat_id):
polling_message = {
'description': 'What is the capital of France?',
'rows': [
{
'name': 'Paris',
'isCorrectAnswers': True
},
{
'name': 'London',
'isCorrectAnswers': False
},
{
'name': 'Berlin',
'isCorrectAnswers': False
}
],
'isAnonymous': False,
'isQuizVote': True,
'allowMultipleVote': False,
'explanation': 'The capital of France is Paris.'
}
bot.send_poll(chat_id, polling_message)
# send contact
bot.send_contact(chat_id, '+1234567890', 'John')
# send location
bot.send_location(chat_id, 37.7749, -122.4194)
```
# Credit
- eternnoir [telebot](https://github.com/eternnoir/pyTelegramBotAPI)
- & me :)
I have been works lonely for 7 hours making this libary and i forgot to touch some grass outside
so give me:
- fork this reposity
- click the star
`adjidev 2024`
Raw data
{
"_id": null,
"home_page": "https://github.com/adjidev/simplybot",
"name": "simplybot",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": null,
"author": "adjisan",
"author_email": "support@ailibytes.xyz",
"download_url": "https://files.pythonhosted.org/packages/c3/c8/88a4ecb9db91912c4f8a2c99885a49d9638bab7c51134e7e345d6f9ce682/simplybot-0.24.8.113.tar.gz",
"platform": null,
"description": "# simplybot\r\n**A python library to create telegram bots simply and easily**\r\n\r\n\r\n\r\n**Get started**\r\n\r\n- First install the main bot library\r\n```\r\npip install simplybot\r\n```\r\n# Example\r\n```python\r\n# initialize bot token\r\nfrom simplybot import startBot\r\n\r\nbot = startBot('token here')\r\n# example send plain text message\r\ndef start(message, chat_id):\r\n bot.send_text(chat_id, \"Hello %username! I'm your friendly telegram bot.\", message=message)\r\n\r\n# quoted message\r\nbot.handle_command('start', start)\r\ndef quotedMessage(message, chat_id):\r\n bot.send_text(chat_id, \"This is quoted message\", quoted=message.message_id)\r\n\r\nbot.handle_command('start', start)\r\nbot.handle_command('quoted', quotedMessage)\r\n\r\nbot.start_polling() # start the bot\r\n```\r\n# sending media\r\n```python\r\ndef send_media_messages(message, chat_id):\r\n # Send an image from a URL\r\n image_url = \"https://example.com/path/to/image.jpg\"\r\n bot.send_img(chat_id, image_url, caption=\"Here is an image from a URL!\")\r\n\r\n # Send an image from a local file path\r\n local_image_path = \"path/to/local/image.jpg\"\r\n bot.send_img(chat_id, local_image_path, caption=\"Here is an image from a local file!\")\r\n\r\n # Send a video from a local file path\r\n local_video_path = \"path/to/local/video.mp4\"\r\n bot.send_video(chat_id, local_video_path, caption=\"Check out this video!\")\r\n\r\n # Send an audio file from a local file path\r\n local_audio_path = \"path/to/local/audio.mp3\"\r\n bot.send_audio(chat_id, local_audio_path, caption=\"Listen to this audio!\")\r\n\r\n # Send a document from a local file path\r\n local_doc_path = \"path/to/local/document.pdf\"\r\n bot.send_docs(chat_id, local_doc_path, mimetype=\"application/pdf\")\r\n```\r\n# markup/callback message\r\n```python\r\ndef start(message, chat_id):\r\n\r\n # Define the buttons\r\n payloads = {\r\n 'button': [\r\n {\r\n 'rows': [\r\n {\r\n 'type': 'inline',\r\n 'displayText': 'Option 1',\r\n 'callback': 'option_1'\r\n },\r\n {\r\n 'type': 'inline',\r\n 'displayText': 'Option 2',\r\n 'callback': 'option_2'\r\n },\r\n ]\r\n }\r\n ]\r\n }\r\n\r\n # Send the message with buttons\r\n bot.send_message_with_buttons(chat_id, \"Click button below\", payloads)\r\n\r\ndef handle_option_1(call, chat_id):\r\n # Respond to Option 1 button press\r\n bot.send_text(chat_id, \"You selected Option 1!\")\r\n\r\ndef handle_option_2(call, chat_id):\r\n # Respond to Option 2 button press\r\n bot.send_text(chat_id, \"You selected Option 2!\")\r\n```\r\n# other\r\n```python\r\n# send quiz & polling message\r\ndef quiz(message, chat_id):\r\n polling_message = {\r\n 'description': 'What is the capital of France?',\r\n 'rows': [\r\n {\r\n 'name': 'Paris',\r\n 'isCorrectAnswers': True\r\n },\r\n {\r\n 'name': 'London',\r\n 'isCorrectAnswers': False\r\n },\r\n {\r\n 'name': 'Berlin',\r\n 'isCorrectAnswers': False\r\n }\r\n ],\r\n 'isAnonymous': False,\r\n 'isQuizVote': True,\r\n 'allowMultipleVote': False,\r\n 'explanation': 'The capital of France is Paris.'\r\n }\r\n bot.send_poll(chat_id, polling_message)\r\n\r\n# send contact\r\nbot.send_contact(chat_id, '+1234567890', 'John')\r\n# send location\r\nbot.send_location(chat_id, 37.7749, -122.4194)\r\n```\r\n\r\n# Credit\r\n- eternnoir [telebot](https://github.com/eternnoir/pyTelegramBotAPI)\r\n- & me :)\r\n\r\nI have been works lonely for 7 hours making this libary and i forgot to touch some grass outside\r\nso give me:\r\n- fork this reposity\r\n- click the star\r\n\r\n`adjidev 2024`\r\n",
"bugtrack_url": null,
"license": null,
"summary": "A Python library to build simple Telegram bots more easily",
"version": "0.24.8.113",
"project_urls": {
"Homepage": "https://github.com/adjidev/simplybot"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "0121cd078aaf822968c1275eca0db10224318e2e948d38c32f448488320f9ab0",
"md5": "9487196345dcd1d5f9d67e768c24d1cc",
"sha256": "6c35a40f68e2d3052fce1832e1c6577c3e26890d3a15d0a0c62782b7005d6698"
},
"downloads": -1,
"filename": "simplybot-0.24.8.113-py3-none-any.whl",
"has_sig": false,
"md5_digest": "9487196345dcd1d5f9d67e768c24d1cc",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 3320,
"upload_time": "2024-08-13T15:48:44",
"upload_time_iso_8601": "2024-08-13T15:48:44.729337Z",
"url": "https://files.pythonhosted.org/packages/01/21/cd078aaf822968c1275eca0db10224318e2e948d38c32f448488320f9ab0/simplybot-0.24.8.113-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c3c888a4ecb9db91912c4f8a2c99885a49d9638bab7c51134e7e345d6f9ce682",
"md5": "6b747255aec43aa417ec11e3e6670ff1",
"sha256": "56ea40b52496af338e6467e16c0f554b0bdc27175c0fdb21cd3ccd8c1537a6dc"
},
"downloads": -1,
"filename": "simplybot-0.24.8.113.tar.gz",
"has_sig": false,
"md5_digest": "6b747255aec43aa417ec11e3e6670ff1",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 3312,
"upload_time": "2024-08-13T15:48:46",
"upload_time_iso_8601": "2024-08-13T15:48:46.058142Z",
"url": "https://files.pythonhosted.org/packages/c3/c8/88a4ecb9db91912c4f8a2c99885a49d9638bab7c51134e7e345d6f9ce682/simplybot-0.24.8.113.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2024-08-13 15:48:46",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "adjidev",
"github_project": "simplybot",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "simplybot"
}