forked from adam/discord-bot-shtik
more failure-tolerance
This commit is contained in:
parent
ac1e0c6ba2
commit
08f39f257f
24
Program.cs
24
Program.cs
@ -127,25 +127,41 @@ namespace silverworker_discord
|
|||||||
{
|
{
|
||||||
if (link.Host == "vm.tiktok.com")
|
if (link.Host == "vm.tiktok.com")
|
||||||
{
|
{
|
||||||
detiktokify(link, message.Channel);
|
detiktokify(link, message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private async void detiktokify(Uri link, ISocketMessageChannel channel)
|
private async void detiktokify(Uri link, SocketUserMessage message)
|
||||||
{
|
{
|
||||||
var ytdl = new YoutubeDLSharp.YoutubeDL();
|
var ytdl = new YoutubeDLSharp.YoutubeDL();
|
||||||
ytdl.YoutubeDLPath = config["ytdl"];
|
ytdl.YoutubeDLPath = "youtube-dl";
|
||||||
ytdl.FFmpegPath = "ffmpeg";
|
ytdl.FFmpegPath = "ffmpeg";
|
||||||
ytdl.OutputFolder = "";
|
ytdl.OutputFolder = "";
|
||||||
ytdl.OutputFileTemplate = "tiktokbad.%(ext)s";
|
ytdl.OutputFileTemplate = "tiktokbad.%(ext)s";
|
||||||
var res = await ytdl.RunVideoDownload(link.ToString());
|
var res = await ytdl.RunVideoDownload(link.ToString());
|
||||||
|
if(!res.Success)
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("tried to dl, failed. \n" + res.ErrorOutput);
|
||||||
|
message.AddReactionAsync(new Emoji("👎"));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
string path = res.Data;
|
string path = res.Data;
|
||||||
await channel.SendFileAsync(path);
|
if(File.Exists(path))
|
||||||
|
{
|
||||||
|
await message.Channel.SendFileAsync(path);
|
||||||
File.Delete(path);
|
File.Delete(path);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Console.Error.WriteLine("idgi but something happened.");
|
||||||
|
message.AddReactionAsync(new Emoji("👎"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
private Task UserJoined(SocketGuildUser arg)
|
private Task UserJoined(SocketGuildUser arg)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"user joined: {arg.Nickname}. Guid: {arg.Guild.Id}. Channel: {arg.Guild.DefaultChannel}");
|
Console.WriteLine($"user joined: {arg.Nickname}. Guid: {arg.Guild.Id}. Channel: {arg.Guild.DefaultChannel}");
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
{
|
{
|
||||||
"token": "59 chars",
|
"token": "59 chars",
|
||||||
"botChatterChannel": 0,
|
"botChatterChannel": 0,
|
||||||
"announcementChannel": 0,
|
"announcementChannel": 0
|
||||||
"ytdl": "youtube-dl"
|
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user