Skip to content

Commit

Permalink
creating bot
Browse files Browse the repository at this point in the history
  • Loading branch information
singla16shubham committed Nov 3, 2021
1 parent aae6fd9 commit f9d8ab9
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions main.py
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()


0 comments on commit f9d8ab9

Please sign in to comment.