Bienvenido a nuestro sitio, aquí encontrarás la resolución a lo que estás buscando.
Ejemplo: secuencia de comandos de youtube de notificación de bot de discord.py
import discord
import time
import asyncio
import sys
from Implementation import YouTuber
from config import Config
config = Config('config.yml')
client = discord.Client()
youtubers = config.getYouTubersList()if(config.getYouTubersNr()!=0)else sys.exit()if(config.getDiscordChannelNr()==0): sys.exit()id=''
GOOGLE_API = config.getConnectionData()[0]
pingEveryXMinutes = config.getPingTime()
threads =[]
processes =[]
i =0while i < config.getYouTubersNr():
temp_list =[]
temp_list.append(config.getYouTubersList()[i]['name'])
temp_list.append(id)ifnot config.getYouTubersList()[i]['channelID']else temp_list.append(config.getYouTubersList()[i]['channelID'])
temp_list.append(True)ifnotidelse temp_list.append(False)
temp_list.append('')
threads.append(temp_list)
i +=1
i =0while i < config.getYouTubersNr():
processes.append(YouTuber(GOOGLE_API, threads[i][1], threads[i][2]))
i +=1asyncdefupdate():whileTrue:try:
waittime = pingEveryXMinutes *60
item =0while item < config.getYouTubersNr():
data = processes[item].update()print('Checking for new videos from '.format(threads[item][0]))if processes[item].isNewVideo():print(' HAS UPLOADED A NEW VIDEO! PUSHING UPDATE ON DISCORD.'.format(threads[item][0]))for x inrange(0, config.getDiscordChannelNr()):
newvideo = config.getDiscordChannelList()[x]['New video'].format(threads[item][0])+'n'.format(processes[item].getVideoLink(processes[item].videosData[0][1]))await client.send_message(client.get_channel(str(config.getDiscordChannelList()[x]['channelID'])), newvideo)if processes[item].isUserLive():ifnot processes[item].liveId == threads[item][3]:print(' IS LIVESTREAMING NOW! PUSHING UPDATE ON DISCORD.'.format(threads[item][0]))
threads[item][3]= processes[item].liveId
for x inrange(0, config.getDiscordChannelNr()):
livestream = config.getDiscordChannelList()[x]['Livestream'].format(threads[item][0])+'n'.format(processes[item].getVideoLink(processes[item].getUserLiveData()))await client.send_message(client.get_channel(str(config.getDiscordChannelList()[x]['channelID'])), livestream)
item +=1except:passwhile waittime >0:
mins, secs =divmod(waittime,60)
timeformat =':02d::02d'.format(mins, secs)
sys.stdout.write('Rechecking in '+str(timeformat)+'r')
waittime -=1await asyncio.sleep(1)@client.eventasyncdefon_ready():print('Logged in as:')print(client.user.name)print(client.user.id)print('---------------------------------------')print('Bot running.')
asyncio.ensure_future(update())
client.run(config.getConnectionData()[1])
valoraciones y reseñas
Si guardas alguna cuestión y disposición de aumentar nuestro reseña puedes escribir una nota y con placer lo ojearemos.
¡Haz clic para puntuar esta entrada!
(Votos: 0 Promedio: 0)