less delay on radio links, smarter shortenurl, fixes to rr (thx to HySy)
This commit is contained in:
parent
b1ac645b1f
commit
bf81b803db
@ -258,7 +258,8 @@ namespace NadekoBot.Classes.Music {
|
||||
// prebuffering wait stuff start
|
||||
int bufferAttempts = 0;
|
||||
int waitPerAttempt = 500;
|
||||
while (!prebufferingComplete && bufferAttempts++ < 15) {
|
||||
int toAttemptTimes = parent.RadioLink ? 4 : 8;
|
||||
while (!prebufferingComplete && bufferAttempts++ < toAttemptTimes) {
|
||||
await Task.Delay(waitPerAttempt);
|
||||
}
|
||||
if (prebufferingComplete) {
|
||||
|
@ -208,9 +208,9 @@ namespace NadekoBot.Classes {
|
||||
}
|
||||
|
||||
public static async Task<string> ShortenUrl(string url) {
|
||||
if (NadekoBot.GoogleAPIKey == null || NadekoBot.GoogleAPIKey == "") return url;
|
||||
if (NadekoBot.creds.GoogleAPIKey == null || NadekoBot.creds.GoogleAPIKey == "") return url;
|
||||
try {
|
||||
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" + NadekoBot.GoogleAPIKey);
|
||||
var httpWebRequest = (HttpWebRequest)WebRequest.Create("https://www.googleapis.com/urlshortener/v1/url?key=" + NadekoBot.creds.GoogleAPIKey);
|
||||
httpWebRequest.ContentType = "application/json";
|
||||
httpWebRequest.Method = "POST";
|
||||
|
||||
@ -225,7 +225,7 @@ namespace NadekoBot.Classes {
|
||||
string MATCH_PATTERN = @"""id"": ?""(?<id>.+)""";
|
||||
return Regex.Match(responseText, MATCH_PATTERN).Groups["id"].Value;
|
||||
}
|
||||
} catch (Exception ex) { Console.WriteLine(ex.ToString()); return ""; }
|
||||
} catch (Exception ex) { Console.WriteLine(ex.ToString()); return url; }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,8 @@ namespace NadekoBot.Modules {
|
||||
.Parameter("user_name", ParameterType.Required)
|
||||
.Parameter("role_name", ParameterType.Unparsed)
|
||||
.Do(async e => {
|
||||
if (!e.User.ServerPermissions.ManageRoles) return;
|
||||
if (!e.User.ServerPermissions.ManageRoles ||
|
||||
string.IsNullOrWhiteSpace(e.GetArg("role_name"))) return;
|
||||
var usr = e.Server.FindUsers(e.GetArg("user_name")).FirstOrDefault();
|
||||
if (usr == null) {
|
||||
await e.Send("You failed to supply a valid username");
|
||||
@ -61,9 +62,10 @@ namespace NadekoBot.Modules {
|
||||
cgb.CreateCommand(".rr").Alias(".removerole")
|
||||
.Description("Removes a role from a given user.\n**Usage**: .rr @User Admin")
|
||||
.Parameter("user_name", ParameterType.Required)
|
||||
.Parameter("role_name", ParameterType.Required)
|
||||
.Parameter("role_name", ParameterType.Unparsed)
|
||||
.Do(async e => {
|
||||
if (!e.User.ServerPermissions.ManageRoles) return;
|
||||
if (!e.User.ServerPermissions.ManageRoles ||
|
||||
string.IsNullOrWhiteSpace("role_name")) return;
|
||||
|
||||
var usr = e.Server.FindUsers(e.GetArg("user_name")).FirstOrDefault();
|
||||
if (usr == null) {
|
||||
|
Loading…
Reference in New Issue
Block a user