-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
222 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
using Newtonsoft.Json; | ||
using System.IO; | ||
|
||
namespace DracosBot | ||
{ | ||
internal static class Information | ||
{ | ||
internal static Config Config => JsonConvert.DeserializeObject<Config>(File.ReadAllText("config.json")); | ||
|
||
internal static string ClientId => Config.ClientId; | ||
internal static string ClientSecret => Config.ClientSecret; | ||
internal static string BotName => Config.BotName; | ||
internal static string Token => Config.Token; | ||
internal static string ServerName => Config.ServerName; | ||
internal static string TextChannelName => Config.TextChannelName; | ||
internal static string VoiceChannelName => Config.VoiceChannelName; | ||
} | ||
|
||
public class Config | ||
{ | ||
public string ClientId = "YourClientID"; | ||
public string ClientSecret = "YourClientSecret"; | ||
public string BotName = "YourBotName"; | ||
public string Token = "YourBotToken"; | ||
public string ServerName = "TheServerYouWantToConnectTo"; | ||
public string TextChannelName = "TheTextChannelYouWantToJoin"; | ||
public string VoiceChannelName = "TheVoiceChannelYouWantToJoin"; | ||
|
||
public static bool operator ==(Config cfg1, Config cfg2) | ||
{ | ||
return ReferenceEquals(cfg1, null) ? ReferenceEquals(cfg2, null) : cfg1.Equals(cfg2); | ||
} | ||
|
||
public static bool operator !=(Config cfg1, Config cfg2) | ||
{ | ||
return !ReferenceEquals(cfg1, null) ? !ReferenceEquals(cfg2, null) : !cfg1.Equals(cfg2); | ||
} | ||
|
||
public bool Equals(Config compare) | ||
{ | ||
if (compare == null) | ||
return false; | ||
|
||
return | ||
ClientId == compare.ClientId && | ||
ClientSecret == compare.ClientSecret && | ||
BotName == compare.BotName && | ||
Token == compare.Token && | ||
ServerName == compare.ServerName && | ||
TextChannelName == compare.TextChannelName && | ||
VoiceChannelName == compare.VoiceChannelName; | ||
} | ||
|
||
public override bool Equals(object obj) | ||
{ | ||
return Equals(obj as Config); | ||
} | ||
|
||
public override int GetHashCode() | ||
{ | ||
return (ClientId + ClientSecret + BotName + Token + ServerName + TextChannelName + VoiceChannelName).GetHashCode(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Discord; | ||
using Discord.Audio; | ||
using Discord.WebSocket; | ||
using Discord.Rest; | ||
namespace DracosBot | ||
{ | ||
internal class YoutubeCommand : Program | ||
{ | ||
private DiscordSocketClient _clientThis; | ||
private IVoiceChannel _voiceChannel; | ||
private ITextChannel _textChannel; | ||
private TaskCompletionSource<bool> _tsc; | ||
private IAudioClient _audio; | ||
private CancellationTokenSource _disposeToken; | ||
private Queue<Tuple<string, string, string, string>> _queue; | ||
|
||
public static string[] command = { "!youtube" }; | ||
|
||
|
||
|
||
/// <summary> | ||
/// Tuple(FilePath, Video Name, Duration, Requested by) | ||
/// </summary> | ||
private bool Pause | ||
{ | ||
get => _internal_Pause; | ||
set | ||
{ | ||
new Thread(() => _tsc.TrySetResult(value)).Start(); | ||
_internal_Pause = value; | ||
} | ||
} | ||
private bool _internal_Pause; | ||
private bool Skip | ||
{ | ||
get | ||
{ | ||
bool ret = _internal_Skip; | ||
_internal_Skip = false; | ||
return ret; | ||
} | ||
set => _internal_Skip = value; | ||
} | ||
private bool _internal_Skip; | ||
|
||
public bool isDisposed; | ||
|
||
public YoutubeCommand() | ||
{ | ||
Initialize(); | ||
} | ||
public async void Initialize() | ||
{ | ||
_queue = new Queue<Tuple<string, string, string, string>>(); | ||
_tsc = new TaskCompletionSource<bool>(); | ||
_disposeToken = new CancellationTokenSource(); | ||
_clientThis = _client; | ||
} | ||
|
||
} | ||
} |