bugfix, added option in config to forward messages to all owners.
This commit is contained in:
parent
f1b839337a
commit
57bc26dd46
@ -92,7 +92,7 @@ namespace NadekoBot.Modules.Games.Commands
|
|||||||
e.Channel.SendMessage($"There is already a {NadekoBot.Config.CurrencyName} in this channel.");
|
e.Channel.SendMessage($"There is already a {NadekoBot.Config.CurrencyName} in this channel.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
var removed = FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1);
|
var removed = FlowersHandler.RemoveFlowers(e.User, "Planted a flower.", 1).GetAwaiter().GetResult();
|
||||||
if (!removed)
|
if (!removed)
|
||||||
{
|
{
|
||||||
e.Channel.SendMessage($"You don't have any {NadekoBot.Config.CurrencyName}s.").Wait();
|
e.Channel.SendMessage($"You don't have any {NadekoBot.Config.CurrencyName}s.").Wait();
|
||||||
|
@ -42,7 +42,7 @@ namespace NadekoBot
|
|||||||
public static string BotMention { get; set; } = "";
|
public static string BotMention { get; set; } = "";
|
||||||
public static bool Ready { get; set; } = false;
|
public static bool Ready { get; set; } = false;
|
||||||
|
|
||||||
private static Channel OwnerPrivateChannel { get; set; }
|
private static List<Channel> OwnerPrivateChannels { get; set; }
|
||||||
|
|
||||||
private static void Main()
|
private static void Main()
|
||||||
{
|
{
|
||||||
@ -205,15 +205,19 @@ namespace NadekoBot
|
|||||||
Console.WriteLine(await NadekoStats.Instance.GetStats().ConfigureAwait(false));
|
Console.WriteLine(await NadekoStats.Instance.GetStats().ConfigureAwait(false));
|
||||||
Console.WriteLine("-----------------");
|
Console.WriteLine("-----------------");
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
OwnerPrivateChannel = await Client.CreatePrivateChannel(Creds.OwnerIds[0]).ConfigureAwait(false);
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
Console.WriteLine("Failed creating private channel with the first owner listed in credentials.json");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
OwnerPrivateChannels = new List<Channel>(Creds.OwnerIds.Length);
|
||||||
|
foreach (var id in Creds.OwnerIds)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OwnerPrivateChannels.Add(await Client.CreatePrivateChannel(id).ConfigureAwait(false));
|
||||||
|
}
|
||||||
|
catch
|
||||||
|
{
|
||||||
|
Console.WriteLine($"Failed creating private channel with the owner {id} listed in credentials.json");
|
||||||
|
}
|
||||||
|
}
|
||||||
Client.ClientAPI.SendingRequest += (s, e) =>
|
Client.ClientAPI.SendingRequest += (s, e) =>
|
||||||
{
|
{
|
||||||
var request = e.Request as Discord.API.Client.Rest.SendMessageRequest;
|
var request = e.Request as Discord.API.Client.Rest.SendMessageRequest;
|
||||||
@ -234,8 +238,18 @@ namespace NadekoBot
|
|||||||
|
|
||||||
public static async Task SendMessageToOwner(string message)
|
public static async Task SendMessageToOwner(string message)
|
||||||
{
|
{
|
||||||
if (Config.ForwardMessages && OwnerPrivateChannel != null)
|
if (Config.ForwardMessages && OwnerPrivateChannels.Any())
|
||||||
await OwnerPrivateChannel.SendMessage(message).ConfigureAwait(false);
|
if (Config.ForwardToAllOwners)
|
||||||
|
OwnerPrivateChannels.ForEach(async c =>
|
||||||
|
{
|
||||||
|
try { await c.SendMessage(message).ConfigureAwait(false); } catch { }
|
||||||
|
});
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var c = OwnerPrivateChannels.FirstOrDefault();
|
||||||
|
if (c != null)
|
||||||
|
await c.SendMessage(message).ConfigureAwait(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool repliedRecently = false;
|
private static bool repliedRecently = false;
|
||||||
@ -248,8 +262,8 @@ namespace NadekoBot
|
|||||||
if (ConfigHandler.IsBlackListed(e))
|
if (ConfigHandler.IsBlackListed(e))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannel != null)
|
if (Config.ForwardMessages && !NadekoBot.Creds.OwnerIds.Contains(e.User.Id) && OwnerPrivateChannels.Any())
|
||||||
await OwnerPrivateChannel.SendMessage(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false);
|
await SendMessageToOwner(e.User + ": ```\n" + e.Message.Text + "\n```").ConfigureAwait(false);
|
||||||
|
|
||||||
if (repliedRecently) return;
|
if (repliedRecently) return;
|
||||||
|
|
||||||
|
@ -84,6 +84,7 @@ namespace NadekoBot.Classes.JSONModels
|
|||||||
|
|
||||||
public bool DontJoinServers { get; set; } = false;
|
public bool DontJoinServers { get; set; } = false;
|
||||||
public bool ForwardMessages { get; set; } = true;
|
public bool ForwardMessages { get; set; } = true;
|
||||||
|
public bool ForwardToAllOwners { get; set; } = false;
|
||||||
public bool IsRotatingStatus { get; set; } = false;
|
public bool IsRotatingStatus { get; set; } = false;
|
||||||
public int BufferSize { get; set; } = 4.MiB();
|
public int BufferSize { get; set; } = 4.MiB();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user