missing key

This commit is contained in:
Kwoth 2017-03-05 16:09:54 +01:00
parent f37a2c4db9
commit e741e84190
7 changed files with 133 additions and 4 deletions

View File

@ -0,0 +1,78 @@
using System.Collections.Generic;
using System.Linq;
using System.Net.Http;
using System.Threading.Tasks;
using Discord.Commands;
using Discord;
using NadekoBot.Attributes;
using NadekoBot.Modules.Utility.Models;
using Newtonsoft.Json;
namespace NadekoBot.Modules.Utility
{
public partial class Utility
{
//[Group]
//public class PatreonCommands : NadekoSubmodule
//{
// [NadekoCommand, Usage, Description, Aliases]
// [RequireContext(ContextType.Guild)]
// public async Task ClaimPatreonRewards([Remainder] string arg)
// {
// var pledges = await GetPledges2();
// }
// private static async Task<Pledge[]> GetPledges()
// {
// var pledges = new List<Pledge>();
// using (var http = new HttpClient())
// {
// http.DefaultRequestHeaders.Clear();
// http.DefaultRequestHeaders.Add("Authorization", "Bearer " + NadekoBot.Credentials.PatreonAccessToken);
// var data = new PatreonData()
// {
// Links = new Links()
// {
// Next = "https://api.patreon.com/oauth2/api/campaigns/334038/pledges"
// }
// };
// do
// {
// var res =
// await http.GetStringAsync(data.Links.Next)
// .ConfigureAwait(false);
// data = JsonConvert.DeserializeObject<PatreonData>(res);
// pledges.AddRange(data.Data);
// } while (!string.IsNullOrWhiteSpace(data.Links.Next));
// }
// return pledges.Where(x => string.IsNullOrWhiteSpace(x.Attributes.declined_since)).ToArray();
// }
// private static async Task<Pledge[]> GetPledges2()
// {
// var pledges = new List<Pledge>();
// using (var http = new HttpClient())
// {
// http.DefaultRequestHeaders.Clear();
// http.DefaultRequestHeaders.Add("Authorization", "Bearer " + NadekoBot.Credentials.PatreonAccessToken);
// var data = new PatreonData()
// {
// Links = new Links()
// {
// Next = "https://api.patreon.com/oauth2/api/current_user/campaigns?include=pledges"
// }
// };
// do
// {
// var res =
// await http.GetStringAsync(data.Links.Next)
// .ConfigureAwait(false);
// data = JsonConvert.DeserializeObject<PatreonData>(res);
// pledges.AddRange(data.Data);
// } while (!string.IsNullOrWhiteSpace(data.Links.Next));
// }
// return pledges.Where(x => string.IsNullOrWhiteSpace(x.Attributes.declined_since)).ToArray();
// }
//}
}
}

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace NadekoBot.Modules.Utility.Models
{
public class PatreonData
{
public Pledge[] Data { get; set; }
public Links Links { get; set; }
}
public class Attributes
{
public int amount_cents { get; set; }
public string created_at { get; set; }
public string declined_since { get; set; }
public bool is_twitch_pledge { get; set; }
public bool patron_pays_fees { get; set; }
public int pledge_cap_cents { get; set; }
}
public class Pledge
{
public Attributes Attributes { get; set; }
public int Id { get; set; }
}
public class Links
{
public string First { get; set; }
public string Next { get; set; }
}
}

View File

@ -2081,6 +2081,15 @@ namespace NadekoBot.Resources {
} }
} }
/// <summary>
/// Looks up a localized string similar to You&apos;ve already joined this race!.
/// </summary>
public static string gambling_animal_race_already_in {
get {
return ResourceManager.GetString("gambling_animal_race_already_in", resourceCulture);
}
}
/// <summary> /// <summary>
/// Looks up a localized string similar to Animal Race is already running.. /// Looks up a localized string similar to Animal Race is already running..
/// </summary> /// </summary>

View File

@ -1218,6 +1218,9 @@ Don't forget to leave your discord name or id in the message.
<data name="gambling_animal_race_already_started" xml:space="preserve"> <data name="gambling_animal_race_already_started" xml:space="preserve">
<value>Animal Race is already running.</value> <value>Animal Race is already running.</value>
</data> </data>
<data name="gambling_animal_race_already_in" xml:space="preserve">
<value>You've already joined this race!</value>
</data>
<data name="gambling_total_average" xml:space="preserve"> <data name="gambling_total_average" xml:space="preserve">
<value>Total: {0} Average: {1}</value> <value>Total: {0} Average: {1}</value>
</data> </data>

View File

@ -7,13 +7,13 @@ namespace NadekoBot.Services
public interface IBotCredentials public interface IBotCredentials
{ {
ulong ClientId { get; } ulong ClientId { get; }
ulong BotId { get; }
string Token { get; } string Token { get; }
string GoogleApiKey { get; } string GoogleApiKey { get; }
ImmutableHashSet<ulong> OwnerIds { get; } ImmutableHashSet<ulong> OwnerIds { get; }
string MashapeKey { get; } string MashapeKey { get; }
string LoLApiKey { get; } string LoLApiKey { get; }
string PatreonAccessToken { get; }
DBConfig Db { get; } DBConfig Db { get; }

View File

@ -5,7 +5,6 @@ using Discord;
using System.Linq; using System.Linq;
using NLog; using NLog;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using System.Collections.Generic;
using System.Collections.Immutable; using System.Collections.Immutable;
namespace NadekoBot.Services.Impl namespace NadekoBot.Services.Impl
@ -15,7 +14,6 @@ namespace NadekoBot.Services.Impl
private Logger _log; private Logger _log;
public ulong ClientId { get; } public ulong ClientId { get; }
public ulong BotId { get; }
public string GoogleApiKey { get; } public string GoogleApiKey { get; }
@ -44,6 +42,7 @@ namespace NadekoBot.Services.Impl
public string CarbonKey { get; } public string CarbonKey { get; }
public string credsFileName { get; } = Path.Combine(Directory.GetCurrentDirectory(), "credentials.json"); public string credsFileName { get; } = Path.Combine(Directory.GetCurrentDirectory(), "credentials.json");
public string PatreonAccessToken { get; }
public BotCredentials() public BotCredentials()
{ {
@ -68,6 +67,7 @@ namespace NadekoBot.Services.Impl
GoogleApiKey = data[nameof(GoogleApiKey)]; GoogleApiKey = data[nameof(GoogleApiKey)];
MashapeKey = data[nameof(MashapeKey)]; MashapeKey = data[nameof(MashapeKey)];
OsuApiKey = data[nameof(OsuApiKey)]; OsuApiKey = data[nameof(OsuApiKey)];
PatreonAccessToken = data[nameof(PatreonAccessToken)];
int ts = 1; int ts = 1;
int.TryParse(data[nameof(TotalShards)], out ts); int.TryParse(data[nameof(TotalShards)], out ts);
@ -109,6 +109,7 @@ namespace NadekoBot.Services.Impl
public string CarbonKey { get; set; } = ""; public string CarbonKey { get; set; } = "";
public DBConfig Db { get; set; } = new DBConfig("sqlite", "Filename=./data/NadekoBot.db"); public DBConfig Db { get; set; } = new DBConfig("sqlite", "Filename=./data/NadekoBot.db");
public int TotalShards { get; set; } = 1; public int TotalShards { get; set; } = 1;
public string PatreonAccessToken { get; set; } = "";
} }
private class DbModel private class DbModel

View File

@ -14,5 +14,6 @@
"Type": "sqlite", "Type": "sqlite",
"ConnectionString": "Filename=./data/NadekoBot.db" "ConnectionString": "Filename=./data/NadekoBot.db"
}, },
"TotalShards": 1 "TotalShards": 1,
"PatreonAccessToken": ""
} }