Import logging


Download 1.1 Mb.
Sana23.11.2023
Hajmi1.1 Mb.
#1796329
Bog'liq
Mustaqil ish 1


Mavzu:Telegram API dan foydalanib bot orqali telegram guruhiga yoki kanalga post qilish, xabarlarni tahrirlash, … funksiyalariga ega bo‘lgan dastur yaratish









import logging


import wikipedia

from aiogram import Bot, Dispatcher, executor, types


API_TOKEN = '5232641699:AAEgLbZAq0GTzFJoV97zd5CMMRMiV5A8a8o'


wikipedia.set_lang('uz')

# Configure logging


logging.basicConfig(level=logging.INFO)

# Initialize bot and dispatcher


bot = Bot(token=API_TOKEN)
dp = Dispatcher(bot)

@dp.message_handler(commands=['start', 'help'])


async def send_welcome(message: types.Message):
"""
This handler will be called when user sends `/start` or `/help` command
"""
await message.reply("Wikipeida Botiga Xush Kelibsiz!")

@dp.message_handler()


async def sendWiki(message: types.Message):
try:
respond = wikipedia.summary(message.text)
await message.answer(respond)
except:
await message.answer("Bu mavzuga oid maqola topilmadi")

if __name__ == '__main__':


executor.start_polling(dp, skip_updates=True)

Download 1.1 Mb.

Do'stlaringiz bilan baham:




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling