Prefixes in strings, fixed CI?

This commit is contained in:
Kwoth 2016-09-15 17:31:02 +02:00
parent 0794137232
commit 8fa90348a3
6 changed files with 31 additions and 20 deletions

View File

@ -12,9 +12,16 @@ namespace NadekoBot.Modules
protected CommandService _commands { get; } protected CommandService _commands { get; }
protected DiscordSocketClient _client { get; } protected DiscordSocketClient _client { get; }
protected Logger _log { get; } protected Logger _log { get; }
private string _prefix { get; }
public DiscordModule(ILocalization loc, CommandService cmds, DiscordSocketClient client) public DiscordModule(ILocalization loc, CommandService cmds, DiscordSocketClient client)
{ {
string prefix;
if (NadekoBot.ModulePrefixes.TryGetValue(this.GetType().Name, out prefix))
_prefix = prefix;
else
_prefix = "?missing_prefix?";
_l = loc; _l = loc;
_commands = cmds; _commands = cmds;
_client = client; _client = client;

View File

@ -18,6 +18,10 @@ namespace NadekoBot.Modules.Gambling
[Group] [Group]
public class AnimalRacing public class AnimalRacing
{ {
public AnimalRacing()
{
}
public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces = new ConcurrentDictionary<ulong, AnimalRace>(); public static ConcurrentDictionary<ulong, AnimalRace> AnimalRaces = new ConcurrentDictionary<ulong, AnimalRace>();
[LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias] [LocalizedCommand, LocalizedDescription, LocalizedSummary, LocalizedAlias]
@ -92,8 +96,7 @@ namespace NadekoBot.Modules.Gambling
{ {
try try
{ {
//todo Commmand prefixes from config await raceChannel.SendMessageAsync($"🏁`Race is starting in 20 seconds or when the room is full. Type {NadekoBot.ModulePrefixes["Gambling"]}jr to join the race.`");
await raceChannel.SendMessageAsync($"🏁`Race is starting in 20 seconds or when the room is full. Type $jr to join the race.`");
var t = await Task.WhenAny(Task.Delay(20000, token), fullgame); var t = await Task.WhenAny(Task.Delay(20000, token), fullgame);
Started = true; Started = true;
cancelSource.Cancel(); cancelSource.Cancel();

View File

@ -28,7 +28,6 @@ namespace NadekoBot.Modules.Games
[Group] [Group]
public class PlantPickCommands public class PlantPickCommands
{ {
private Random rng; private Random rng;
private ConcurrentDictionary<ulong, bool> generationChannels = new ConcurrentDictionary<ulong, bool>(); private ConcurrentDictionary<ulong, bool> generationChannels = new ConcurrentDictionary<ulong, bool>();
@ -83,12 +82,11 @@ namespace NadekoBot.Modules.Games
if (num > 100) if (num > 100)
{ {
lastGenerations.AddOrUpdate(channel.Id, DateTime.Now, (id, old) => DateTime.Now); lastGenerations.AddOrUpdate(channel.Id, DateTime.Now, (id, old) => DateTime.Now);
//todo get prefix
try try
{ {
var sent = await channel.SendFileAsync( var sent = await channel.SendFileAsync(
GetRandomCurrencyImagePath(), GetRandomCurrencyImagePath(),
$"❗ A random { Gambling.Gambling.CurrencyName } appeared! Pick it up by typing `>pick`") $"❗ A random { Gambling.Gambling.CurrencyName } appeared! Pick it up by typing `{NadekoBot.ModulePrefixes["Gambling"]}pick`")
.ConfigureAwait(false); .ConfigureAwait(false);
plantedFlowers.AddOrUpdate(channel.Id, new List<IUserMessage>() { sent }, (id, old) => { old.Add(sent); return old; }); plantedFlowers.AddOrUpdate(channel.Id, new List<IUserMessage>() { sent }, (id, old) => { old.Add(sent); return old; });
} }
@ -149,8 +147,8 @@ namespace NadekoBot.Modules.Games
var file = GetRandomCurrencyImagePath(); var file = GetRandomCurrencyImagePath();
IUserMessage msg; IUserMessage msg;
var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(Gambling.Gambling.CurrencyName[0]); var vowelFirst = new[] { 'a', 'e', 'i', 'o', 'u' }.Contains(Gambling.Gambling.CurrencyName[0]);
//todo add prefix
var msgToSend = $"Oh how Nice! **{imsg.Author.Username}** planted {(vowelFirst ? "an" : "a")} {Gambling.Gambling.CurrencyName}. Pick it using >pick"; var msgToSend = $"Oh how Nice! **{imsg.Author.Username}** planted {(vowelFirst ? "an" : "a")} {Gambling.Gambling.CurrencyName}. Pick it using {NadekoBot.ModulePrefixes["Games"]}pick";
if (file == null) if (file == null)
{ {
msg = await channel.SendMessageAsync(Gambling.Gambling.CurrencySign).ConfigureAwait(false); msg = await channel.SendMessageAsync(Gambling.Gambling.CurrencySign).ConfigureAwait(false);

View File

@ -12,11 +12,8 @@ using System.Diagnostics;
using System.Linq; using System.Linq;
using System.Reflection; using System.Reflection;
using System.Threading.Tasks; using System.Threading.Tasks;
using NLog.Fluent; using System.Collections.Generic;
using Microsoft.EntityFrameworkCore.Infrastructure; using System.Collections.ObjectModel;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Migrations.Operations;
using Microsoft.EntityFrameworkCore;
namespace NadekoBot namespace NadekoBot
{ {
@ -33,6 +30,8 @@ namespace NadekoBot
public static GoogleApiService Google { get; private set; } public static GoogleApiService Google { get; private set; }
public static StatsService Stats { get; private set; } public static StatsService Stats { get; private set; }
public static IReadOnlyDictionary<string, string> ModulePrefixes { get; private set; }
public async Task RunAsync(string[] args) public async Task RunAsync(string[] args)
{ {
SetupLogger(); SetupLogger();
@ -70,7 +69,11 @@ namespace NadekoBot
_log.Info("Connected"); _log.Info("Connected");
//load commands //load commands and prefixes
using (var uow = DbHandler.UnitOfWork())
{
ModulePrefixes = new ReadOnlyDictionary<string, string>(uow.BotConfig.GetOrCreate().ModulePrefixes.ToDictionary(m => m.ModuleName, m => m.Prefix));
}
await Commands.LoadAssembly(Assembly.GetEntryAssembly(), depMap).ConfigureAwait(false); await Commands.LoadAssembly(Assembly.GetEntryAssembly(), depMap).ConfigureAwait(false);
Console.WriteLine(await Stats.Print().ConfigureAwait(false)); Console.WriteLine(await Stats.Print().ConfigureAwait(false));

View File

@ -35,7 +35,7 @@
"Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Design": "1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Sqlite": "1.0.0", "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0",
"CoreCLR-NCalc": "2.1.0", "CoreCLR-NCalc": "2.1.0",
"ImageProcessorCore": "1.0.0-alpha-1021" "ImageProcessorCore": "1.0.0-alpha1045"
}, },
"tools": { "tools": {
"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final" "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"

View File

@ -146,7 +146,7 @@
"lib/netstandard1.3/Google.Apis.YouTube.v3.dll": {} "lib/netstandard1.3/Google.Apis.YouTube.v3.dll": {}
} }
}, },
"ImageProcessorCore/1.0.0-alpha-1021": { "ImageProcessorCore/1.0.0-alpha1045": {
"type": "package", "type": "package",
"dependencies": { "dependencies": {
"System.Collections": "4.0.11", "System.Collections": "4.0.11",
@ -3411,12 +3411,12 @@
"lib/portable-net45+netcore45+wpa81+wp8/Google.Apis.YouTube.v3.xml" "lib/portable-net45+netcore45+wpa81+wp8/Google.Apis.YouTube.v3.xml"
] ]
}, },
"ImageProcessorCore/1.0.0-alpha-1021": { "ImageProcessorCore/1.0.0-alpha1045": {
"sha512": "ItWOgl9z3E67X5WW6Qp9U0E8rmD9ZkBFPeywkuODASCEfuArc+g5viRo6cD8lXyu2TXDE/LAYlsvu6X5dSOP9w==", "sha512": "A5oL7SwFnzcu5eF26u49nf73joQghpEpCGwLb54dm6VI6ZGpjBJpKAyNKtJP30HtXy1VngiGJn/EcvCl8+JGcg==",
"type": "package", "type": "package",
"path": "ImageProcessorCore/1.0.0-alpha-1021", "path": "ImageProcessorCore/1.0.0-alpha1045",
"files": [ "files": [
"ImageProcessorCore.1.0.0-alpha-1021.nupkg.sha512", "ImageProcessorCore.1.0.0-alpha1045.nupkg.sha512",
"ImageProcessorCore.nuspec", "ImageProcessorCore.nuspec",
"lib/netstandard1.1/ImageProcessorCore.dll" "lib/netstandard1.1/ImageProcessorCore.dll"
] ]
@ -9100,7 +9100,7 @@
"Google.Apis.Customsearch.v1 >= 1.16.0.466", "Google.Apis.Customsearch.v1 >= 1.16.0.466",
"Google.Apis.Urlshortener.v1 >= 1.15.0.138", "Google.Apis.Urlshortener.v1 >= 1.15.0.138",
"Google.Apis.YouTube.v3 >= 1.15.0.582", "Google.Apis.YouTube.v3 >= 1.15.0.582",
"ImageProcessorCore >= 1.0.0-alpha-1021", "ImageProcessorCore >= 1.0.0-alpha1045",
"Microsoft.EntityFrameworkCore >= 1.0.0", "Microsoft.EntityFrameworkCore >= 1.0.0",
"Microsoft.EntityFrameworkCore.Design >= 1.0.0-preview2-final", "Microsoft.EntityFrameworkCore.Design >= 1.0.0-preview2-final",
"Microsoft.EntityFrameworkCore.Sqlite >= 1.0.0", "Microsoft.EntityFrameworkCore.Sqlite >= 1.0.0",