-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
aae6fd9
commit f9d8ab9
Showing
1 changed file
with
40 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
from typing import Text | ||
import telebot | ||
import time | ||
bot_token='2015065858:AAEcP14C5MKLEuoc9K4AZxqEJpjFAqwXi2k' | ||
|
||
bot = telebot.TeleBot(token = bot_token) | ||
|
||
def findat(msg): | ||
# from a list of texts, it finds the one with the '@' sign | ||
for i in msg: | ||
if '@' in i: | ||
return i | ||
|
||
@bot.message_handler(commands=['Greet']) | ||
def send_welcome(message): | ||
bot.reply_to(message,'welcome') | ||
|
||
|
||
@bot.message_handler(commands=['Hello']) | ||
def hello(message): | ||
bot.send_message(message.chat.id,'Hey,How are You??') | ||
|
||
@bot.message_handler(commands=['PEC']) | ||
def celeb(message): | ||
bot.reply_to(message,'Celebrating 100 years') | ||
|
||
@bot.message_handler(func=lambda msg: msg.text is not None and '@' in msg.text) | ||
def at_answer(message): | ||
texts=message.text.split() | ||
at_text=findat(texts) | ||
|
||
if at_text == '@': # in case it's just the '@', skip | ||
pass | ||
else: | ||
insta_link = "https://instagram.com/{}".format(at_text[1:]) | ||
bot.reply_to(message, insta_link) | ||
|
||
bot.polling() | ||
|
||
|