Some replacements, osu commands converted
This commit is contained in:
parent
5e4628ec10
commit
4317e97113
@ -115,13 +115,13 @@ namespace NadekoBot
|
|||||||
HttpClient carbonClient = new HttpClient();
|
HttpClient carbonClient = new HttpClient();
|
||||||
private async Task SendUpdateToCarbon()
|
private async Task SendUpdateToCarbon()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.CarbonKey))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.CarbonKey))
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
using (var content = new FormUrlEncodedContent(new Dictionary<string, string> {
|
using (var content = new FormUrlEncodedContent(new Dictionary<string, string> {
|
||||||
{ "servercount", NadekoBot.Client.Servers.Count().ToString() },
|
{ "servercount", NadekoBot.Client.Servers.Count().ToString() },
|
||||||
{ "key", NadekoBot.Creds.CarbonKey }
|
{ "key", NadekoBot.Credentials.CarbonKey }
|
||||||
}))
|
}))
|
||||||
{
|
{
|
||||||
content.Headers.Clear();
|
content.Headers.Clear();
|
||||||
@ -155,7 +155,7 @@ namespace NadekoBot
|
|||||||
sb.AppendLine($"`Bot Version: {BotVersion}`");
|
sb.AppendLine($"`Bot Version: {BotVersion}`");
|
||||||
sb.AppendLine($"`Bot id: {NadekoBot.Client.CurrentUser.Id}`");
|
sb.AppendLine($"`Bot id: {NadekoBot.Client.CurrentUser.Id}`");
|
||||||
sb.Append("`Owners' Ids:` ");
|
sb.Append("`Owners' Ids:` ");
|
||||||
sb.AppendLine("`" + String.Join(", ", NadekoBot.Creds.OwnerIds) + "`");
|
sb.AppendLine("`" + String.Join(", ", NadekoBot.Credentials.OwnerIds) + "`");
|
||||||
sb.AppendLine($"`Uptime: {GetUptimeString()}`");
|
sb.AppendLine($"`Uptime: {GetUptimeString()}`");
|
||||||
sb.Append($"`Servers: {ServerCount}");
|
sb.Append($"`Servers: {ServerCount}");
|
||||||
sb.Append($" | TextChannels: {TextChannelsCount}");
|
sb.Append($" | TextChannels: {TextChannelsCount}");
|
||||||
|
@ -147,14 +147,14 @@ namespace NadekoBot.Classes
|
|||||||
return $"https://www.youtube.com/watch?v={match.Groups["id"].Value}";
|
return $"https://www.youtube.com/watch?v={match.Groups["id"].Value}";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.GoogleAPIKey))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.GoogleAPIKey))
|
||||||
throw new InvalidCredentialException("Google API Key is missing.");
|
throw new InvalidCredentialException("Google API Key is missing.");
|
||||||
|
|
||||||
var response = await GetResponseStringAsync(
|
var response = await GetResponseStringAsync(
|
||||||
$"https://www.googleapis.com/youtube/v3/search?" +
|
$"https://www.googleapis.com/youtube/v3/search?" +
|
||||||
$"part=snippet&maxResults=1" +
|
$"part=snippet&maxResults=1" +
|
||||||
$"&q={Uri.EscapeDataString(keywords)}" +
|
$"&q={Uri.EscapeDataString(keywords)}" +
|
||||||
$"&key={NadekoBot.Creds.GoogleAPIKey}").ConfigureAwait(false);
|
$"&key={NadekoBot.Credentials.GoogleAPIKey}").ConfigureAwait(false);
|
||||||
JObject obj = JObject.Parse(response);
|
JObject obj = JObject.Parse(response);
|
||||||
|
|
||||||
var data = JsonConvert.DeserializeObject<YoutubeVideoSearch>(response);
|
var data = JsonConvert.DeserializeObject<YoutubeVideoSearch>(response);
|
||||||
@ -181,7 +181,7 @@ namespace NadekoBot.Classes
|
|||||||
$"https://www.googleapis.com/youtube/v3/search?" +
|
$"https://www.googleapis.com/youtube/v3/search?" +
|
||||||
$"part=snippet&maxResults={count}&type=video" +
|
$"part=snippet&maxResults={count}&type=video" +
|
||||||
$"&relatedToVideoId={id}" +
|
$"&relatedToVideoId={id}" +
|
||||||
$"&key={NadekoBot.Creds.GoogleAPIKey}").ConfigureAwait(false);
|
$"&key={NadekoBot.Credentials.GoogleAPIKey}").ConfigureAwait(false);
|
||||||
JObject obj = JObject.Parse(response);
|
JObject obj = JObject.Parse(response);
|
||||||
|
|
||||||
var data = JsonConvert.DeserializeObject<YoutubeVideoSearch>(response);
|
var data = JsonConvert.DeserializeObject<YoutubeVideoSearch>(response);
|
||||||
@ -191,7 +191,7 @@ namespace NadekoBot.Classes
|
|||||||
|
|
||||||
public static async Task<string> GetPlaylistIdByKeyword(string query)
|
public static async Task<string> GetPlaylistIdByKeyword(string query)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.GoogleAPIKey))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.GoogleAPIKey))
|
||||||
throw new ArgumentNullException(nameof(query));
|
throw new ArgumentNullException(nameof(query));
|
||||||
var match = new Regex("(?:youtu\\.be\\/|list=)(?<id>[\\da-zA-Z\\-_]*)").Match(query);
|
var match = new Regex("(?:youtu\\.be\\/|list=)(?<id>[\\da-zA-Z\\-_]*)").Match(query);
|
||||||
if (match.Length > 1)
|
if (match.Length > 1)
|
||||||
@ -201,7 +201,7 @@ namespace NadekoBot.Classes
|
|||||||
var link = "https://www.googleapis.com/youtube/v3/search?part=snippet" +
|
var link = "https://www.googleapis.com/youtube/v3/search?part=snippet" +
|
||||||
"&maxResults=1&type=playlist" +
|
"&maxResults=1&type=playlist" +
|
||||||
$"&q={Uri.EscapeDataString(query)}" +
|
$"&q={Uri.EscapeDataString(query)}" +
|
||||||
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
$"&key={NadekoBot.Credentials.GoogleAPIKey}";
|
||||||
|
|
||||||
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
||||||
var data = JsonConvert.DeserializeObject<YoutubePlaylistSearch>(response);
|
var data = JsonConvert.DeserializeObject<YoutubePlaylistSearch>(response);
|
||||||
@ -212,7 +212,7 @@ namespace NadekoBot.Classes
|
|||||||
|
|
||||||
public static async Task<IList<string>> GetVideoIDs(string playlist, int number = 50)
|
public static async Task<IList<string>> GetVideoIDs(string playlist, int number = 50)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.GoogleAPIKey))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.GoogleAPIKey))
|
||||||
{
|
{
|
||||||
throw new ArgumentNullException(nameof(playlist));
|
throw new ArgumentNullException(nameof(playlist));
|
||||||
}
|
}
|
||||||
@ -231,7 +231,7 @@ namespace NadekoBot.Classes
|
|||||||
$"https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails" +
|
$"https://www.googleapis.com/youtube/v3/playlistItems?part=contentDetails" +
|
||||||
$"&maxResults={toGet}" +
|
$"&maxResults={toGet}" +
|
||||||
$"&playlistId={playlist}" +
|
$"&playlistId={playlist}" +
|
||||||
$"&key={NadekoBot.Creds.GoogleAPIKey}";
|
$"&key={NadekoBot.Credentials.GoogleAPIKey}";
|
||||||
if (!string.IsNullOrWhiteSpace(nextPageToken))
|
if (!string.IsNullOrWhiteSpace(nextPageToken))
|
||||||
link += $"&pageToken={nextPageToken}";
|
link += $"&pageToken={nextPageToken}";
|
||||||
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
var response = await GetResponseStringAsync(link).ConfigureAwait(false);
|
||||||
@ -245,12 +245,12 @@ namespace NadekoBot.Classes
|
|||||||
|
|
||||||
public static async Task<string> ShortenUrl(string url)
|
public static async Task<string> ShortenUrl(string url)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.GoogleAPIKey)) return url;
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.GoogleAPIKey)) return url;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var httpWebRequest =
|
var httpWebRequest =
|
||||||
(HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" +
|
(HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" +
|
||||||
NadekoBot.Creds.GoogleAPIKey);
|
NadekoBot.Credentials.GoogleAPIKey);
|
||||||
httpWebRequest.ContentType = "application/json";
|
httpWebRequest.ContentType = "application/json";
|
||||||
httpWebRequest.Method = "POST";
|
httpWebRequest.Method = "POST";
|
||||||
|
|
||||||
|
@ -494,10 +494,10 @@ namespace NadekoBot.Modules.Administration
|
|||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as ITextChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// if (string.IsNullOrWhiteSpace(e.GetArg("img")))
|
// if (string.IsNullOrWhiteSpace(img))
|
||||||
// return;
|
// return;
|
||||||
// // Gather user provided URL.
|
// // Gather user provided URL.
|
||||||
// var avatarAddress = e.GetArg("img");
|
// var avatarAddress = img;
|
||||||
// var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
|
// var imageStream = await SearchHelper.GetResponseStreamAsync(avatarAddress).ConfigureAwait(false);
|
||||||
// var image = System.Drawing.Image.FromStream(imageStream);
|
// var image = System.Drawing.Image.FromStream(imageStream);
|
||||||
// await client.CurrentUser.Edit("", avatar: image.ToStream()).ConfigureAwait(false);
|
// await client.CurrentUser.Edit("", avatar: image.ToStream()).ConfigureAwait(false);
|
||||||
@ -515,7 +515,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
|
|
||||||
// game = game ?? "";
|
// game = game ?? "";
|
||||||
|
|
||||||
// client.SetGame(e.GetArg("set_game"));
|
// client.SetGame(set_game);
|
||||||
//}
|
//}
|
||||||
|
|
||||||
////todo owner only
|
////todo owner only
|
||||||
@ -570,8 +570,8 @@ namespace NadekoBot.Modules.Administration
|
|||||||
//public async Task Donadd(IMessage imsg, IUser donator, int amount)
|
//public async Task Donadd(IMessage imsg, IUser donator, int amount)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as ITextChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
// var donator = channel.Guild.FindUsers(e.GetArg("donator")).FirstOrDefault();
|
// var donator = channel.Guild.FindUsers(donator).FirstOrDefault();
|
||||||
// var amount = int.Parse(e.GetArg("amount"));
|
// var amount = int.Parse(amount);
|
||||||
// if (donator == null) return;
|
// if (donator == null) return;
|
||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
|
@ -86,7 +86,7 @@
|
|||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// int token;
|
// int token;
|
||||||
// if (!int.TryParse(e.GetArg("token"), out token))
|
// if (!int.TryParse(token, out token))
|
||||||
// return;
|
// return;
|
||||||
// HashSet<Channel> set;
|
// HashSet<Channel> set;
|
||||||
// if (!Subscribers.TryGetValue(token, out set))
|
// if (!Subscribers.TryGetValue(token, out set))
|
||||||
|
@ -456,7 +456,7 @@
|
|||||||
// {
|
// {
|
||||||
|
|
||||||
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
// var config = SpecificConfigurations.Default.Of(e.Server.Id);
|
||||||
// if (e.GetArg("all")?.ToLower() == "all")
|
// if (all?.ToLower() == "all")
|
||||||
// {
|
// {
|
||||||
// foreach (var voiceChannel in e.Server.VoiceChannels)
|
// foreach (var voiceChannel in e.Server.VoiceChannels)
|
||||||
// {
|
// {
|
||||||
|
@ -80,8 +80,8 @@
|
|||||||
// .AddCheck(SimpleCheckers.ManageMessages())
|
// .AddCheck(SimpleCheckers.ManageMessages())
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var minutesStr = e.GetArg("minutes");
|
// var minutesStr = minutes;
|
||||||
// var msg = e.GetArg("msg");
|
// var msg = msg;
|
||||||
|
|
||||||
// // if both null, disable
|
// // if both null, disable
|
||||||
// if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
// if (string.IsNullOrWhiteSpace(msg) && string.IsNullOrWhiteSpace(minutesStr))
|
||||||
|
@ -109,7 +109,7 @@
|
|||||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var arg = e.GetArg("text");
|
// var arg = text;
|
||||||
// if (string.IsNullOrWhiteSpace(arg))
|
// if (string.IsNullOrWhiteSpace(arg))
|
||||||
// return;
|
// return;
|
||||||
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||||
@ -149,7 +149,7 @@
|
|||||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var arg = e.GetArg("number");
|
// var arg = number;
|
||||||
// int num;
|
// int num;
|
||||||
// string str;
|
// string str;
|
||||||
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
// await playingPlaceholderLock.WaitAsync().ConfigureAwait(false);
|
||||||
|
@ -49,7 +49,7 @@
|
|||||||
// .AddCheck(SimpleCheckers.CanManageRoles)
|
// .AddCheck(SimpleCheckers.CanManageRoles)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var roleName = e.GetArg("role")?.Trim();
|
// var roleName = role?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(roleName))
|
// if (string.IsNullOrWhiteSpace(roleName))
|
||||||
// return;
|
// return;
|
||||||
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
@ -116,7 +116,7 @@
|
|||||||
// .Parameter("role", ParameterType.Unparsed)
|
// .Parameter("role", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var roleName = e.GetArg("role")?.Trim();
|
// var roleName = role?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(roleName))
|
// if (string.IsNullOrWhiteSpace(roleName))
|
||||||
// return;
|
// return;
|
||||||
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
@ -172,7 +172,7 @@
|
|||||||
// .Parameter("role", ParameterType.Unparsed)
|
// .Parameter("role", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var roleName = e.GetArg("role")?.Trim();
|
// var roleName = role?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(roleName))
|
// if (string.IsNullOrWhiteSpace(roleName))
|
||||||
// return;
|
// return;
|
||||||
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
// var role = e.Server.FindRoles(roleName).FirstOrDefault();
|
||||||
|
@ -240,14 +240,14 @@
|
|||||||
// {
|
// {
|
||||||
// if (!imsg.Author.ServerPermissions.ManageServer) return;
|
// if (!imsg.Author.ServerPermissions.ManageServer) return;
|
||||||
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
// if (string.IsNullOrWhiteSpace(msg))
|
||||||
// {
|
// {
|
||||||
// await channel.SendMessageAsync("`Current greet message:` " + ann.GreetText);
|
// await channel.SendMessageAsync("`Current greet message:` " + ann.GreetText);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
|
||||||
// ann.GreetText = e.GetArg("msg");
|
// ann.GreetText = msg;
|
||||||
// await channel.SendMessageAsync("New greet message set.").ConfigureAwait(false);
|
// await channel.SendMessageAsync("New greet message set.").ConfigureAwait(false);
|
||||||
// if (!ann.Greet)
|
// if (!ann.Greet)
|
||||||
// await channel.SendMessageAsync("Enable greet messsages by typing `.greet`").ConfigureAwait(false);
|
// await channel.SendMessageAsync("Enable greet messsages by typing `.greet`").ConfigureAwait(false);
|
||||||
@ -273,13 +273,13 @@
|
|||||||
// {
|
// {
|
||||||
// if (!imsg.Author.ServerPermissions.ManageServer) return;
|
// if (!imsg.Author.ServerPermissions.ManageServer) return;
|
||||||
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
// var ann = AnnouncementsDictionary.GetOrAdd(e.Server.Id, new AnnounceControls(e.Server.Id));
|
||||||
// if (string.IsNullOrWhiteSpace(e.GetArg("msg")))
|
// if (string.IsNullOrWhiteSpace(msg))
|
||||||
// {
|
// {
|
||||||
// await channel.SendMessageAsync("`Current bye message:` " + ann.ByeText);
|
// await channel.SendMessageAsync("`Current bye message:` " + ann.ByeText);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// ann.ByeText = e.GetArg("msg");
|
// ann.ByeText = msg;
|
||||||
// await channel.SendMessageAsync("New bye message set.").ConfigureAwait(false);
|
// await channel.SendMessageAsync("New bye message set.").ConfigureAwait(false);
|
||||||
// if (!ann.Bye)
|
// if (!ann.Bye)
|
||||||
// await channel.SendMessageAsync("Enable bye messsages by typing `.bye`.").ConfigureAwait(false);
|
// await channel.SendMessageAsync("Enable bye messsages by typing `.bye`.").ConfigureAwait(false);
|
||||||
|
@ -53,7 +53,7 @@
|
|||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// var num = 1;
|
// var num = 1;
|
||||||
// var isParsed = int.TryParse(e.GetArg("count"), out num);
|
// var isParsed = int.TryParse(count, out num);
|
||||||
// if (!isParsed || num < 2)
|
// if (!isParsed || num < 2)
|
||||||
// {
|
// {
|
||||||
// var c = cards.DrawACard();
|
// var c = cards.DrawACard();
|
||||||
|
@ -34,9 +34,9 @@
|
|||||||
// public Func<CommandEventArgs, Task> BetFlipCoinFunc() => async e =>
|
// public Func<CommandEventArgs, Task> BetFlipCoinFunc() => async e =>
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// var amountstr = e.GetArg("amount").Trim();
|
// var amountstr = amount.Trim();
|
||||||
|
|
||||||
// var guessStr = e.GetArg("guess").Trim().ToUpperInvariant();
|
// var guessStr = guess.Trim().ToUpperInvariant();
|
||||||
// if (guessStr != "H" && guessStr != "T" && guessStr != "HEADS" && guessStr != "TAILS")
|
// if (guessStr != "H" && guessStr != "T" && guessStr != "HEADS" && guessStr != "TAILS")
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
@ -82,7 +82,7 @@
|
|||||||
// public Func<CommandEventArgs, Task> FlipCoinFunc() => async e =>
|
// public Func<CommandEventArgs, Task> FlipCoinFunc() => async e =>
|
||||||
// {
|
// {
|
||||||
|
|
||||||
// if (e.GetArg("count") == "")
|
// if (count == "")
|
||||||
// {
|
// {
|
||||||
// if (rng.Next(0, 2) == 1)
|
// if (rng.Next(0, 2) == 1)
|
||||||
// await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
// await e.Channel.SendFile("heads.png", Properties.Resources.heads.ToStream(System.Drawing.Imaging.ImageFormat.Png)).ConfigureAwait(false);
|
||||||
@ -92,7 +92,7 @@
|
|||||||
// else
|
// else
|
||||||
// {
|
// {
|
||||||
// int result;
|
// int result;
|
||||||
// if (int.TryParse(e.GetArg("count"), out result))
|
// if (int.TryParse(count, out result))
|
||||||
// {
|
// {
|
||||||
// if (result > 10)
|
// if (result > 10)
|
||||||
// result = 10;
|
// result = 10;
|
||||||
|
@ -131,7 +131,7 @@
|
|||||||
// .Parameter("cd", ParameterType.Unparsed)
|
// .Parameter("cd", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var cdStr = e.GetArg("cd");
|
// var cdStr = cd;
|
||||||
// int cd = 2;
|
// int cd = 2;
|
||||||
// if (!int.TryParse(cdStr, out cd) || cd < 0)
|
// if (!int.TryParse(cdStr, out cd) || cd < 0)
|
||||||
// {
|
// {
|
||||||
|
@ -181,11 +181,11 @@
|
|||||||
// .Parameter("text", ParameterType.Unparsed)
|
// .Parameter("text", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// if (!NadekoBot.IsOwner(imsg.Author.Id) || string.IsNullOrWhiteSpace(e.GetArg("text"))) return;
|
// if (!NadekoBot.IsOwner(imsg.Author.Id) || string.IsNullOrWhiteSpace(text)) return;
|
||||||
|
|
||||||
// DbHandler.Instance.Connection.Insert(new TypingArticle
|
// DbHandler.Instance.Connection.Insert(new TypingArticle
|
||||||
// {
|
// {
|
||||||
// Text = e.GetArg("text"),
|
// Text = text,
|
||||||
// DateAdded = DateTime.Now
|
// DateAdded = DateTime.Now
|
||||||
// });
|
// });
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@ using System.Text.RegularExpressions;
|
|||||||
using System.Xml.Linq;
|
using System.Xml.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
|
using NadekoBot.Extensions;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.NSFW
|
namespace NadekoBot.Modules.NSFW
|
||||||
{
|
{
|
||||||
@ -173,9 +174,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
{
|
{
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
http.DefaultRequestHeaders.Clear();
|
http.AddFakeHeaders();
|
||||||
http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1");
|
|
||||||
http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
|
||||||
|
|
||||||
var webpage = await http.GetStringAsync("http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags="+ tag.Replace(" ", "_")).ConfigureAwait(false);
|
var webpage = await http.GetStringAsync("http://gelbooru.com/index.php?page=dapi&s=post&q=index&limit=100&tags="+ tag.Replace(" ", "_")).ConfigureAwait(false);
|
||||||
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
var matches = Regex.Matches(webpage, "file_url=\"(?<url>.*?)\"");
|
||||||
@ -211,9 +210,7 @@ namespace NadekoBot.Modules.NSFW
|
|||||||
{
|
{
|
||||||
using (var http = new HttpClient())
|
using (var http = new HttpClient())
|
||||||
{
|
{
|
||||||
http.DefaultRequestHeaders.Clear();
|
http.AddFakeHeaders();
|
||||||
http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1");
|
|
||||||
http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
|
||||||
var data = await http.GetStreamAsync("http://e621.net/post/index.xml?tags=" + Uri.EscapeUriString(tags) + "%20order:random&limit=1");
|
var data = await http.GetStreamAsync("http://e621.net/post/index.xml?tags=" + Uri.EscapeUriString(tags) + "%20order:random&limit=1");
|
||||||
var doc = XDocument.Load(data);
|
var doc = XDocument.Load(data);
|
||||||
return doc.Descendants("file_url").FirstOrDefault().Value;
|
return doc.Descendants("file_url").FirstOrDefault().Value;
|
||||||
|
@ -72,11 +72,11 @@
|
|||||||
// {
|
// {
|
||||||
// await e.Channel.SendIsTyping().ConfigureAwait(false);
|
// await e.Channel.SendIsTyping().ConfigureAwait(false);
|
||||||
|
|
||||||
// string from = e.GetArg("from-to").ToLowerInvariant().Split('>')[0];
|
// string from = from-to.ToLowerInvariant().Split('>')[0];
|
||||||
// string to = e.GetArg("from-to").ToLowerInvariant().Split('>')[1];
|
// string to = from-to.ToLowerInvariant().Split('>')[1];
|
||||||
|
|
||||||
// float quantity = 1.0f;
|
// float quantity = 1.0f;
|
||||||
// if (!float.TryParse(e.GetArg("quantity"), out quantity))
|
// if (!float.TryParse(quantity, out quantity))
|
||||||
// {
|
// {
|
||||||
// quantity = 1.0f;
|
// quantity = 1.0f;
|
||||||
// }
|
// }
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
// private CustomParser parser = new CustomParser();
|
// private CustomParser parser = new CustomParser();
|
||||||
// private Func<CommandEventArgs, Task> EvalFunc() => async e =>
|
// private Func<CommandEventArgs, Task> EvalFunc() => async e =>
|
||||||
// {
|
// {
|
||||||
// string expression = e.GetArg("expression")?.Trim();
|
// string expression = expression?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(expression))
|
// if (string.IsNullOrWhiteSpace(expression))
|
||||||
// {
|
// {
|
||||||
// return;
|
// return;
|
||||||
|
@ -124,9 +124,9 @@ namespace NadekoBot.Modules.Searches
|
|||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// //get role
|
// //get role
|
||||||
// var role = ResolvePos(e.GetArg("position"));
|
// var role = ResolvePos(position);
|
||||||
// var resolvedRole = role;
|
// var resolvedRole = role;
|
||||||
// var name = e.GetArg("champ").Replace(" ", "").ToLower();
|
// var name = champ.Replace(" ", "").ToLower();
|
||||||
// CachedChampion champ = null;
|
// CachedChampion champ = null;
|
||||||
|
|
||||||
// if (CachedChampionImages.TryGetValue(name + "_" + resolvedRole, out champ))
|
// if (CachedChampionImages.TryGetValue(name + "_" + resolvedRole, out champ))
|
||||||
@ -136,7 +136,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
// await e.Channel.SendFile("champ.png", champ.ImageStream).ConfigureAwait(false);
|
// await e.Channel.SendFile("champ.png", champ.ImageStream).ConfigureAwait(false);
|
||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
// var allData = JArray.Parse(await Classes.http.GetStringAsync($"http://api.champion.gg/champion/{name}?api_key={NadekoBot.Creds.LOLAPIKey}").ConfigureAwait(false));
|
// var allData = JArray.Parse(await Classes.http.GetStringAsync($"http://api.champion.gg/champion/{name}?api_key={NadekoBot.Credentials.LOLAPIKey}").ConfigureAwait(false));
|
||||||
// JToken data = null;
|
// JToken data = null;
|
||||||
// if (role != null)
|
// if (role != null)
|
||||||
// {
|
// {
|
||||||
@ -177,7 +177,7 @@ namespace NadekoBot.Modules.Searches
|
|||||||
// roles[i] = ">" + roles[i] + "<";
|
// roles[i] = ">" + roles[i] + "<";
|
||||||
// }
|
// }
|
||||||
// var general = JArray.Parse(await http.GetStringAsync($"http://api.champion.gg/stats/" +
|
// var general = JArray.Parse(await http.GetStringAsync($"http://api.champion.gg/stats/" +
|
||||||
// $"champs/{name}?api_key={NadekoBot.Creds.LOLAPIKey}")
|
// $"champs/{name}?api_key={NadekoBot.Credentials.LOLAPIKey}")
|
||||||
// .ConfigureAwait(false))
|
// .ConfigureAwait(false))
|
||||||
// .FirstOrDefault(jt => jt["role"].ToString() == role)?["general"];
|
// .FirstOrDefault(jt => jt["role"].ToString() == role)?["general"];
|
||||||
// if (general == null)
|
// if (general == null)
|
||||||
|
@ -1,269 +1,277 @@
|
|||||||
//using Discord.Commands;
|
using Discord;
|
||||||
//using NadekoBot.Classes;
|
using Discord.Commands;
|
||||||
//using Newtonsoft.Json.Linq;
|
using NadekoBot.Attributes;
|
||||||
//using System;
|
using NadekoBot.Classes;
|
||||||
//using System.IO;
|
using NadekoBot.Extensions;
|
||||||
//using System.Net;
|
using Newtonsoft.Json.Linq;
|
||||||
//using System.Text.RegularExpressions;
|
using NLog;
|
||||||
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
|
using System.IO;
|
||||||
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
//todo DI into partials
|
namespace NadekoBot.Modules.Searches
|
||||||
//namespace NadekoBot.Modules.Searches
|
{
|
||||||
//{
|
public partial class Searches
|
||||||
// internal class OsuCommands : DiscordCommand
|
{
|
||||||
// {
|
[Group]
|
||||||
// public OsuCommands(DiscordModule module) : base(module)
|
public class OsuCommands
|
||||||
// {
|
{
|
||||||
// }
|
private Logger _log;
|
||||||
|
|
||||||
// internal override void Init(CommandGroupBuilder cgb)
|
public OsuCommands()
|
||||||
// {
|
{
|
||||||
// cgb.CreateCommand(Module.Prefix + "osu")
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
// .Description($"Shows osu stats for a player. | `{Prefix}osu Name` or `{Prefix}osu Name taiko`")
|
}
|
||||||
// .Parameter("usr", ParameterType.Required)
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
// .Parameter("mode", ParameterType.Unparsed)
|
[RequireContext(ContextType.Guild)]
|
||||||
// .Do(async e =>
|
public async Task Osu(IMessage imsg, string usr, string mode)
|
||||||
// {
|
{
|
||||||
// if (string.IsNullOrWhiteSpace(e.GetArg("usr")))
|
var channel = imsg.Channel as ITextChannel;
|
||||||
// return;
|
|
||||||
|
|
||||||
// using (WebClient cl = new WebClient())
|
if (string.IsNullOrWhiteSpace(usr))
|
||||||
// {
|
return;
|
||||||
// try
|
|
||||||
// {
|
|
||||||
// var m = 0;
|
|
||||||
// if (!string.IsNullOrWhiteSpace(e.GetArg("mode")))
|
|
||||||
// {
|
|
||||||
// m = ResolveGameMode(e.GetArg("mode"));
|
|
||||||
// }
|
|
||||||
|
|
||||||
// cl.CachePolicy = new System.Net.Cache.RequestCachePolicy(System.Net.Cache.RequestCacheLevel.NoCacheNoStore);
|
using (HttpClient http = new HttpClient())
|
||||||
// cl.Headers.Add(HttpRequestHeader.UserAgent, "Mozilla/5.0 (Windows NT 6.2; Win64; x64)");
|
{
|
||||||
// cl.DownloadDataAsync(new Uri($"http://lemmmy.pw/osusig/sig.php?uname={ e.GetArg("usr") }&flagshadow&xpbar&xpbarhex&pp=2&mode={m}"));
|
try
|
||||||
// cl.DownloadDataCompleted += async (s, cle) =>
|
{
|
||||||
// {
|
var m = 0;
|
||||||
// try
|
if (!string.IsNullOrWhiteSpace(mode))
|
||||||
// {
|
{
|
||||||
// await e.Channel.SendFile($"{e.GetArg("usr")}.png", new MemoryStream(cle.Result)).ConfigureAwait(false);
|
m = ResolveGameMode(mode);
|
||||||
// await channel.SendMessageAsync($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(e.GetArg("usr"))}\n`Image provided by https://lemmmy.pw/osusig`").ConfigureAwait(false);
|
}
|
||||||
// }
|
http.AddFakeHeaders();
|
||||||
// catch { }
|
var res = await http.GetStreamAsync(new Uri($"http://lemmmy.pw/osusig/sig.php?uname={ usr }&flagshadow&xpbar&xpbarhex&pp=2&mode={m}")).ConfigureAwait(false);
|
||||||
// };
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// await channel.SendMessageAsync("💢 Failed retrieving osu signature :\\").ConfigureAwait(false);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// cgb.CreateCommand(Module.Prefix + "osu b")
|
res.Position = 0;
|
||||||
// .Description($"Shows information about an osu beatmap. |`{Prefix}osu b` https://osu.ppy.sh/s/127712`")
|
await channel.SendFileAsync(res, $"{usr}.png").ConfigureAwait(false);
|
||||||
// .Parameter("map", ParameterType.Unparsed)
|
await channel.SendMessageAsync($"`Profile Link:`https://osu.ppy.sh/u/{Uri.EscapeDataString(usr)}\n`Image provided by https://lemmmy.pw/osusig`").ConfigureAwait(false);
|
||||||
// .Do(async e =>
|
}
|
||||||
// {
|
catch (Exception ex)
|
||||||
// if (string.IsNullOrWhiteSpace(NadekoBot.Creds.OsuAPIKey))
|
{
|
||||||
// {
|
await channel.SendMessageAsync("💢 Failed retrieving osu signature :\\").ConfigureAwait(false);
|
||||||
// await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
_log.Warn(ex, "Osu command failed");
|
||||||
// return;
|
}
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (string.IsNullOrWhiteSpace(e.GetArg("map")))
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
// return;
|
[RequireContext(ContextType.Guild)]
|
||||||
|
public async Task Osub(IMessage imsg, [Remainder] string map)
|
||||||
|
{
|
||||||
|
var channel = imsg.Channel as ITextChannel;
|
||||||
|
|
||||||
// try
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.OsuApiKey))
|
||||||
// {
|
{
|
||||||
// var mapId = ResolveMap(e.GetArg("map"));
|
await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
||||||
// var reqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Creds.OsuAPIKey}&{mapId}";
|
return;
|
||||||
// var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false))[0];
|
}
|
||||||
// var sb = new System.Text.StringBuilder();
|
|
||||||
// var starRating = Math.Round(Double.Parse($"{obj["difficultyrating"]}", CultureInfo.InvariantCulture), 2);
|
|
||||||
// var time = TimeSpan.FromSeconds(Double.Parse($"{obj["total_length"]}")).ToString(@"mm\:ss");
|
|
||||||
// sb.AppendLine($"{obj["artist"]} - {obj["title"]}, mapped by {obj["creator"]}. https://osu.ppy.sh/s/{obj["beatmapset_id"]}");
|
|
||||||
// sb.AppendLine($"{starRating} stars, {obj["bpm"]} BPM | AR{obj["diff_approach"]}, CS{obj["diff_size"]}, OD{obj["diff_overall"]} | Length: {time}");
|
|
||||||
// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// await channel.SendMessageAsync("Something went wrong.");
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
|
|
||||||
// cgb.CreateCommand(Module.Prefix + "osu top5")
|
if (string.IsNullOrWhiteSpace(map))
|
||||||
// .Description($"Displays a user's top 5 plays. |`{Prefix}osu top5 Name`")
|
return;
|
||||||
// .Parameter("usr", ParameterType.Required)
|
|
||||||
// .Parameter("mode", ParameterType.Unparsed)
|
|
||||||
// .Do(async e =>
|
|
||||||
// {
|
|
||||||
// if (string.IsNullOrWhiteSpace(NadekoBot.Creds.OsuAPIKey))
|
|
||||||
// {
|
|
||||||
// await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
|
||||||
// return;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// if (string.IsNullOrWhiteSpace(e.GetArg("usr")))
|
try
|
||||||
// {
|
{
|
||||||
// await channel.SendMessageAsync("💢 Please provide a username.").ConfigureAwait(false);
|
using (var http = new HttpClient())
|
||||||
// return;
|
{
|
||||||
// }
|
var mapId = ResolveMap(map);
|
||||||
|
var reqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Credentials.OsuApiKey}&{mapId}";
|
||||||
|
var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false))[0];
|
||||||
|
var sb = new System.Text.StringBuilder();
|
||||||
|
var starRating = Math.Round(Double.Parse($"{obj["difficultyrating"]}", CultureInfo.InvariantCulture), 2);
|
||||||
|
var time = TimeSpan.FromSeconds(Double.Parse($"{obj["total_length"]}")).ToString(@"mm\:ss");
|
||||||
|
sb.AppendLine($"{obj["artist"]} - {obj["title"]}, mapped by {obj["creator"]}. https://osu.ppy.sh/s/{obj["beatmapset_id"]}");
|
||||||
|
sb.AppendLine($"{starRating} stars, {obj["bpm"]} BPM | AR{obj["diff_approach"]}, CS{obj["diff_size"]}, OD{obj["diff_overall"]} | Length: {time}");
|
||||||
|
await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
await channel.SendMessageAsync("Something went wrong.");
|
||||||
|
_log.Warn(ex, "Osub command failed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// try
|
[LocalizedCommand, LocalizedDescription, LocalizedSummary]
|
||||||
// {
|
[RequireContext(ContextType.Guild)]
|
||||||
// var m = 0;
|
public async Task Osu5(IMessage imsg, string user, [Remainder] string mode)
|
||||||
// if (!string.IsNullOrWhiteSpace(e.GetArg("mode")))
|
{
|
||||||
// {
|
var channel = imsg.Channel as ITextChannel;
|
||||||
// m = ResolveGameMode(e.GetArg("mode"));
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.OsuApiKey))
|
||||||
// }
|
{
|
||||||
|
await channel.SendMessageAsync("💢 An osu! API key is required.").ConfigureAwait(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// var reqString = $"https://osu.ppy.sh/api/get_user_best?k={NadekoBot.Creds.OsuAPIKey}&u={Uri.EscapeDataString(e.GetArg("usr"))}&type=string&limit=5&m={m}";
|
if (string.IsNullOrWhiteSpace(user))
|
||||||
// var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false));
|
{
|
||||||
// var sb = new System.Text.StringBuilder($"`Top 5 plays for {e.GetArg("usr")}:`\n```xl" + Environment.NewLine);
|
await channel.SendMessageAsync("💢 Please provide a username.").ConfigureAwait(false);
|
||||||
// foreach (var item in obj)
|
return;
|
||||||
// {
|
}
|
||||||
// var mapReqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Creds.OsuAPIKey}&b={item["beatmap_id"]}";
|
using (var http = new HttpClient())
|
||||||
// var map = JArray.Parse(await http.GetStringAsync(mapReqString).ConfigureAwait(false))[0];
|
{
|
||||||
// var pp = Math.Round(Double.Parse($"{item["pp"]}", CultureInfo.InvariantCulture), 2);
|
try
|
||||||
// var acc = CalculateAcc(item, m);
|
{
|
||||||
// var mods = ResolveMods(Int32.Parse($"{item["enabled_mods"]}"));
|
var m = 0;
|
||||||
// if (mods != "+")
|
if (!string.IsNullOrWhiteSpace(mode))
|
||||||
// sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | **{mods,-10}** | /b/{item["beatmap_id"]}");
|
{
|
||||||
// else
|
m = ResolveGameMode(mode);
|
||||||
// sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | /b/{item["beatmap_id"]}");
|
}
|
||||||
// }
|
|
||||||
// sb.Append("```");
|
|
||||||
// await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
|
||||||
// }
|
|
||||||
// catch
|
|
||||||
// {
|
|
||||||
// await channel.SendMessageAsync("Something went wrong.");
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
|
|
||||||
// //https://osu.ppy.sh/wiki/Accuracy
|
var reqString = $"https://osu.ppy.sh/api/get_user_best?k={NadekoBot.Credentials.OsuApiKey}&u={Uri.EscapeDataString(user)}&type=string&limit=5&m={m}";
|
||||||
// private static Double CalculateAcc(JToken play, int mode)
|
var obj = JArray.Parse(await http.GetStringAsync(reqString).ConfigureAwait(false));
|
||||||
// {
|
var sb = new System.Text.StringBuilder($"`Top 5 plays for {user}:`\n```xl" + Environment.NewLine);
|
||||||
// if (mode == 0)
|
foreach (var item in obj)
|
||||||
// {
|
{
|
||||||
// var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["count300"]}") * 300;
|
var mapReqString = $"https://osu.ppy.sh/api/get_beatmaps?k={NadekoBot.Credentials.OsuApiKey}&b={item["beatmap_id"]}";
|
||||||
// var totalHits = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countmiss"]}");
|
var map = JArray.Parse(await http.GetStringAsync(mapReqString).ConfigureAwait(false))[0];
|
||||||
// totalHits *= 300;
|
var pp = Math.Round(Double.Parse($"{item["pp"]}", CultureInfo.InvariantCulture), 2);
|
||||||
// return Math.Round(hitPoints / totalHits * 100, 2);
|
var acc = CalculateAcc(item, m);
|
||||||
// }
|
var mods = ResolveMods(Int32.Parse($"{item["enabled_mods"]}"));
|
||||||
// else if (mode == 1)
|
if (mods != "+")
|
||||||
// {
|
sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | **{mods,-10}** | /b/{item["beatmap_id"]}");
|
||||||
// var hitPoints = Double.Parse($"{play["countmiss"]}") * 0 + Double.Parse($"{play["count100"]}") * 0.5 + Double.Parse($"{play["count300"]}") * 1;
|
else
|
||||||
// var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
sb.AppendLine($"{pp + "pp",-7} | {acc + "%",-7} | {map["artist"] + "-" + map["title"] + " (" + map["version"],-40}) | /b/{item["beatmap_id"]}");
|
||||||
// hitPoints *= 300;
|
}
|
||||||
// totalHits *= 300;
|
sb.Append("```");
|
||||||
// return Math.Round(hitPoints / totalHits * 100, 2);
|
await channel.SendMessageAsync(sb.ToString()).ConfigureAwait(false);
|
||||||
// }
|
}
|
||||||
// else if (mode == 2)
|
catch (Exception ex)
|
||||||
// {
|
{
|
||||||
// var fruitsCaught = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
await channel.SendMessageAsync("Something went wrong.");
|
||||||
// var totalFruits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countkatu"]}");
|
_log.Warn(ex, "Osu5 command failed");
|
||||||
// return Math.Round(fruitsCaught / totalFruits * 100, 2);
|
}
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["countkatu"]}") * 200 + (Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}")) * 300;
|
|
||||||
// var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["countkatu"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}");
|
|
||||||
// totalHits *= 300;
|
|
||||||
// return Math.Round(hitPoints / totalHits * 100, 2);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static string ResolveMap(string mapLink)
|
}
|
||||||
// {
|
}
|
||||||
// Match s = new Regex(@"osu.ppy.sh\/s\/", RegexOptions.IgnoreCase).Match(mapLink);
|
|
||||||
// Match b = new Regex(@"osu.ppy.sh\/b\/", RegexOptions.IgnoreCase).Match(mapLink);
|
|
||||||
// Match p = new Regex(@"osu.ppy.sh\/p\/", RegexOptions.IgnoreCase).Match(mapLink);
|
|
||||||
// Match m = new Regex(@"&m=", RegexOptions.IgnoreCase).Match(mapLink);
|
|
||||||
// if (s.Success)
|
|
||||||
// {
|
|
||||||
// var mapId = mapLink.Substring(mapLink.IndexOf("/s/") + 3);
|
|
||||||
// return $"s={mapId}";
|
|
||||||
// }
|
|
||||||
// else if (b.Success)
|
|
||||||
// {
|
|
||||||
// if (m.Success)
|
|
||||||
// return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("/b/") + 3))}";
|
|
||||||
// else
|
|
||||||
// return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3)}";
|
|
||||||
// }
|
|
||||||
// else if (p.Success)
|
|
||||||
// {
|
|
||||||
// if (m.Success)
|
|
||||||
// return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("?b=") + 3))}";
|
|
||||||
// else
|
|
||||||
// return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3)}";
|
|
||||||
// }
|
|
||||||
// else
|
|
||||||
// {
|
|
||||||
// return $"s={mapLink}"; //just a default incase an ID number was provided by itself (non-url)?
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// private static int ResolveGameMode(string mode)
|
//https://osu.ppy.sh/wiki/Accuracy
|
||||||
// {
|
private static Double CalculateAcc(JToken play, int mode)
|
||||||
// switch (mode.ToLower())
|
{
|
||||||
// {
|
if (mode == 0)
|
||||||
// case "std":
|
{
|
||||||
// case "standard":
|
var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["count300"]}") * 300;
|
||||||
// return 0;
|
var totalHits = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countmiss"]}");
|
||||||
// case "taiko":
|
totalHits *= 300;
|
||||||
// return 1;
|
return Math.Round(hitPoints / totalHits * 100, 2);
|
||||||
// case "ctb":
|
}
|
||||||
// case "catchthebeat":
|
else if (mode == 1)
|
||||||
// return 2;
|
{
|
||||||
// case "mania":
|
var hitPoints = Double.Parse($"{play["countmiss"]}") * 0 + Double.Parse($"{play["count100"]}") * 0.5 + Double.Parse($"{play["count300"]}") * 1;
|
||||||
// case "osu!mania":
|
var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
||||||
// return 3;
|
hitPoints *= 300;
|
||||||
// default:
|
totalHits *= 300;
|
||||||
// return 0;
|
return Math.Round(hitPoints / totalHits * 100, 2);
|
||||||
// }
|
}
|
||||||
// }
|
else if (mode == 2)
|
||||||
|
{
|
||||||
|
var fruitsCaught = Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}");
|
||||||
|
var totalFruits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countkatu"]}");
|
||||||
|
return Math.Round(fruitsCaught / totalFruits * 100, 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var hitPoints = Double.Parse($"{play["count50"]}") * 50 + Double.Parse($"{play["count100"]}") * 100 + Double.Parse($"{play["countkatu"]}") * 200 + (Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}")) * 300;
|
||||||
|
var totalHits = Double.Parse($"{play["countmiss"]}") + Double.Parse($"{play["count50"]}") + Double.Parse($"{play["count100"]}") + Double.Parse($"{play["countkatu"]}") + Double.Parse($"{play["count300"]}") + Double.Parse($"{play["countgeki"]}");
|
||||||
|
totalHits *= 300;
|
||||||
|
return Math.Round(hitPoints / totalHits * 100, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// //https://github.com/ppy/osu-api/wiki#mods
|
private static string ResolveMap(string mapLink)
|
||||||
// private static string ResolveMods(int mods)
|
{
|
||||||
// {
|
Match s = new Regex(@"osu.ppy.sh\/s\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||||
// var modString = $"+";
|
Match b = new Regex(@"osu.ppy.sh\/b\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||||
|
Match p = new Regex(@"osu.ppy.sh\/p\/", RegexOptions.IgnoreCase).Match(mapLink);
|
||||||
|
Match m = new Regex(@"&m=", RegexOptions.IgnoreCase).Match(mapLink);
|
||||||
|
if (s.Success)
|
||||||
|
{
|
||||||
|
var mapId = mapLink.Substring(mapLink.IndexOf("/s/") + 3);
|
||||||
|
return $"s={mapId}";
|
||||||
|
}
|
||||||
|
else if (b.Success)
|
||||||
|
{
|
||||||
|
if (m.Success)
|
||||||
|
return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("/b/") + 3))}";
|
||||||
|
else
|
||||||
|
return $"b={mapLink.Substring(mapLink.IndexOf("/b/") + 3)}";
|
||||||
|
}
|
||||||
|
else if (p.Success)
|
||||||
|
{
|
||||||
|
if (m.Success)
|
||||||
|
return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3, mapLink.IndexOf("&m") - (mapLink.IndexOf("?b=") + 3))}";
|
||||||
|
else
|
||||||
|
return $"b={mapLink.Substring(mapLink.IndexOf("?b=") + 3)}";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return $"s={mapLink}"; //just a default incase an ID number was provided by itself (non-url)?
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (IsBitSet(mods, 0))
|
private static int ResolveGameMode(string mode)
|
||||||
// modString += "NF";
|
{
|
||||||
// if (IsBitSet(mods, 1))
|
switch (mode.ToLower())
|
||||||
// modString += "EZ";
|
{
|
||||||
// if (IsBitSet(mods, 8))
|
case "std":
|
||||||
// modString += "HT";
|
case "standard":
|
||||||
|
return 0;
|
||||||
|
case "taiko":
|
||||||
|
return 1;
|
||||||
|
case "ctb":
|
||||||
|
case "catchthebeat":
|
||||||
|
return 2;
|
||||||
|
case "mania":
|
||||||
|
case "osu!mania":
|
||||||
|
return 3;
|
||||||
|
default:
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// if (IsBitSet(mods, 3))
|
//https://github.com/ppy/osu-api/wiki#mods
|
||||||
// modString += "HD";
|
private static string ResolveMods(int mods)
|
||||||
// if (IsBitSet(mods, 4))
|
{
|
||||||
// modString += "HR";
|
var modString = $"+";
|
||||||
// if (IsBitSet(mods, 6) && !IsBitSet(mods, 9))
|
|
||||||
// modString += "DT";
|
|
||||||
// if (IsBitSet(mods, 9))
|
|
||||||
// modString += "NC";
|
|
||||||
// if (IsBitSet(mods, 10))
|
|
||||||
// modString += "FL";
|
|
||||||
|
|
||||||
// if (IsBitSet(mods, 5))
|
if (IsBitSet(mods, 0))
|
||||||
// modString += "SD";
|
modString += "NF";
|
||||||
// if (IsBitSet(mods, 14))
|
if (IsBitSet(mods, 1))
|
||||||
// modString += "PF";
|
modString += "EZ";
|
||||||
|
if (IsBitSet(mods, 8))
|
||||||
|
modString += "HT";
|
||||||
|
|
||||||
// if (IsBitSet(mods, 7))
|
if (IsBitSet(mods, 3))
|
||||||
// modString += "RX";
|
modString += "HD";
|
||||||
// if (IsBitSet(mods, 11))
|
if (IsBitSet(mods, 4))
|
||||||
// modString += "AT";
|
modString += "HR";
|
||||||
// if (IsBitSet(mods, 12))
|
if (IsBitSet(mods, 6) && !IsBitSet(mods, 9))
|
||||||
// modString += "SO";
|
modString += "DT";
|
||||||
// return modString;
|
if (IsBitSet(mods, 9))
|
||||||
// }
|
modString += "NC";
|
||||||
|
if (IsBitSet(mods, 10))
|
||||||
|
modString += "FL";
|
||||||
|
|
||||||
// private static bool IsBitSet(int mods, int pos)
|
if (IsBitSet(mods, 5))
|
||||||
// {
|
modString += "SD";
|
||||||
// return (mods & (1 << pos)) != 0;
|
if (IsBitSet(mods, 14))
|
||||||
// }
|
modString += "PF";
|
||||||
|
|
||||||
// }
|
if (IsBitSet(mods, 7))
|
||||||
//}
|
modString += "RX";
|
||||||
|
if (IsBitSet(mods, 11))
|
||||||
|
modString += "AT";
|
||||||
|
if (IsBitSet(mods, 12))
|
||||||
|
modString += "SO";
|
||||||
|
return modString;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static bool IsBitSet(int mods, int pos) =>
|
||||||
|
(mods & (1 << pos)) != 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -154,7 +154,7 @@
|
|||||||
// .AddCheck(SimpleCheckers.ManageServer())
|
// .AddCheck(SimpleCheckers.ManageServer())
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var stream = e.GetArg("username")?.Trim();
|
// var stream = username?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(stream))
|
// if (string.IsNullOrWhiteSpace(stream))
|
||||||
// return;
|
// return;
|
||||||
// try
|
// try
|
||||||
@ -183,7 +183,7 @@
|
|||||||
// .Parameter("username", ParameterType.Unparsed)
|
// .Parameter("username", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var stream = e.GetArg("username")?.Trim();
|
// var stream = username?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(stream))
|
// if (string.IsNullOrWhiteSpace(stream))
|
||||||
// return;
|
// return;
|
||||||
// try
|
// try
|
||||||
@ -212,7 +212,7 @@
|
|||||||
// .Parameter("username", ParameterType.Unparsed)
|
// .Parameter("username", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var stream = e.GetArg("username")?.Trim();
|
// var stream = username?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(stream))
|
// if (string.IsNullOrWhiteSpace(stream))
|
||||||
// return;
|
// return;
|
||||||
// try
|
// try
|
||||||
@ -241,7 +241,7 @@
|
|||||||
// .Parameter("username", ParameterType.Unparsed)
|
// .Parameter("username", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var username = e.GetArg("username")?.ToLower().Trim();
|
// var username = username?.ToLower().Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(username))
|
// if (string.IsNullOrWhiteSpace(username))
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
@ -298,7 +298,7 @@
|
|||||||
// private Func<CommandEventArgs, Task> TrackStream(StreamNotificationConfig.StreamType type) =>
|
// private Func<CommandEventArgs, Task> TrackStream(StreamNotificationConfig.StreamType type) =>
|
||||||
// async e =>
|
// async e =>
|
||||||
// {
|
// {
|
||||||
// var username = e.GetArg("username")?.ToLowerInvariant();
|
// var username = username?.ToLowerInvariant();
|
||||||
// if (string.IsNullOrWhiteSpace(username))
|
// if (string.IsNullOrWhiteSpace(username))
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
@ -8,7 +8,6 @@ using System.Net.Http;
|
|||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using NadekoBot.Attributes;
|
using NadekoBot.Attributes;
|
||||||
using NadekoBot.Extensions;
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
@ -206,7 +205,7 @@ $@"🌍 **Weather for** 【{obj["target"]}】
|
|||||||
//public async Task Hearthstone(IMessage imsg, [Remainder] string name = null)
|
//public async Task Hearthstone(IMessage imsg, [Remainder] string name = null)
|
||||||
//{
|
//{
|
||||||
// var channel = imsg.Channel as ITextChannel;
|
// var channel = imsg.Channel as ITextChannel;
|
||||||
// var arg = e.GetArg("name");
|
// var arg = name;
|
||||||
// if (string.IsNullOrWhiteSpace(arg))
|
// if (string.IsNullOrWhiteSpace(arg))
|
||||||
// {
|
// {
|
||||||
// await channel.SendMessageAsync("💢 Please enter a card name to search for.").ConfigureAwait(false);
|
// await channel.SendMessageAsync("💢 Please enter a card name to search for.").ConfigureAwait(false);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
// TrelloConfiguration.Deserializer = serializer;
|
// TrelloConfiguration.Deserializer = serializer;
|
||||||
// TrelloConfiguration.JsonFactory = new ManateeFactory();
|
// TrelloConfiguration.JsonFactory = new ManateeFactory();
|
||||||
// TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
|
// TrelloConfiguration.RestClientProvider = new Manatee.Trello.WebApi.WebApiClientProvider();
|
||||||
// TrelloAuthorization.Default.AppKey = NadekoBot.Creds.TrelloAppKey;
|
// TrelloAuthorization.Default.AppKey = NadekoBot.Credentials.TrelloAppKey;
|
||||||
// //TrelloAuthorization.Default.UserToken = "[your user token]";
|
// //TrelloAuthorization.Default.UserToken = "[your user token]";
|
||||||
|
|
||||||
// Discord.Channel bound = null;
|
// Discord.Channel bound = null;
|
||||||
@ -80,7 +80,7 @@
|
|||||||
// try
|
// try
|
||||||
// {
|
// {
|
||||||
// bound = e.Channel;
|
// bound = e.Channel;
|
||||||
// board = new Board(e.GetArg("board_id").Trim());
|
// board = new Board(board_id.Trim());
|
||||||
// board.Refresh();
|
// board.Refresh();
|
||||||
// await channel.SendMessageAsync("Successfully bound to this channel and board " + board.Name);
|
// await channel.SendMessageAsync("Successfully bound to this channel and board " + board.Name);
|
||||||
// t.Start();
|
// t.Start();
|
||||||
@ -121,15 +121,15 @@
|
|||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// if (!NadekoBot.IsOwner(imsg.Author.Id)) return;
|
// if (!NadekoBot.IsOwner(imsg.Author.Id)) return;
|
||||||
// if (bound == null || board == null || bound != e.Channel || e.GetArg("list_name") == null) return;
|
// if (bound == null || board == null || bound != e.Channel || list_name == null) return;
|
||||||
|
|
||||||
// int num;
|
// int num;
|
||||||
// var success = int.TryParse(e.GetArg("list_name"), out num);
|
// var success = int.TryParse(list_name, out num);
|
||||||
// List list = null;
|
// List list = null;
|
||||||
// if (success && num <= board.Lists.Count() && num > 0)
|
// if (success && num <= board.Lists.Count() && num > 0)
|
||||||
// list = board.Lists[num - 1];
|
// list = board.Lists[num - 1];
|
||||||
// else
|
// else
|
||||||
// list = board.Lists.FirstOrDefault(l => l.Name == e.GetArg("list_name"));
|
// list = board.Lists.FirstOrDefault(l => l.Name == list_name);
|
||||||
|
|
||||||
|
|
||||||
// if (list != null)
|
// if (list != null)
|
||||||
|
@ -94,7 +94,7 @@
|
|||||||
// .Parameter("message", ParameterType.Unparsed)
|
// .Parameter("message", ParameterType.Unparsed)
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var meorchStr = e.GetArg("meorchannel").ToUpperInvariant();
|
// var meorchStr = meorchannel.ToUpperInvariant();
|
||||||
// Channel ch;
|
// Channel ch;
|
||||||
// bool isPrivate = false;
|
// bool isPrivate = false;
|
||||||
// if (meorchStr == "ME")
|
// if (meorchStr == "ME")
|
||||||
@ -117,7 +117,7 @@
|
|||||||
// return;
|
// return;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
// var timeStr = e.GetArg("time");
|
// var timeStr = time;
|
||||||
|
|
||||||
// var m = regex.Match(timeStr);
|
// var m = regex.Match(timeStr);
|
||||||
|
|
||||||
@ -167,7 +167,7 @@
|
|||||||
// ChannelId = (long)ch.Id,
|
// ChannelId = (long)ch.Id,
|
||||||
// IsPrivate = isPrivate,
|
// IsPrivate = isPrivate,
|
||||||
// When = time,
|
// When = time,
|
||||||
// Message = e.GetArg("message"),
|
// Message = message,
|
||||||
// UserId = (long)imsg.Author.Id,
|
// UserId = (long)imsg.Author.Id,
|
||||||
// ServerId = (long)e.Server.Id
|
// ServerId = (long)e.Server.Id
|
||||||
// };
|
// };
|
||||||
@ -175,7 +175,7 @@
|
|||||||
|
|
||||||
// reminders.Add(StartNewReminder(rem));
|
// reminders.Add(StartNewReminder(rem));
|
||||||
|
|
||||||
// await channel.SendMessageAsync($"⏰ I will remind \"{ch.Name}\" to \"{e.GetArg("message").ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false);
|
// await channel.SendMessageAsync($"⏰ I will remind \"{ch.Name}\" to \"{message.ToString()}\" in {output}. ({time:d.M.yyyy.} at {time:HH:mm})").ConfigureAwait(false);
|
||||||
// });
|
// });
|
||||||
// cgb.CreateCommand(Module.Prefix + "remindmsg")
|
// cgb.CreateCommand(Module.Prefix + "remindmsg")
|
||||||
// .Description("Sets message for when the remind is triggered. " +
|
// .Description("Sets message for when the remind is triggered. " +
|
||||||
@ -185,7 +185,7 @@
|
|||||||
// .AddCheck(SimpleCheckers.OwnerOnly())
|
// .AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
// .Do(async e =>
|
// .Do(async e =>
|
||||||
// {
|
// {
|
||||||
// var arg = e.GetArg("msg")?.Trim();
|
// var arg = msg?.Trim();
|
||||||
// if (string.IsNullOrWhiteSpace(arg))
|
// if (string.IsNullOrWhiteSpace(arg))
|
||||||
// return;
|
// return;
|
||||||
|
|
||||||
|
@ -23,7 +23,7 @@ namespace NadekoBot
|
|||||||
public static Localization Localizer { get; private set; }
|
public static Localization Localizer { get; private set; }
|
||||||
public static BotCredentials Credentials { get; private set; }
|
public static BotCredentials Credentials { get; private set; }
|
||||||
|
|
||||||
private static YoutubeService Youtube { get; set; }
|
private static GoogleApiService Youtube { get; set; }
|
||||||
public static StatsService Stats { get; private set; }
|
public static StatsService Stats { get; private set; }
|
||||||
|
|
||||||
public async Task RunAsync(string[] args)
|
public async Task RunAsync(string[] args)
|
||||||
@ -43,7 +43,7 @@ namespace NadekoBot
|
|||||||
Commands = new CommandService();
|
Commands = new CommandService();
|
||||||
Config = new BotConfiguration();
|
Config = new BotConfiguration();
|
||||||
Localizer = new Localization();
|
Localizer = new Localization();
|
||||||
Youtube = new YoutubeService();
|
Youtube = new GoogleApiService();
|
||||||
Stats = new StatsService(Client);
|
Stats = new StatsService(Client);
|
||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
|
@ -5,6 +5,7 @@ using System.Collections.Generic;
|
|||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Net.Http;
|
||||||
using System.Security.Cryptography;
|
using System.Security.Cryptography;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
@ -14,6 +15,13 @@ namespace NadekoBot.Extensions
|
|||||||
{
|
{
|
||||||
public static class Extensions
|
public static class Extensions
|
||||||
{
|
{
|
||||||
|
public static void AddFakeHeaders(this HttpClient http)
|
||||||
|
{
|
||||||
|
http.DefaultRequestHeaders.Clear();
|
||||||
|
http.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 6.1) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/14.0.835.202 Safari/535.1");
|
||||||
|
http.DefaultRequestHeaders.Add("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8");
|
||||||
|
}
|
||||||
|
|
||||||
public static async Task<IMessage> SendMessageAsync(this IGuildUser user, string message, bool isTTS = false) =>
|
public static async Task<IMessage> SendMessageAsync(this IGuildUser user, string message, bool isTTS = false) =>
|
||||||
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(message, isTTS).ConfigureAwait(false);
|
await (await user.CreateDMChannelAsync().ConfigureAwait(false)).SendMessageAsync(message, isTTS).ConfigureAwait(false);
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ namespace NadekoBot.Modules.CustomReactions
|
|||||||
} },
|
} },
|
||||||
{new Regex("%mention%"), (e,m) => NadekoBot.BotMention },
|
{new Regex("%mention%"), (e,m) => NadekoBot.BotMention },
|
||||||
{new Regex("%user%"), (e,m) => imsg.Author.Mention },
|
{new Regex("%user%"), (e,m) => imsg.Author.Mention },
|
||||||
{new Regex("%target%"), (e,m) => e.GetArg("args")?.Trim() ?? "" },
|
{new Regex("%target%"), (e,m) => args?.Trim() ?? "" },
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -18,10 +18,10 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(url))
|
if (string.IsNullOrWhiteSpace(url))
|
||||||
throw new ArgumentNullException(nameof(url));
|
throw new ArgumentNullException(nameof(url));
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.SoundCloudClientID))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.SoundCloudClientID))
|
||||||
throw new ArgumentNullException(nameof(NadekoBot.Creds.SoundCloudClientID));
|
throw new ArgumentNullException(nameof(NadekoBot.Credentials.SoundCloudClientID));
|
||||||
|
|
||||||
var response = await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={NadekoBot.Creds.SoundCloudClientID}").ConfigureAwait(false);
|
var response = await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={url}&client_id={NadekoBot.Credentials.SoundCloudClientID}").ConfigureAwait(false);
|
||||||
|
|
||||||
var responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject<SoundCloudVideo>(response);
|
var responseObj = Newtonsoft.Json.JsonConvert.DeserializeObject<SoundCloudVideo>(response);
|
||||||
if (responseObj?.Kind != "track")
|
if (responseObj?.Kind != "track")
|
||||||
@ -37,10 +37,10 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(query))
|
if (string.IsNullOrWhiteSpace(query))
|
||||||
throw new ArgumentNullException(nameof(query));
|
throw new ArgumentNullException(nameof(query));
|
||||||
if (string.IsNullOrWhiteSpace(NadekoBot.Creds.SoundCloudClientID))
|
if (string.IsNullOrWhiteSpace(NadekoBot.Credentials.SoundCloudClientID))
|
||||||
throw new ArgumentNullException(nameof(NadekoBot.Creds.SoundCloudClientID));
|
throw new ArgumentNullException(nameof(NadekoBot.Credentials.SoundCloudClientID));
|
||||||
|
|
||||||
var response = await http.GetStringAsync($"http://api.soundcloud.com/tracks?q={Uri.EscapeDataString(query)}&client_id={NadekoBot.Creds.SoundCloudClientID}").ConfigureAwait(false);
|
var response = await http.GetStringAsync($"http://api.soundcloud.com/tracks?q={Uri.EscapeDataString(query)}&client_id={NadekoBot.Credentials.SoundCloudClientID}").ConfigureAwait(false);
|
||||||
|
|
||||||
var responseObj = JsonConvert.DeserializeObject<SoundCloudVideo[]>(response).Where(s => s.Streamable).FirstOrDefault();
|
var responseObj = JsonConvert.DeserializeObject<SoundCloudVideo[]>(response).Where(s => s.Streamable).FirstOrDefault();
|
||||||
if (responseObj?.Kind != "track")
|
if (responseObj?.Kind != "track")
|
||||||
@ -62,7 +62,7 @@ namespace NadekoBot.Modules.Music.Classes
|
|||||||
[JsonProperty("permalink_url")]
|
[JsonProperty("permalink_url")]
|
||||||
public string TrackLink { get; set; } = "";
|
public string TrackLink { get; set; } = "";
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public string StreamLink => $"https://api.soundcloud.com/tracks/{Id}/stream?client_id={NadekoBot.Creds.SoundCloudClientID}";
|
public string StreamLink => $"https://api.soundcloud.com/tracks/{Id}/stream?client_id={NadekoBot.Credentials.SoundCloudClientID}";
|
||||||
}
|
}
|
||||||
public class SoundCloudUser
|
public class SoundCloudUser
|
||||||
{
|
{
|
||||||
|
@ -105,7 +105,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("query", ParameterType.Unparsed)
|
.Parameter("query", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("query")).ConfigureAwait(false);
|
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, query).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
@ -120,7 +120,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("query", ParameterType.Unparsed)
|
.Parameter("query", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("query"), musicType: MusicType.Soundcloud).ConfigureAwait(false);
|
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, query, musicType: MusicType.Soundcloud).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
@ -142,7 +142,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
}
|
}
|
||||||
|
|
||||||
int page;
|
int page;
|
||||||
if (!int.TryParse(e.GetArg("page"), out page) || page <= 0)
|
if (!int.TryParse(page, out page) || page <= 0)
|
||||||
{
|
{
|
||||||
page = 1;
|
page = 1;
|
||||||
}
|
}
|
||||||
@ -192,7 +192,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
if (imsg.Author.VoiceChannel != musicPlayer.PlaybackVoiceChannel)
|
||||||
return;
|
return;
|
||||||
var arg = e.GetArg("val");
|
var arg = val;
|
||||||
int volume;
|
int volume;
|
||||||
if (!int.TryParse(arg, out volume))
|
if (!int.TryParse(arg, out volume))
|
||||||
{
|
{
|
||||||
@ -210,7 +210,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("val", ParameterType.Required)
|
.Parameter("val", ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("val");
|
var arg = val;
|
||||||
float volume;
|
float volume;
|
||||||
if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100)
|
if (!float.TryParse(arg, out volume) || volume < 0 || volume > 100)
|
||||||
{
|
{
|
||||||
@ -285,7 +285,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("playlist", ParameterType.Unparsed)
|
.Parameter("playlist", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("playlist");
|
var arg = playlist;
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
return;
|
return;
|
||||||
if (imsg.Author.VoiceChannel?.Server != e.Server)
|
if (imsg.Author.VoiceChannel?.Server != e.Server)
|
||||||
@ -328,12 +328,12 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("pl", ParameterType.Unparsed)
|
.Parameter("pl", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var pl = e.GetArg("pl")?.Trim();
|
var pl = pl?.Trim();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(pl))
|
if (string.IsNullOrWhiteSpace(pl))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
var scvids = JObject.Parse(await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={pl}&client_id={NadekoBot.Creds.SoundCloudClientID}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
|
var scvids = JObject.Parse(await http.GetStringAsync($"http://api.soundcloud.com/resolve?url={pl}&client_id={NadekoBot.Credentials.SoundCloudClientID}").ConfigureAwait(false))["tracks"].ToObject<SoundCloudVideo[]>();
|
||||||
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false);
|
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, scvids[0].TrackLink).ConfigureAwait(false);
|
||||||
|
|
||||||
MusicPlayer mp;
|
MusicPlayer mp;
|
||||||
@ -364,7 +364,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("directory");
|
var arg = directory;
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
return;
|
return;
|
||||||
try
|
try
|
||||||
@ -398,7 +398,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
await channel.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false);
|
await channel.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining it.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("radio_link"), musicType: MusicType.Radio).ConfigureAwait(false);
|
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, radio_link, musicType: MusicType.Radio).ConfigureAwait(false);
|
||||||
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
if (e.Server.CurrentUser.GetPermissions(e.Channel).ManageMessages)
|
||||||
{
|
{
|
||||||
await Task.Delay(10000).ConfigureAwait(false);
|
await Task.Delay(10000).ConfigureAwait(false);
|
||||||
@ -413,10 +413,10 @@ namespace NadekoBot.Modules.Music
|
|||||||
.AddCheck(SimpleCheckers.OwnerOnly())
|
.AddCheck(SimpleCheckers.OwnerOnly())
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("path");
|
var arg = path;
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
return;
|
return;
|
||||||
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, e.GetArg("path"), musicType: MusicType.Local).ConfigureAwait(false);
|
await QueueSong(imsg.Author, e.Channel, imsg.Author.VoiceChannel, path, musicType: MusicType.Local).ConfigureAwait(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
cgb.CreateCommand(Prefix + "move")
|
cgb.CreateCommand(Prefix + "move")
|
||||||
@ -437,7 +437,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("num", ParameterType.Required)
|
.Parameter("num", ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("num");
|
var arg = num;
|
||||||
MusicPlayer musicPlayer;
|
MusicPlayer musicPlayer;
|
||||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
||||||
{
|
{
|
||||||
@ -475,7 +475,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var fromto = e.GetArg("fromto").Trim();
|
var fromto = fromto.Trim();
|
||||||
var fromtoArr = fromto.Split('>');
|
var fromtoArr = fromto.Split('>');
|
||||||
|
|
||||||
int n1;
|
int n1;
|
||||||
@ -512,7 +512,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var sizeStr = e.GetArg("size")?.Trim();
|
var sizeStr = size?.Trim();
|
||||||
uint size = 0;
|
uint size = 0;
|
||||||
if (string.IsNullOrWhiteSpace(sizeStr) || !uint.TryParse(sizeStr, out size))
|
if (string.IsNullOrWhiteSpace(sizeStr) || !uint.TryParse(sizeStr, out size))
|
||||||
{
|
{
|
||||||
@ -576,7 +576,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("name", ParameterType.Unparsed)
|
.Parameter("name", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var name = e.GetArg("name")?.Trim();
|
var name = name?.Trim();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(name) ||
|
if (string.IsNullOrWhiteSpace(name) ||
|
||||||
name.Length > 20 ||
|
name.Length > 20 ||
|
||||||
@ -636,7 +636,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
await textCh.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false);
|
await textCh.SendMessageAsync("💢 You need to be in a voice channel on this server.\n If you are already in a voice channel, try rejoining.").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var name = e.GetArg("name")?.Trim().ToLowerInvariant();
|
var name = name?.Trim().ToLowerInvariant();
|
||||||
|
|
||||||
if (string.IsNullOrWhiteSpace(name))
|
if (string.IsNullOrWhiteSpace(name))
|
||||||
return;
|
return;
|
||||||
@ -690,7 +690,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Do(e =>
|
.Do(e =>
|
||||||
{
|
{
|
||||||
int num = 0;
|
int num = 0;
|
||||||
int.TryParse(e.GetArg("num"), out num);
|
int.TryParse(num, out num);
|
||||||
if (num < 0)
|
if (num < 0)
|
||||||
return;
|
return;
|
||||||
var result = DbHandler.Instance.GetPlaylistData(num);
|
var result = DbHandler.Instance.GetPlaylistData(num);
|
||||||
@ -706,7 +706,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("pl", ParameterType.Required)
|
.Parameter("pl", ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var pl = e.GetArg("pl").Trim().Split('-')[1];
|
var pl = pl.Trim().Split('-')[1];
|
||||||
if (string.IsNullOrWhiteSpace(pl))
|
if (string.IsNullOrWhiteSpace(pl))
|
||||||
return;
|
return;
|
||||||
var plnum = int.Parse(pl);
|
var plnum = int.Parse(pl);
|
||||||
@ -722,7 +722,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
.Parameter("time")
|
.Parameter("time")
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var skipToStr = e.GetArg("time")?.Trim();
|
var skipToStr = time?.Trim();
|
||||||
MusicPlayer musicPlayer;
|
MusicPlayer musicPlayer;
|
||||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
||||||
return;
|
return;
|
||||||
@ -764,7 +764,7 @@ namespace NadekoBot.Modules.Music
|
|||||||
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
if (!MusicPlayers.TryGetValue(e.Server, out musicPlayer))
|
||||||
return;
|
return;
|
||||||
int index;
|
int index;
|
||||||
string arg = e.GetArg("index")?.Trim();
|
string arg = index?.Trim();
|
||||||
if (!string.IsNullOrEmpty(arg) && int.TryParse(arg, out index))
|
if (!string.IsNullOrEmpty(arg) && int.TryParse(arg, out index))
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -62,8 +62,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var chanStr = e.GetArg("channel");
|
var chanStr = channel;
|
||||||
|
|
||||||
if (chanStr?.ToLowerInvariant().Trim() != "all")
|
if (chanStr?.ToLowerInvariant().Trim() != "all")
|
||||||
{
|
{
|
||||||
@ -101,7 +101,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
await PermissionsHandler.SetServerFilterInvitesPermission(e.Server, state).ConfigureAwait(false);
|
await PermissionsHandler.SetServerFilterInvitesPermission(e.Server, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for this server.")
|
await channel.SendMessageAsync($"Invite Filter has been **{(state ? "enabled" : "disabled")}** for this server.")
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
@ -60,8 +60,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var chanStr = e.GetArg("channel")?.ToLowerInvariant().Trim();
|
var chanStr = channel?.ToLowerInvariant().Trim();
|
||||||
|
|
||||||
if (chanStr != "all")
|
if (chanStr != "all")
|
||||||
{
|
{
|
||||||
@ -95,7 +95,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var word = e.GetArg("word");
|
var word = word;
|
||||||
if (string.IsNullOrWhiteSpace(word))
|
if (string.IsNullOrWhiteSpace(word))
|
||||||
return;
|
return;
|
||||||
await PermissionsHandler.AddFilteredWord(e.Server, word.ToLowerInvariant().Trim()).ConfigureAwait(false);
|
await PermissionsHandler.AddFilteredWord(e.Server, word.ToLowerInvariant().Trim()).ConfigureAwait(false);
|
||||||
@ -117,7 +117,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var word = e.GetArg("word");
|
var word = word;
|
||||||
if (string.IsNullOrWhiteSpace(word))
|
if (string.IsNullOrWhiteSpace(word))
|
||||||
return;
|
return;
|
||||||
await PermissionsHandler.RemoveFilteredWord(e.Server, word.ToLowerInvariant().Trim()).ConfigureAwait(false);
|
await PermissionsHandler.RemoveFilteredWord(e.Server, word.ToLowerInvariant().Trim()).ConfigureAwait(false);
|
||||||
@ -158,7 +158,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
await PermissionsHandler.SetServerWordPermission(e.Server, state).ConfigureAwait(false);
|
await PermissionsHandler.SetServerWordPermission(e.Server, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** on this server.")
|
await channel.SendMessageAsync($"Word filtering has been **{(state ? "enabled" : "disabled")}** on this server.")
|
||||||
.ConfigureAwait(false);
|
.ConfigureAwait(false);
|
||||||
|
@ -37,13 +37,13 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Parameter("role", ParameterType.Unparsed)
|
.Parameter("role", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
if (string.IsNullOrWhiteSpace(e.GetArg("role")))
|
if (string.IsNullOrWhiteSpace(role))
|
||||||
{
|
{
|
||||||
await channel.SendMessageAsync($"Current permissions role is `{PermissionsHandler.GetServerPermissionsRoleName(e.Server)}`").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Current permissions role is `{PermissionsHandler.GetServerPermissionsRoleName(e.Server)}`").ConfigureAwait(false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var arg = e.GetArg("role");
|
var arg = role;
|
||||||
Discord.Role role = null;
|
Discord.Role role = null;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -65,7 +65,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Parameter("from_to", ParameterType.Unparsed)
|
.Parameter("from_to", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("from_to")?.Trim();
|
var arg = from_to?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(arg) || !arg.Contains('~'))
|
if (string.IsNullOrWhiteSpace(arg) || !arg.Contains('~'))
|
||||||
return;
|
return;
|
||||||
var args = arg.Split('~').Select(a => a.Trim()).ToArray();
|
var args = arg.Split('~').Select(a => a.Trim()).ToArray();
|
||||||
@ -93,7 +93,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Parameter("from_to", ParameterType.Unparsed)
|
.Parameter("from_to", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("from_to")?.Trim();
|
var arg = from_to?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(arg) || !arg.Contains('~'))
|
if (string.IsNullOrWhiteSpace(arg) || !arg.Contains('~'))
|
||||||
return;
|
return;
|
||||||
var args = arg.Split('~').Select(a => a.Trim()).ToArray();
|
var args = arg.Split('~').Select(a => a.Trim()).ToArray();
|
||||||
@ -121,7 +121,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Parameter("from_to", ParameterType.Unparsed)
|
.Parameter("from_to", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("from_to")?.Trim();
|
var arg = from_to?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(arg) || !arg.Contains('~'))
|
if (string.IsNullOrWhiteSpace(arg) || !arg.Contains('~'))
|
||||||
return;
|
return;
|
||||||
var args = arg.Split('~').Select(a => a.Trim()).ToArray();
|
var args = arg.Split('~').Select(a => a.Trim()).ToArray();
|
||||||
@ -150,7 +150,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Parameter("arg", ParameterType.Required)
|
.Parameter("arg", ParameterType.Required)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("arg");
|
var arg = arg;
|
||||||
var val = PermissionHelper.ValidateBool(arg);
|
var val = PermissionHelper.ValidateBool(arg);
|
||||||
await PermissionsHandler.SetVerbosity(e.Server, val).ConfigureAwait(false);
|
await PermissionsHandler.SetVerbosity(e.Server, val).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Verbosity set to {val}.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Verbosity set to {val}.").ConfigureAwait(false);
|
||||||
@ -173,7 +173,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Parameter("role", ParameterType.Unparsed)
|
.Parameter("role", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("role");
|
var arg = role;
|
||||||
var role = e.Server.EveryoneRole;
|
var role = e.Server.EveryoneRole;
|
||||||
if (!string.IsNullOrWhiteSpace(arg))
|
if (!string.IsNullOrWhiteSpace(arg))
|
||||||
try
|
try
|
||||||
@ -199,7 +199,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Parameter("channel", ParameterType.Unparsed)
|
.Parameter("channel", ParameterType.Unparsed)
|
||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("channel");
|
var arg = channel;
|
||||||
var channel = e.Channel;
|
var channel = e.Channel;
|
||||||
if (!string.IsNullOrWhiteSpace(arg))
|
if (!string.IsNullOrWhiteSpace(arg))
|
||||||
try
|
try
|
||||||
@ -225,10 +225,10 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
.Do(async e =>
|
.Do(async e =>
|
||||||
{
|
{
|
||||||
var user = imsg.Author;
|
var user = imsg.Author;
|
||||||
if (!string.IsNullOrWhiteSpace(e.GetArg("user")))
|
if (!string.IsNullOrWhiteSpace(user))
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
user = PermissionHelper.ValidateUser(e.Server, user);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
@ -251,8 +251,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(module);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
|
|
||||||
await PermissionsHandler.SetServerModulePermission(e.Server, module, state).ConfigureAwait(false);
|
await PermissionsHandler.SetServerModulePermission(e.Server, module, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
||||||
@ -275,8 +275,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
var command = PermissionHelper.ValidateCommand(command);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
|
|
||||||
await PermissionsHandler.SetServerCommandPermission(e.Server, command, state).ConfigureAwait(false);
|
await PermissionsHandler.SetServerCommandPermission(e.Server, command, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** on this server.").ConfigureAwait(false);
|
||||||
@ -300,10 +300,10 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(module);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
|
|
||||||
if (e.GetArg("role")?.ToLower() == "all")
|
if (role?.ToLower() == "all")
|
||||||
{
|
{
|
||||||
foreach (var role in e.Server.Roles)
|
foreach (var role in e.Server.Roles)
|
||||||
{
|
{
|
||||||
@ -313,7 +313,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
var role = PermissionHelper.ValidateRole(e.Server, role);
|
||||||
|
|
||||||
await PermissionsHandler.SetRoleModulePermission(role, module, state).ConfigureAwait(false);
|
await PermissionsHandler.SetRoleModulePermission(role, module, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
||||||
@ -338,10 +338,10 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
var command = PermissionHelper.ValidateCommand(command);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
|
|
||||||
if (e.GetArg("role")?.ToLower() == "all")
|
if (role?.ToLower() == "all")
|
||||||
{
|
{
|
||||||
foreach (var role in e.Server.Roles)
|
foreach (var role in e.Server.Roles)
|
||||||
{
|
{
|
||||||
@ -351,7 +351,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
var role = PermissionHelper.ValidateRole(e.Server, role);
|
||||||
|
|
||||||
await PermissionsHandler.SetRoleCommandPermission(role, command, state).ConfigureAwait(false);
|
await PermissionsHandler.SetRoleCommandPermission(role, command, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{role.Name}** role.").ConfigureAwait(false);
|
||||||
@ -376,9 +376,9 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(module);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var channelArg = e.GetArg("channel");
|
var channelArg = channel;
|
||||||
if (channelArg?.ToLower() == "all")
|
if (channelArg?.ToLower() == "all")
|
||||||
{
|
{
|
||||||
foreach (var channel in e.Server.TextChannels)
|
foreach (var channel in e.Server.TextChannels)
|
||||||
@ -419,10 +419,10 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
var command = PermissionHelper.ValidateCommand(command);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
|
|
||||||
if (e.GetArg("channel")?.ToLower() == "all")
|
if (channel?.ToLower() == "all")
|
||||||
{
|
{
|
||||||
foreach (var channel in e.Server.TextChannels)
|
foreach (var channel in e.Server.TextChannels)
|
||||||
{
|
{
|
||||||
@ -432,7 +432,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
var channel = PermissionHelper.ValidateChannel(e.Server, channel);
|
||||||
|
|
||||||
await PermissionsHandler.SetChannelCommandPermission(channel, command, state).ConfigureAwait(false);
|
await PermissionsHandler.SetChannelCommandPermission(channel, command, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for **{channel.Name}** channel.").ConfigureAwait(false);
|
||||||
@ -457,9 +457,9 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(module);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
var user = PermissionHelper.ValidateUser(e.Server, user);
|
||||||
|
|
||||||
await PermissionsHandler.SetUserModulePermission(user, module, state).ConfigureAwait(false);
|
await PermissionsHandler.SetUserModulePermission(user, module, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Module **{module}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false);
|
||||||
@ -483,9 +483,9 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
var command = PermissionHelper.ValidateCommand(command);
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var user = PermissionHelper.ValidateUser(e.Server, e.GetArg("user"));
|
var user = PermissionHelper.ValidateUser(e.Server, user);
|
||||||
|
|
||||||
await PermissionsHandler.SetUserCommandPermission(user, command, state).ConfigureAwait(false);
|
await PermissionsHandler.SetUserCommandPermission(user, command, state).ConfigureAwait(false);
|
||||||
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false);
|
await channel.SendMessageAsync($"Command **{command}** has been **{(state ? "enabled" : "disabled")}** for user **{user.Name}**.").ConfigureAwait(false);
|
||||||
@ -507,7 +507,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
|
|
||||||
foreach (var module in NadekoBot.Client.GetService<ModuleService>().Modules)
|
foreach (var module in NadekoBot.Client.GetService<ModuleService>().Modules)
|
||||||
{
|
{
|
||||||
@ -533,8 +533,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(module);
|
||||||
|
|
||||||
foreach (var command in NadekoBot.Client.GetService<CommandService>().AllCommands.Where(c => c.Category == module))
|
foreach (var command in NadekoBot.Client.GetService<CommandService>().AllCommands.Where(c => c.Category == module))
|
||||||
{
|
{
|
||||||
@ -560,8 +560,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var chArg = e.GetArg("channel");
|
var chArg = channel;
|
||||||
var channel = string.IsNullOrWhiteSpace(chArg) ? e.Channel : PermissionHelper.ValidateChannel(e.Server, chArg);
|
var channel = string.IsNullOrWhiteSpace(chArg) ? e.Channel : PermissionHelper.ValidateChannel(e.Server, chArg);
|
||||||
foreach (var module in NadekoBot.Client.GetService<ModuleService>().Modules)
|
foreach (var module in NadekoBot.Client.GetService<ModuleService>().Modules)
|
||||||
{
|
{
|
||||||
@ -589,9 +589,9 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(module);
|
||||||
var channel = PermissionHelper.ValidateChannel(e.Server, e.GetArg("channel"));
|
var channel = PermissionHelper.ValidateChannel(e.Server, channel);
|
||||||
foreach (var command in NadekoBot.Client.GetService<CommandService>().AllCommands.Where(c => c.Category == module))
|
foreach (var command in NadekoBot.Client.GetService<CommandService>().AllCommands.Where(c => c.Category == module))
|
||||||
{
|
{
|
||||||
await PermissionsHandler.SetChannelCommandPermission(channel, command.Text, state).ConfigureAwait(false);
|
await PermissionsHandler.SetChannelCommandPermission(channel, command.Text, state).ConfigureAwait(false);
|
||||||
@ -616,8 +616,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
var role = PermissionHelper.ValidateRole(e.Server, role);
|
||||||
foreach (var module in NadekoBot.Client.GetService<ModuleService>().Modules)
|
foreach (var module in NadekoBot.Client.GetService<ModuleService>().Modules)
|
||||||
{
|
{
|
||||||
await PermissionsHandler.SetRoleModulePermission(role, module.Name, state).ConfigureAwait(false);
|
await PermissionsHandler.SetRoleModulePermission(role, module.Name, state).ConfigureAwait(false);
|
||||||
@ -644,9 +644,9 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var state = PermissionHelper.ValidateBool(e.GetArg("bool"));
|
var state = PermissionHelper.ValidateBool(bool);
|
||||||
var module = PermissionHelper.ValidateModule(e.GetArg("module"));
|
var module = PermissionHelper.ValidateModule(module);
|
||||||
if (e.GetArg("role")?.ToLower() == "all")
|
if (role?.ToLower() == "all")
|
||||||
{
|
{
|
||||||
foreach (var role in e.Server.Roles)
|
foreach (var role in e.Server.Roles)
|
||||||
{
|
{
|
||||||
@ -659,7 +659,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
var role = PermissionHelper.ValidateRole(e.Server, e.GetArg("role"));
|
var role = PermissionHelper.ValidateRole(e.Server, role);
|
||||||
|
|
||||||
foreach (var command in NadekoBot.Client.GetService<CommandService>().AllCommands.Where(c => c.Category == module))
|
foreach (var command in NadekoBot.Client.GetService<CommandService>().AllCommands.Where(c => c.Category == module))
|
||||||
{
|
{
|
||||||
@ -755,7 +755,7 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
await Task.Run(async () =>
|
await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
var arg = e.GetArg("server")?.Trim();
|
var arg = server?.Trim();
|
||||||
if (string.IsNullOrWhiteSpace(arg))
|
if (string.IsNullOrWhiteSpace(arg))
|
||||||
return;
|
return;
|
||||||
var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
|
var server = NadekoBot.Client.Servers.FirstOrDefault(s => s.Id.ToString() == arg) ??
|
||||||
@ -788,8 +788,8 @@ namespace NadekoBot.Modules.Permissions
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var command = PermissionHelper.ValidateCommand(e.GetArg("command"));
|
var command = PermissionHelper.ValidateCommand(command);
|
||||||
var secsStr = e.GetArg("secs").Trim();
|
var secsStr = secs.Trim();
|
||||||
int secs;
|
int secs;
|
||||||
if (!int.TryParse(secsStr, out secs) || secs < 0 || secs > 3600)
|
if (!int.TryParse(secsStr, out secs) || secs < 0 || secs > 3600)
|
||||||
throw new ArgumentOutOfRangeException("secs", "Invalid second parameter. (Must be a number between 0 and 3600)");
|
throw new ArgumentOutOfRangeException("secs", "Invalid second parameter. (Must be a number between 0 and 3600)");
|
||||||
|
Loading…
Reference in New Issue
Block a user