File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11# This is a simple echo bot using the decorator mechanism.
22# It echoes any incoming text messages.
33
4- import telebot
4+ import telebot . listeners
55
66API_TOKEN = '<api_token>'
77
88bot = telebot .TeleBot (API_TOKEN )
99
10+
1011# Handle '/start' and '/help'
1112@bot .message_handler (commands = ['help' , 'start' ])
1213def send_welcome (message ):
Original file line number Diff line number Diff line change 11# This example show how to write an inline mode telegramt bot use pyTelegramBotAPI.
2+ from __future__ import print_function
23import telebot
34import time
45import sys
@@ -69,5 +70,5 @@ def main_loop():
6970 try :
7071 main_loop ()
7172 except KeyboardInterrupt :
72- print >> sys . stderr , '\n Exiting by user request.\n '
73+ print ( '\n Exiting by user request.\n ' )
7374 sys .exit (0 )
Original file line number Diff line number Diff line change @@ -39,7 +39,7 @@ def process_name_step(message):
3939 user_dict [chat_id ] = user
4040 msg = bot .reply_to (message , 'How old are you?' )
4141 bot .register_next_step_handler (msg , process_age_step )
42- except Exception as e :
42+ except Exception :
4343 bot .reply_to (message , 'oooops' )
4444
4545
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ def index(self):
4646 length = int (cherrypy .request .headers ['content-length' ])
4747 json_string = cherrypy .request .body .read (length ).decode ("utf-8" )
4848 update = telebot .types .Update .de_json (json_string )
49- bot .process_new_messages ([update . message ])
49+ bot .process_new_updates ([update ])
5050 return ''
5151 else :
5252 raise cherrypy .HTTPError (403 )
Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ def do_POST(self):
6060 self .end_headers ()
6161
6262 update = telebot .types .Update .de_json (json_string )
63- bot .process_new_messages ([update .message ])
63+ bot .process_new_updates ([update .message ])
6464 else :
6565 self .send_error (403 )
6666 self .end_headers ()
Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ def webhook():
5050 if flask .request .headers .get ('content-type' ) == 'application/json' :
5151 json_string = flask .request .get_data ().encode ('utf-8' )
5252 update = telebot .types .Update .de_json (json_string )
53- bot .process_new_messages ([update . message ])
53+ bot .process_new_updates ([update ])
5454 return ''
5555 else :
5656 flask .abort (403 )
You can’t perform that action at this time.
0 commit comments