-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot.py
26 lines (24 loc) · 1.18 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import os
import requests
from pyrogram import filters
from main import get_text , get_url_song
from config import bot
@bot.on_message(filters.command('start'))
def text_1(bot , message):
bot.send_message(message.chat.id,f'Привет {message.from_user.first_name}! \n Я бот помогающий искать текст песен! \n Вбивай любую песнь в формате /search (название) и получай текст!')
@bot.on_message(filters.command('search'))
def search(bot , message):
try:
text = ' '.join(message.text.split()[1:])
print(text)
bot.send_message(message.chat.id,f'Ищу текст твоей песни!')
url = get_url_song(text)
result = get_text(text,url)
if result:
bot.send_document(message.chat.id, f"{text}.txt", caption="Держи текст песни!")
else:
bot.send_message(message.chat.id,"Не удалось достать текст!")
os.remove(f"{text}.txt")
except IndexError :
bot.send_message(message.chat.id,"А какую именно песню? Тут не написано какая")
bot.run()