# KenarBot
<div align="center">
[](https://badge.fury.io/py/kenarbot)
[](https://opensource.org/licenses/MIT)
[](https://pypi.org/project/kenarbot/)
[](https://codecov.io/github/Mobin-Pourabedini/KenarBot)
</div>
A Python SDK for creating and managing Kenar messaging bots. KenarpyBot provides a simple, intuitive interface inspired by teleBot's syntax, making it easy for developers familiar with Telegram bot development to create bots for the Kenar platform.
### What is Kenar Divar?
[Kenar Divar](https://github.com/divar-ir/kenar-docs) is Divar's official platform that provides APIs for developers to create
plugins and integrations with Divar. These APIs enable functionality like sending and receiving messages, editing posts, patching add-ons on posts and etc...
, you should also checkput [Kenar Divar Panel](https://divar.ir/kenar)
## Features
- 🚀 Simple, teleBot-inspired syntax
- 📨 Easy message handling and routing
- 🔄 Built-in support for Kenar's messaging endpoints
- ⚡ Flask-based webhook handling
- ⚙️ Straightforward bot configuration
## Examples
- [Cowsay echo bot](https://github.com/Mobin-Pourabedini/divar-echo-bot)
## Installation
```bash
pip install kenarbot
```
## Quick Start Example
Here's a simple example demonstrating how to create a bot that responds to messages containing "hello":
```python
import os
from kenarBot import KenarBot
from kenarBot.types import ChatBotMessage
# Initialize your API key from Kenar platform
DIVAR_API_KEY = os.getenv("DIVAR_API_KEY")
DIVAR_IDENTIFICATION_KEY = os.getenv("DIVAR_IDENTIFICATION_KEY")
# Create a bot instance
bot = KenarBot(DIVAR_IDENTIFICATION_KEY, "/webhook", DIVAR_API_KEY)
# Define a message handler that responds to messages containing "hello"
@bot.message_handler(regexp="hello")
def handle_hello(chatbot_message: ChatBotMessage):
# Send a response back to the same conversation
bot.send_message(chatbot_message.conversation_id, f"Hi, my name is AmazingKenarBot")
if __name__ == "__main__":
# Start the bot
bot.run()
```
This example shows:
- How to initialize the bot with your API key
- How to create a message handler using decorators
- How to respond to specific messages using regular expressions
- How to send messages back to conversations
### Key Components:
1. **Bot Initialization**:
- Create a `KenarBot` instance with your app name, webhook path, and API key
- The webhook path is where your bot will receive updates
2. **Message Handler**:
- Use the `@bot.message_handler` decorator to define message handlers
- The `regexp` parameter allows you to filter messages based on regular expressions
- Other handler options are available (commands, content types, etc.)
3. **Sending Messages**:
- Use `bot.send_message()` to send responses
- Requires the conversation ID and the message text
4. **Running the Bot**:
- Call `bot.run()` to start the bot
- This will start a Flask server to handle incoming webhook requests
### Important Notes:
- Keep your API key secure and never commit it to version control
- Consider using environment variables for sensitive data
- The bot runs on Flask, so it needs to be hosted on a server accessible to Kenar
## Documentation
### Available Methods
- `bot.send_message(conversation_id, text)`: Send a message to a conversation
- `bot.message_handler(regexp="")`: Decorator for handling messages matching a regex pattern
- `bot.run()`: Start the bot's webhook server
## Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
1. Fork the repository
2. Create your feature branch (`git checkout -b feature/AmazingFeature`)
3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## Support
- Create an [Issue](https://github.com/Mobin-Pourabedini/KenarBot/issues)
- Send an email to realmobinpourabedini@gmail.com
## Acknowledgments
- Inspired by the [pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI) project
- Thanks to the open-platform team
## Author
Mobin Pourabedini ([@Mobin-Pourabedini](https://github.com/Mobin-Pourabedini))
---
Made with ❤️ for the Kenar community
Raw data
{
"_id": null,
"home_page": "https://github.com/Mobin-Pourabedini/KenarBot",
"name": "kenarBot",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "bot, kenar, messaging, chat, api",
"author": "Mobin Pourabedini",
"author_email": "realmobinpourabedini@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/ca/55/26322638bcd96b8bd028170ab55f8d3b6930d2dcd2ced579f5b761b1a7c6/kenarbot-0.1.1.tar.gz",
"platform": null,
"description": "# KenarBot\n\n<div align=\"center\">\n\n[](https://badge.fury.io/py/kenarbot)\n[](https://opensource.org/licenses/MIT)\n[](https://pypi.org/project/kenarbot/)\n[](https://codecov.io/github/Mobin-Pourabedini/KenarBot)\n</div>\n\nA Python SDK for creating and managing Kenar messaging bots. KenarpyBot provides a simple, intuitive interface inspired by teleBot's syntax, making it easy for developers familiar with Telegram bot development to create bots for the Kenar platform.\n\n### What is Kenar Divar?\n[Kenar Divar](https://github.com/divar-ir/kenar-docs) is Divar's official platform that provides APIs for developers to create\nplugins and integrations with Divar. These APIs enable functionality like sending and receiving messages, editing posts, patching add-ons on posts and etc...\n, you should also checkput [Kenar Divar Panel](https://divar.ir/kenar)\n\n## Features\n\n- \ud83d\ude80 Simple, teleBot-inspired syntax\n- \ud83d\udce8 Easy message handling and routing\n- \ud83d\udd04 Built-in support for Kenar's messaging endpoints\n- \u26a1 Flask-based webhook handling\n- \u2699\ufe0f Straightforward bot configuration\n\n## Examples\n- [Cowsay echo bot](https://github.com/Mobin-Pourabedini/divar-echo-bot)\n\n## Installation\n\n```bash\npip install kenarbot\n```\n\n## Quick Start Example\n\nHere's a simple example demonstrating how to create a bot that responds to messages containing \"hello\":\n\n```python\nimport os\n\nfrom kenarBot import KenarBot\nfrom kenarBot.types import ChatBotMessage\n\n# Initialize your API key from Kenar platform\nDIVAR_API_KEY = os.getenv(\"DIVAR_API_KEY\")\nDIVAR_IDENTIFICATION_KEY = os.getenv(\"DIVAR_IDENTIFICATION_KEY\")\n\n# Create a bot instance\nbot = KenarBot(DIVAR_IDENTIFICATION_KEY, \"/webhook\", DIVAR_API_KEY)\n\n# Define a message handler that responds to messages containing \"hello\"\n@bot.message_handler(regexp=\"hello\")\ndef handle_hello(chatbot_message: ChatBotMessage):\n # Send a response back to the same conversation\n bot.send_message(chatbot_message.conversation_id, f\"Hi, my name is AmazingKenarBot\")\n\nif __name__ == \"__main__\":\n # Start the bot\n bot.run()\n```\n\nThis example shows:\n- How to initialize the bot with your API key\n- How to create a message handler using decorators\n- How to respond to specific messages using regular expressions\n- How to send messages back to conversations\n\n### Key Components:\n\n1. **Bot Initialization**:\n - Create a `KenarBot` instance with your app name, webhook path, and API key\n - The webhook path is where your bot will receive updates\n\n2. **Message Handler**:\n - Use the `@bot.message_handler` decorator to define message handlers\n - The `regexp` parameter allows you to filter messages based on regular expressions\n - Other handler options are available (commands, content types, etc.)\n\n3. **Sending Messages**:\n - Use `bot.send_message()` to send responses\n - Requires the conversation ID and the message text\n\n4. **Running the Bot**:\n - Call `bot.run()` to start the bot\n - This will start a Flask server to handle incoming webhook requests\n\n### Important Notes:\n- Keep your API key secure and never commit it to version control\n- Consider using environment variables for sensitive data\n- The bot runs on Flask, so it needs to be hosted on a server accessible to Kenar\n\n## Documentation\n\n### Available Methods\n\n- `bot.send_message(conversation_id, text)`: Send a message to a conversation\n- `bot.message_handler(regexp=\"\")`: Decorator for handling messages matching a regex pattern\n- `bot.run()`: Start the bot's webhook server\n\n## Contributing\n\nContributions are welcome! Please feel free to submit a Pull Request.\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n\n## Support\n\n- Create an [Issue](https://github.com/Mobin-Pourabedini/KenarBot/issues)\n- Send an email to realmobinpourabedini@gmail.com\n\n## Acknowledgments\n\n- Inspired by the [pyTelegramBotAPI](https://github.com/eternnoir/pyTelegramBotAPI) project\n- Thanks to the open-platform team\n\n## Author\n\nMobin Pourabedini ([@Mobin-Pourabedini](https://github.com/Mobin-Pourabedini))\n\n---\n\nMade with \u2764\ufe0f for the Kenar community\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "KenarBot: A Python SDK for building Kenar messaging bots with an intuitive, teleBot-inspired syntax.",
"version": "0.1.1",
"project_urls": {
"Homepage": "https://github.com/Mobin-Pourabedini/KenarBot"
},
"split_keywords": [
"bot",
" kenar",
" messaging",
" chat",
" api"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "95e7cad5ed1c8a60089aadd91f79fec37f58b7556c50d8ccbdc2816f7528541d",
"md5": "d5d62187364aed1790cad07e0b745c26",
"sha256": "2e9bdb864b50c8626241623ed34d77540041caba802beefe90dbffb38652baf7"
},
"downloads": -1,
"filename": "kenarbot-0.1.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "d5d62187364aed1790cad07e0b745c26",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 9099,
"upload_time": "2025-07-13T12:09:00",
"upload_time_iso_8601": "2025-07-13T12:09:00.895287Z",
"url": "https://files.pythonhosted.org/packages/95/e7/cad5ed1c8a60089aadd91f79fec37f58b7556c50d8ccbdc2816f7528541d/kenarbot-0.1.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "ca5526322638bcd96b8bd028170ab55f8d3b6930d2dcd2ced579f5b761b1a7c6",
"md5": "c3a14307d5e230db3a37704c7d493e19",
"sha256": "c8b0b73bbcac1ae61fb824c1f095b30c5796f771ced68aa0c8032fbe50d292c4"
},
"downloads": -1,
"filename": "kenarbot-0.1.1.tar.gz",
"has_sig": false,
"md5_digest": "c3a14307d5e230db3a37704c7d493e19",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 9645,
"upload_time": "2025-07-13T12:09:02",
"upload_time_iso_8601": "2025-07-13T12:09:02.828354Z",
"url": "https://files.pythonhosted.org/packages/ca/55/26322638bcd96b8bd028170ab55f8d3b6930d2dcd2ced579f5b761b1a7c6/kenarbot-0.1.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-13 12:09:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "Mobin-Pourabedini",
"github_project": "KenarBot",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"requirements": [
{
"name": "blinker",
"specs": [
[
"==",
"1.9.0"
]
]
},
{
"name": "certifi",
"specs": [
[
"==",
"2024.12.14"
]
]
},
{
"name": "charset-normalizer",
"specs": [
[
"==",
"3.4.1"
]
]
},
{
"name": "click",
"specs": [
[
"==",
"8.1.8"
]
]
},
{
"name": "Flask",
"specs": [
[
"==",
"3.1.0"
]
]
},
{
"name": "idna",
"specs": [
[
"==",
"3.10"
]
]
},
{
"name": "iniconfig",
"specs": [
[
"==",
"2.0.0"
]
]
},
{
"name": "itsdangerous",
"specs": [
[
"==",
"2.2.0"
]
]
},
{
"name": "Jinja2",
"specs": [
[
"==",
"3.1.5"
]
]
},
{
"name": "MarkupSafe",
"specs": [
[
"==",
"3.0.2"
]
]
},
{
"name": "packaging",
"specs": [
[
"==",
"24.2"
]
]
},
{
"name": "pluggy",
"specs": [
[
"==",
"1.5.0"
]
]
},
{
"name": "pytest",
"specs": [
[
"==",
"8.3.4"
]
]
},
{
"name": "requests",
"specs": [
[
"==",
"2.32.3"
]
]
},
{
"name": "urllib3",
"specs": [
[
"==",
"2.3.0"
]
]
},
{
"name": "Werkzeug",
"specs": [
[
"==",
"3.1.3"
]
]
},
{
"name": "httpx",
"specs": [
[
"==",
"0.28.1"
]
]
},
{
"name": "loguru",
"specs": [
[
"==",
"0.7.3"
]
]
}
],
"lcname": "kenarbot"
}