Skip to content

Commit 7f08409

Browse files
committed
Day 1. Basic stuff
1 parent 0ce770a commit 7f08409

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

main.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
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)

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
pyTelegramBotAPI~=4.10.0
2+
python-dotenv~=1.0.0

0 commit comments

Comments
 (0)