Last active
February 16, 2021 19:56
-
-
Save fatiiates/7ad8ec92788d66c8b62ff8e9a0c7a0a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from telegram.ext import Updater, CommandHandler, MessageHandler, Filters | |
TOKEN = "[BOT_TOKEN]" | |
def run(updater): | |
print("Bot başlatıldı.") | |
updater.start_polling() | |
def start(update, context): | |
message = "Bot başlatıldı.\n" | |
message += "Daha fazla bilgi için /yardim komutunu gönderin." | |
# Bot gönderilen mesaja özel yanıt döndürüyor | |
update.message.reply_text(message) | |
def help(update, context): | |
help_message = "Mevcut komutları aşağıdan görebilirsin.\n\n" | |
help_message += "/hakkinda - Chatbot hakkındaki bilgileri verir.\n" | |
help_message += "/yardim - Tüm komutları listeler.\n" | |
help_message += "/start - Chatbotu başlatır.\n" | |
# Bot gönderilen mesaja özel yanıt döndürüyor | |
update.message.reply_text(help_message) | |
def about(update, context): | |
message = "Merhaba, ben bir test chatbotum.\n" | |
message += "Sana hizmet etmek için buradayım." | |
# Bot gönderilen mesaja özel yanıt döndürüyor | |
update.message.reply_text(message) | |
def wrongCommand(update, context): | |
update.message.reply_text("Üzgünüm, gönderdiğiniz mesajı anlayamıyorum.") | |
def main(): | |
#Telegram Api güncellemelerini yakalayan bir Updater oluşturduk | |
updater = Updater(TOKEN, use_context=True) | |
# Api güncellemelerini yönlendirmek için Dispatcher oluşturduk | |
dp = updater.dispatcher | |
# Dispatchera komut yakalayıcılarımızı ekledik | |
dp.add_handler(CommandHandler("start", start)) | |
dp.add_handler(CommandHandler("yardim", help)) | |
dp.add_handler(CommandHandler("hakkinda", about)) | |
# Yanlış bir komut girildiyse burada yakalanacak | |
dp.add_handler(MessageHandler(Filters.text, wrongCommand)) | |
run(updater) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment