basic.py¶
1# An API wrapper for Bale written in Python
2# Copyright (c) 2022-2024
3# Kian Ahmadian <devs@python-bale-bot.ir>
4# All rights reserved.
5#
6# This software is licensed under the GNU General Public License v2.0.
7# See the accompanying LICENSE file for details.
8#
9# You should have received a copy of the GNU General Public License v2.0
10# along with this program. If not, see <https://www.gnu.org/licenses/gpl-2.0.html>.
11
12from bale import Bot, Update, Message
13from bale.handlers import BaseHandler, CommandHandler
14from bale.checks import ChatType
15
16client = Bot(token="Your Token")
17
18@client.listen('on_ready')
19async def on_ready_handler():
20 print(client.user, "is Ready!")
21
22@client.handle(BaseHandler())
23async def update_handler(update: Update):
24 print(update.update_id)
25
26@client.handle(CommandHandler(['start', 'help'], check=ChatType.PRIVATE | ChatType.GROUP))
27async def start_command(message: Message):
28 return await message.reply("Hello {}!".format(message.author.mention or message.author.first_name))
29
30# See https://docs.python-bale-bot.ir/en/stable/bale.handlers.html to get more information about events!
31
32client.run()