import os
import youtube_dl
import telepotpro
from random import randint
from multiprocessing import Process
from youtubesearchpython import VideosSearch
from dotenv import load_dotenv
from os.path import join, dirname

dotenv_path = join(dirname(__file__), '.env')
load_dotenv(dotenv_path)

TOKEN = os.environ.get("TOKEN")
bot = telepotpro.Bot(TOKEN)


class Music:
    def __init__(self, user_input, msg):
        self.chat = Chat
        self.user_input = user_input[6:]

    def search_music(self, user_input):
        return VideosSearch(user_input, limit=1).result()

    def get_link(self, result):
        return result['result'][0]['link']

    def get_title(self, result):
        return result['result'][0]['title']

    def get_duration(self, result):
Example #2
0
import os
import sys
import json
import youtube_dl
import telepotpro
from random import randint
from multiprocessing import Process
from youtubesearchpython import SearchVideos

bot = telepotpro.Bot("API_TOKEN")


def startMsg(chat_id, first_name):
    bot.sendMessage(chat_id,
                    '🤖 Hello, ' + first_name + '!\n\n'
                    '📩 Send me:\n\n'
                    '"*/music* _song name_"  or\n'
                    '"*/music* _musician name - song name_"\n\n'
                    'to order some music. 🎶',
                    parse_mode='Markdown')


def errorMsg(chat_id, error_type):
    if error_type == 'too_long':
        bot.sendMessage(chat_id, '‼️ *Oops! Video too long to convert!*\n'
                        'Order something 30 minutes or less.',
                        parse_mode='Markdown')

    if error_type == 'spotify_command':
        bot.sendMessage(chat_id,
                        "‼️ *Oops! The bot doesn't support Spotify links!*\n"
import os
import sys
import json
import youtube_dl
import telepotpro
from random import randint
from multiprocessing import Process
from youtubesearchpython import SearchVideos

bot = telepotpro.Bot("1158344275:AAGQCCNWHGyHo1a-MLk-MnxMXeq1R-6xGYw")


def startMsg(chat_id, first_name):
    bot.sendMessage(chat_id,
                    'Hey, 💓' + first_name + '💓\n'
                    'I am a Music Downloader bot\n'
                    '*My* _commands available are_\n'
                    '*/find* _song name_ or\n'
                    '*/find* _musician name - song name_\n\n'
                    'And I will try my best to get your music \n'
                    '🎶🎶🎶🎶🎶🎶🎶',
                    parse_mode='Markdown')


def errorMsg(chat_id, error_type):
    if error_type == 'too_long':
        bot.sendMessage(chat_id, 'Sorry! The video too is long to convert!\n'
                        'Order something 30 minutes or less.',
                        parse_mode='Markdown')

    if error_type == 'spotify_command':
Example #4
0
import telepotpro
from multiprocessing import Process
import crawller
import contaPalavras

bot = telepotpro.Bot("YOUR_TOKEN")

def startMsg(chat_id):
	bot.sendMessage(chat_id, '🤖 Hello')

def errorMsg(chat_id, error_type):
	if error_type == 'invalid_command':
		bot.sendMessage(chat_id, '*Oops! Invalid command!')


def validInput(userInput, chat_id):
    userInput = userInput[6:].split()
    print(userInput)

    SITES_TEXTOS = crawller.pegar_texto_dos_sites_google(userInput)

    for site_texto in SITES_TEXTOS:
        Nome_site = site_texto['site']
        Texto_do_site = site_texto['texto']
        print(site_texto['site'], '\n', site_texto['texto'])

    #bot.sendMessage(chat_id, 'em ', len(SITES_TEXTOS) ,' foram encontradas ', contaPalavras.contar(site_texto['texto'], userInput), ' palavras referentes ao assunto, resultando em ', (100*contaPalavras.contar(site_texto['texto'], userInput))/len(SITES_TEXTOS), ' "%" de sites que mencionaram o assunto')


def recebendoMsg(msg):
	userInput = msg['text']
Example #5
0
File: tele.py Project: kalyevb/beka
import os
import sys
import json
import youtube_dl
import telepotpro
from random import randint
from multiprocessing import Process
from youtubesearchpython import SearchVideos
from datetime import datetime

bot = telepotpro.Bot("1544498260:AAGg6Chm_35MatLh1tM3qu7N6jpuYaUTwxQ")


def startMsg(chat_id, first_name, message):
    bot.sendMessage(chat_id,
                    'Привет, ' + first_name + '!\n\n'
                    'Напиши:\n\n'
                    '"*/m* Название песни"  or\n'
                    '"*/m* Название автора,название песни"\n\n'
                    'И я скачаю тебе ее. 🎶',
                    parse_mode='Markdown')
    save_info_mp4(message)


def errorMsg(chat_id, error_type):
    if error_type == 'too_long':
        bot.sendMessage(chat_id,
                        '‼️ *Ой! Слишком длинное видео для скачивания!*\n'
                        'Закажи что-нибудь не более 30 минут.',
                        parse_mode='Markdown')
Example #6
0
import os
import sys
import json
import youtube_dl
import telepotpro
from info import token, sudo_channel, sudo_username
from random import randint
from multiprocessing import Process
from youtubesearchpython import SearchVideos

bot = telepotpro.Bot("1604318595:AAHj1rkg60SW_cbsA8t7TwDyYPxas2stAso")


def create_keyboard(yt):
    buttons = []
    keyboard = telepotpro.types.InlineKeyboardMarkup(row_width=1)
    i = 0
    for stream in yt.streams.filter(progressive='True'):
        typ = str(stream).split(' ')[2].split('=')[1][1:-1]
        quality = str(stream).split(' ')[3].split('=')[1][1:-1]

        text_but = 'تحميل'
        buttons.append(
            telepotpro.types.InlineKeyboardButton(text=text_but,
                                                  callback_data=str(i)))
        i += 1
    keyboard.add(*buttons)
    return keyboard


url = f"https://api.telegram.org/bot{token}/getChat?chat_id=@{sudo_channel}"
import os
import sys
import json
import youtube_dl
import telepotpro
from random import randint
from multiprocessing import Process
from youtubesearchpython import SearchVideos

bot = telepotpro.Bot("1342819762:AAFP2To2fqaSERFyj67phE37eCezy4CukT4")


def startMsg(chat_id, first_name):
    bot.sendMessage(chat_id,
                    '🤖 Hello, ' + first_name + '!\n\n'
                    '📩 Send me:\n\n'
                    '"*/music* _song name_"  or\n'
                    '"*/music* _musician name - song name_"\n\n'
                    'to order some music. 🎶',
                    parse_mode='Markdown')


def errorMsg(chat_id, error_type):
    if error_type == 'too_long':
        bot.sendMessage(chat_id, '‼️ *Oops! Video too long to convert!*\n'
                        'Order something 30 minutes or less.',
                        parse_mode='Markdown')

    if error_type == 'spotify_command':
        bot.sendMessage(chat_id,
                        "‼️ *Oops! The bot doesn't support Spotify links!*\n"
Example #8
0
import os
import sys
import json
import youtube_dl
import telepotpro
from random import randint
from multiprocessing import Process
from youtubesearchpython import SearchVideos

bot = telepotpro.Bot("1458562036:AAH8hVqrIByvF5nB5VqIqJoNflgLfriPPIk")


def startMsg(chat_id, first_name):
    bot.sendMessage(chat_id,
                    '🤖 Hello, ' + first_name + '!\n\n'
                    '📩 Send me:\n\n'
                    '"*/music* _song name_"  or\n'
                    '"*/music* _musician name - song name_"\n\n'
                    'to order some music. 🎶',
                    parse_mode='Markdown')


def errorMsg(chat_id, error_type):
    if error_type == 'too_long':
        bot.sendMessage(chat_id, '‼️ *Oops! Video too long to convert!*\n'
                        'Order something 30 minutes or less.',
                        parse_mode='Markdown')

    if error_type == 'spotify_command':
        bot.sendMessage(chat_id,
                        "‼️ *Oops! The bot doesn't support Spotify links!*\n"
import os
import sys
import json
import youtube_dl
import telepotpro
from random import randint
from multiprocessing import Process
from youtubesearchpython import SearchVideos


bot = telepotpro.Bot("1420162191:AAH2dY-RMIJD0R_6hGYMZ3PaGwAa7dikDLs")

def startMsg(chat_id, first_name):
	bot.sendMessage(chat_id, '🤖 Hello, '+ first_name +'!\n\n'
	'📩 Send me:\n\n'
	'"*/music* _song name_"  or\n'
	'"*/music* _musician name - song name_"\n\n'
	'to order some music 🎶', parse_mode= 'Markdown')
        'JOIN OUR OFFICAL CHANNEL:T.me/YTAudio_Channel'.
def errorMsg(chat_id, error_type):
	if error_type == 'too_long':
		bot.sendMessage(chat_id, '‼️ *Oops! Video too long to convert!*\n'
			'Order something 30 minutes or less.', parse_mode= 'Markdown')

	if error_type == 'spotify_command':
		bot.sendMessage(chat_id, "‼️ *Oops! The bot doesn't support Spotify links!*\n"
			'Try: "*/music* _song name_"\n'
			'or: "*/music* _musician name - song name_"', parse_mode= 'Markdown')

	if error_type == 'invalid_command':
		bot.sendMessage(chat_id, '‼️ *Oops! Invalid command!*\n'
Example #10
0
import os
import json
import telepotpro
import youtube_dl
from random import randint
from youtubesearchpython import SearchVideos
from multiprocessing import Process

bot = telepotpro.Bot("1690696524:AAH1pfx5ikQCm7DMr3fA-hX5uPOZyg5GVtQ")


class Chat:
    def __init__(self, chat_id, text, msg):
        self.msg = msg

        self.commands = {
            '/start': self.start,
            '/music': self.music,
            'error': self.error
        }
        self.chat_id = chat_id

        self.command, self.body_command = self.__getCommandAndBodyOfMsg(text)
        self.valideCommand()
        self.answer()
        pass

    def answer(self):
        self.__responseCommand()
        pass