Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. #!/usr/bin/env python
  2. # -*- coding: utf-8 -*-
  3. import os
  4. import sys
  5. import time
  6. import telepot
  7. from telepot.loop import MessageLoop
  8.  
  9. token='432066469:AAH8-jVofZ8JhY8M1NNlqe0A0cdyLAb-q84'
  10.  
  11. def on_chat_cod(msg):
  12. content_type, chat_type, chat_id = telepot.glance(msg)
  13. if content_type != 'text':
  14. return
  15. else:
  16. cod= msg['text']
  17. print cod
  18. bot.sendMessage(chat_id,'ready')
  19.  
  20. def on_chat_data(msg):
  21. content_type, chat_type,chat_id = telepot.glance(msg)
  22. if content_type != 'text':
  23. return
  24. else:
  25. data= msg['text']
  26. print data
  27. bot.sendMessage(chat_id, 'ready')
  28.  
  29. def start(msg):
  30. flavor = telepot.flavor(msg)
  31. summary = telepot.glance(msg, flavor=flavor)
  32. chat_id= summary[2]
  33. command= msg['text']
  34. bot.sendMessage(chat_id,' Hi ... select a command')
  35. if command == '/cedula':
  36. bot.sendMessage(chat_id,'Insert the cod')
  37. on_chat_cedula(msg)
  38. elif command == '/data':
  39. bot.sendMessage(chat_id,'Insert the Data')
  40. on_chat_data(msg)
  41.  
  42. bot =telepot.Bot(token)
  43. MessageLoop(bot,{'chat':start, 'cod':on_chat_cod, data':on_chat_data}).run_as_thread()
  44. print 'listening...'
  45.  
  46. while 1:
  47. time.sleep(3)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement