Advertisement
Guest User

Untitled

a guest
Mar 6th, 2017
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.61 KB | None | 0 0
  1. import telepot
  2. import random
  3. import time
  4. BOT_TOKEN = ''
  5. bot = telepot.Bot(BOT_TOKEN)
  6.  
  7.  
  8. def handle(msg):
  9.     chat_id = msg['chat']['id']
  10.     command = msg['text'].lower()
  11.     user_name = msg['chat']['first_name']
  12.  
  13.     print('Got command: %s' % command)
  14.  
  15.     if command.find('привет') != -1:
  16.         bot.sendMessage(chat_id, privet() + user_name)
  17.  
  18. def privet():
  19.     slova = ['Привет, ', 'Дарова, ', 'Здравствуй, ', 'Хай, ']
  20.     return slova[random.randint(0, 4)]
  21.  
  22. bot.message_loop(handle)
  23. print('Listening ...')
  24.  
  25. # Keep the program running.
  26. while 1:
  27.     time.sleep(10)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement