fork download
  1. import config
  2. import telebot
  3. import MySQLdb
  4.  
  5. bot = telebot.TeleBot(config.token)
  6.  
  7.  
  8. @bot.message_handler(commands=['start'])
  9. def start_conversation(message):
  10. bot.send_message(message.chat.id, "Просто пришлите боту номер вашей квитанции:")
  11.  
  12. @bot.message_handler(content_types=["text"])
  13. def repeat_all_messages(message):
  14. try:
  15. conn = MySQLdb.connect(host="localhost", user="root", passwd="1234", db="mobilservice")
  16.  
  17. except MySQLdb.Error as err:
  18. print("Connection error: {}".format(err))
  19. conn.close()
  20.  
  21. sql = "SELECT note FROM application WHERE id = " + message.text
  22.  
  23. try:
  24. cur = conn.cursor(MySQLdb.cursors.DictCursor)
  25. cur.execute(sql)
  26. data = cur.fetchall()
  27. except MySQLdb.Error as err:
  28. print("Query error: {}".format(err))
  29. bot.send_message(message.chat.id, data[0]['note'])
  30.  
  31. if __name__ == '__main__':
  32. bot.polling(none_stop=True)
Runtime error #stdin #stdout #stderr 0.01s 119552KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "prog.py", line 1, in <module>
    import config
ImportError: No module named config