File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed
Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1+ import os
2+ # import webbrowser
3+
4+ import telebot
5+ from dotenv import load_dotenv
6+
7+ load_dotenv ()
8+ TOKEN = os .getenv ("TELEBOT_TOKEN" )
9+
10+ bot = telebot .TeleBot (TOKEN )
11+
12+
13+ @bot .message_handler (commands = ["start" ])
14+ def start_message (message ):
15+ bot .send_message (message .chat .id , "Hello!" )
16+
17+
18+ @bot .message_handler (commands = ["info" ])
19+ def get_info (message ):
20+ bot .send_message (message .chat .id , message )
21+
22+ # OPENS WEBSITE LOCALLY!!
23+ # @bot.message_handler(commands=["web", "site"])
24+ # def open_website(_):
25+ # webbrowser.open("https://www.usalearns.org/")
26+
27+
28+ @bot .message_handler ()
29+ def general_message_handler (message ):
30+ if message .text .lower () == 'hello' :
31+ bot .send_message (message .chat .id ,
32+ f"Hello { message .from_user .first_name } " )
33+ if message .text .lower () == 'id' :
34+ bot .reply_to (message , f"ID: { message .from_user .id } " )
35+
36+
37+ bot .polling (none_stop = True )
Original file line number Diff line number Diff line change 11pyTelegramBotAPI ~= 4.10.0
2+ python-dotenv ~= 1.0.0
You can’t perform that action at this time.
0 commit comments