Fixed custom reactions self-trigger, fixed bot credentials example

This commit is contained in:
Kwoth 2016-10-14 21:54:26 +02:00
parent 2e046b9fe9
commit c46fd50c12
2 changed files with 11 additions and 9 deletions

View File

@ -33,7 +33,7 @@ namespace NadekoBot.Modules.CustomReactions
client.MessageReceived += (imsg) => client.MessageReceived += (imsg) =>
{ {
var umsg = imsg as IUserMessage; var umsg = imsg as IUserMessage;
if (umsg == null) if (umsg == null || imsg.Author.IsBot)
return Task.CompletedTask; return Task.CompletedTask;
var channel = umsg.Channel as ITextChannel; var channel = umsg.Channel as ITextChannel;

View File

@ -33,6 +33,8 @@ namespace NadekoBot.Services.Impl
public BotCredentials() public BotCredentials()
{ {
_log = LogManager.GetCurrentClassLogger(); _log = LogManager.GetCurrentClassLogger();
try { File.WriteAllText("./credentials_example.json", JsonConvert.SerializeObject(new CredentialsModel(), Formatting.Indented)); } catch { }
if (File.Exists("./credentials.json")) if (File.Exists("./credentials.json"))
{ {
var cm = JsonConvert.DeserializeObject<CredentialsModel>(File.ReadAllText("./credentials.json")); var cm = JsonConvert.DeserializeObject<CredentialsModel>(File.ReadAllText("./credentials.json"));
@ -52,23 +54,23 @@ namespace NadekoBot.Services.Impl
} }
else else
{ {
File.WriteAllText("./credentials_example.json", JsonConvert.SerializeObject(new CredentialsModel(), Formatting.Indented)); _log.Fatal($"credentials.json is missing. Failed to start. Example is in {Path.GetFullPath("./credentials_example.json")}");
_log.Fatal($"credentials.json is missing. Failed to start. Example written to {Path.GetFullPath("./credentials_example.json")}");
throw new FileNotFoundException(); throw new FileNotFoundException();
} }
} }
private class CredentialsModel private class CredentialsModel
{ {
public ulong ClientId { get; set; } public ulong ClientId { get; set; } = 123123123;
public ulong? BotId { get; set; } public ulong? BotId { get; set; }
public string Token { get; set; } = ""; public string Token { get; set; } = "";
public ulong[] OwnerIds { get; set; } = new ulong[1]; public ulong[] OwnerIds { get; set; } = new ulong[1];
public string LoLApiKey { get; set; } public string LoLApiKey { get; set; } = "";
public string GoogleApiKey { get; set; } public string GoogleApiKey { get; set; } = "";
public string MashapeKey { get; set; } public string MashapeKey { get; set; } = "";
public string OsuApiKey { get; set; } public string OsuApiKey { get; set; } = "";
public string SoundCloudClientId { get; set; } public string SoundCloudClientId { get; set; } = "";
public DB Db { get; set; } public DB Db { get; set; }
public int TotalShards { get; set; } = 1; public int TotalShards { get; set; } = 1;
} }