Advertisement
DrAungWinHtut

MathTelegramBot

Nov 17th, 2023
831
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.31 KB | None | 0 0
  1. # pip install pyTelegramBotAPI
  2. # PythonMyanmar_bot
  3. import random
  4. import telebot
  5. from telebot.types import ReplyKeyboardMarkup, KeyboardButton
  6. import os
  7. API_TOKEN = '6755851932:AAHE0EP6aX7As10QF7YnDmHJB9E4dor-u7k'
  8. user_input = ""
  9. digit = 0
  10. count = 0
  11. bot = telebot.TeleBot(API_TOKEN)
  12.  
  13.  
  14. @bot.message_handler(commands=['start']) #/start
  15. def start(message):  
  16.     bot.reply_to(message, "enter digits (1,2,3,4,etc...)")
  17.    
  18.  
  19.  
  20.  
  21. # Handle all other messages with content_type 'text' (content_types defaults to ['text'])
  22. @bot.message_handler(func=lambda message: True)
  23. def online_class(message):
  24.     global digit
  25.     user_input = message.text
  26.     match(user_input):
  27.         case 'a':
  28.             digit = 1            
  29.             n1 = 9
  30.             bot.reply_to(message, f'You will be adding/substracting numbers between -{n1} and {n1}!')
  31.             bot.reply_to(message, "How many numbers to add/ substract?")
  32.         case 'b':
  33.             digit = 2
  34.             n1 = 99
  35.             bot.reply_to(message, f'You will be adding/substracting numbers between -{n1} and {n1}!')
  36.             bot.reply_to(message, "How many numbers to add/ substract?")
  37.         case 'c':
  38.             digit = 3
  39.             n1 = 999
  40.             bot.reply_to(message, f'You will be adding/substracting numbers between -{n1} and {n1}!')
  41.             bot.reply_to(message, "How many numbers to add/ substract?")
  42.         case '2':
  43.             bot.reply_to(message, "2")
  44.             bot.reply_to(message, "digit is " + str(digit))
  45.             match(digit):
  46.                 case 1:
  47.                     num1 = random.randint(-9,9)    
  48.                     num2 = random.randint(-9,9)              
  49.                     bot.reply_to(message, f"{num1} + {num2} = ?")
  50.                 case 2:
  51.                     num1 = random.randint(10,99)    
  52.                     num2 = random.randint(10,99)  
  53.                     s1 = random.randint(0,1)
  54.                     s2 = random.randint(0,1)  
  55.                     if(s1==1):
  56.                         num1 = num1 * -1
  57.                     if(s2==1):
  58.                         num2 = num2 * -1        
  59.                     bot.reply_to(message, f"{num1} + {num2} = ?")
  60.                 case 3:
  61.                     num1 = random.randint(100,999)    
  62.                     num2 = random.randint(100,999)  
  63.                     s1 = random.randint(0,1)
  64.                     s2 = random.randint(0,1)  
  65.                     if(s1==1):
  66.                         num1 = num1 * -1
  67.                     if(s2==1):
  68.                         num2 = num2 * -1        
  69.                     bot.reply_to(message, f"{num1} + {num2} = ?")
  70.         case '3':
  71.             match(digit):
  72.                 case 1:                    
  73.                     bot.reply_to(message, "1 + 1 + 1= ?")
  74.                 case 2:
  75.                     bot.reply_to(message, "11 + 11 + 11= ?")
  76.                 case 3:
  77.                     bot.reply_to(message, "111 + 111 + 111= ?")
  78.         case '4':
  79.             match(digit):
  80.                 case 1:                    
  81.                     bot.reply_to(message, "1 + 1 + 1 + 1= ?")
  82.                 case 2:
  83.                     bot.reply_to(message, "11 + 11 + 11 + 11 = ?")
  84.                 case 3:
  85.                     bot.reply_to(message, "111 + 111 + 111+ 111= ?")
  86.  
  87.    
  88.  
  89.  
  90. bot.infinity_polling()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement