disabled private poll, removed shardid command
This commit is contained in:
parent
c709680413
commit
4862564c74
@ -44,9 +44,14 @@ namespace NadekoBot.Modules.Games
|
|||||||
|
|
||||||
await Context.Channel.EmbedAsync(poll.GetStats(GetText("current_poll_results")));
|
await Context.Channel.EmbedAsync(poll.GetStats(GetText("current_poll_results")));
|
||||||
}
|
}
|
||||||
|
//todo enable private polls, or completely remove them
|
||||||
private async Task InternalStartPoll(string arg, bool isPublic = false)
|
private async Task InternalStartPoll(string arg, bool isPublic = false)
|
||||||
{
|
{
|
||||||
|
if (isPublic == false)
|
||||||
|
{
|
||||||
|
await ReplyErrorLocalized($"Temporarily disabled. Use `{Prefix}ppoll`");
|
||||||
|
return;
|
||||||
|
}
|
||||||
if(await _polls.StartPoll((ITextChannel)Context.Channel, Context.Message, arg, isPublic) == false)
|
if(await _polls.StartPoll((ITextChannel)Context.Channel, Context.Message, arg, isPublic) == false)
|
||||||
await ReplyErrorLocalized("poll_already_running").ConfigureAwait(false);
|
await ReplyErrorLocalized("poll_already_running").ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,7 @@ using Discord.WebSocket;
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using Color = Discord.Color;
|
using Color = Discord.Color;
|
||||||
using NadekoBot.Services;
|
using NadekoBot.Services;
|
||||||
|
using NadekoBot.DataStructures;
|
||||||
|
|
||||||
namespace NadekoBot.Modules.Utility
|
namespace NadekoBot.Modules.Utility
|
||||||
{
|
{
|
||||||
@ -277,48 +278,41 @@ namespace NadekoBot.Modules.Utility
|
|||||||
|
|
||||||
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} https://discord.gg/{invite.Code}");
|
await Context.Channel.SendConfirmAsync($"{Context.User.Mention} https://discord.gg/{invite.Code}");
|
||||||
}
|
}
|
||||||
//todo 2 shard commands
|
|
||||||
//[NadekoCommand, Usage, Description, Aliases]
|
|
||||||
//public async Task ShardStats(int page = 1)
|
|
||||||
//{
|
|
||||||
// if (--page < 0)
|
|
||||||
// return;
|
|
||||||
|
|
||||||
// var status = string.Join(", ", _client.Shards.GroupBy(x => x.ConnectionState)
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
// .Select(x => $"{x.Count()} {x.Key}")
|
[Shard0Precondition]
|
||||||
// .ToArray());
|
public async Task ShardStats(int page = 1)
|
||||||
|
{
|
||||||
|
if (--page < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
// var allShardStrings = _client.Shards
|
var status = string.Join(", ", _bot.ShardCoord.Statuses.GroupBy(x => x.ConnectionState)
|
||||||
// .Select(x =>
|
.Select(x => $"{x.Count()} {x.Key}")
|
||||||
// GetText("shard_stats_txt", x.ShardId.ToString(),
|
.ToArray());
|
||||||
// Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.Count.ToString())))
|
|
||||||
// .ToArray();
|
var allShardStrings = _bot.ShardCoord.Statuses
|
||||||
|
.Select(x =>
|
||||||
|
GetText("shard_stats_txt", x.ShardId.ToString(),
|
||||||
|
Format.Bold(x.ConnectionState.ToString()), Format.Bold(x.Guilds.ToString())))
|
||||||
|
.ToArray();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) =>
|
await Context.Channel.SendPaginatedConfirmAsync(_client, page, (curPage) =>
|
||||||
// {
|
{
|
||||||
|
|
||||||
// var str = string.Join("\n", allShardStrings.Skip(25 * curPage).Take(25));
|
var str = string.Join("\n", allShardStrings.Skip(25 * curPage).Take(25));
|
||||||
|
|
||||||
// if (string.IsNullOrWhiteSpace(str))
|
if (string.IsNullOrWhiteSpace(str))
|
||||||
// str = GetText("no_shards_on_page");
|
str = GetText("no_shards_on_page");
|
||||||
|
|
||||||
// return new EmbedBuilder()
|
return new EmbedBuilder()
|
||||||
// .WithAuthor(a => a.WithName(GetText("shard_stats")))
|
.WithAuthor(a => a.WithName(GetText("shard_stats")))
|
||||||
// .WithTitle(status)
|
.WithTitle(status)
|
||||||
// .WithOkColor()
|
.WithOkColor()
|
||||||
// .WithDescription(str);
|
.WithDescription(str);
|
||||||
// }, allShardStrings.Length / 25);
|
}, allShardStrings.Length / 25);
|
||||||
//}
|
}
|
||||||
|
|
||||||
//[NadekoCommand, Usage, Description, Aliases]
|
|
||||||
//public async Task ShardId(IGuild guild)
|
|
||||||
//{
|
|
||||||
// var shardId = _client.GetShardIdFor(guild);
|
|
||||||
|
|
||||||
// await Context.Channel.SendConfirmAsync(shardId.ToString()).ConfigureAwait(false);
|
|
||||||
//}
|
|
||||||
|
|
||||||
[NadekoCommand, Usage, Description, Aliases]
|
[NadekoCommand, Usage, Description, Aliases]
|
||||||
public async Task Stats()
|
public async Task Stats()
|
||||||
|
@ -20,6 +20,8 @@ namespace NadekoBot.Services
|
|||||||
|
|
||||||
bool IsOwner(IUser u);
|
bool IsOwner(IUser u);
|
||||||
int TotalShards { get; }
|
int TotalShards { get; }
|
||||||
|
string ShardRunCommand { get; }
|
||||||
|
string ShardRunArguments { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DBConfig
|
public class DBConfig
|
||||||
|
@ -30,20 +30,22 @@ namespace NadekoBot.Services.Impl
|
|||||||
public int TotalShards { get; }
|
public int TotalShards { get; }
|
||||||
public string CarbonKey { get; }
|
public string CarbonKey { get; }
|
||||||
|
|
||||||
public string credsFileName { get; } = Path.Combine(Directory.GetCurrentDirectory(), "credentials.json");
|
private readonly string _credsFileName = Path.Combine(Directory.GetCurrentDirectory(), "credentials.json");
|
||||||
public string PatreonAccessToken { get; }
|
public string PatreonAccessToken { get; }
|
||||||
|
public string ShardRunCommand { get; }
|
||||||
|
public string ShardRunArguments { get; }
|
||||||
|
|
||||||
public BotCredentials()
|
public BotCredentials()
|
||||||
{
|
{
|
||||||
_log = LogManager.GetCurrentClassLogger();
|
_log = LogManager.GetCurrentClassLogger();
|
||||||
|
|
||||||
try { File.WriteAllText("./credentials_example.json", JsonConvert.SerializeObject(new CredentialsModel(), Formatting.Indented)); } catch { }
|
try { File.WriteAllText("./credentials_example.json", JsonConvert.SerializeObject(new CredentialsModel(), Formatting.Indented)); } catch { }
|
||||||
if(!File.Exists(credsFileName))
|
if(!File.Exists(_credsFileName))
|
||||||
_log.Warn($"credentials.json is missing. Attempting to load creds from environment variables prefixed with 'NadekoBot_'. Example is in {Path.GetFullPath("./credentials_example.json")}");
|
_log.Warn($"credentials.json is missing. Attempting to load creds from environment variables prefixed with 'NadekoBot_'. Example is in {Path.GetFullPath("./credentials_example.json")}");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var configBuilder = new ConfigurationBuilder();
|
var configBuilder = new ConfigurationBuilder();
|
||||||
configBuilder.AddJsonFile(credsFileName, true)
|
configBuilder.AddJsonFile(_credsFileName, true)
|
||||||
.AddEnvironmentVariables("NadekoBot_");
|
.AddEnvironmentVariables("NadekoBot_");
|
||||||
|
|
||||||
var data = configBuilder.Build();
|
var data = configBuilder.Build();
|
||||||
@ -61,13 +63,19 @@ namespace NadekoBot.Services.Impl
|
|||||||
MashapeKey = data[nameof(MashapeKey)];
|
MashapeKey = data[nameof(MashapeKey)];
|
||||||
OsuApiKey = data[nameof(OsuApiKey)];
|
OsuApiKey = data[nameof(OsuApiKey)];
|
||||||
PatreonAccessToken = data[nameof(PatreonAccessToken)];
|
PatreonAccessToken = data[nameof(PatreonAccessToken)];
|
||||||
|
ShardRunCommand = data[nameof(ShardRunCommand)];
|
||||||
|
ShardRunArguments = data[nameof(ShardRunArguments)];
|
||||||
|
|
||||||
|
if (string.IsNullOrWhiteSpace(ShardRunCommand))
|
||||||
|
ShardRunCommand = "dotnet";
|
||||||
|
if (string.IsNullOrWhiteSpace(ShardRunArguments))
|
||||||
|
ShardRunArguments = "run -c Release -- {0} {1}";
|
||||||
|
|
||||||
int ts = 1;
|
int ts = 1;
|
||||||
int.TryParse(data[nameof(TotalShards)], out ts);
|
int.TryParse(data[nameof(TotalShards)], out ts);
|
||||||
TotalShards = ts < 1 ? 1 : ts;
|
TotalShards = ts < 1 ? 1 : ts;
|
||||||
|
|
||||||
ulong clId = 0;
|
ulong.TryParse(data[nameof(ClientId)], out ulong clId);
|
||||||
ulong.TryParse(data[nameof(ClientId)], out clId);
|
|
||||||
ClientId = clId;
|
ClientId = clId;
|
||||||
|
|
||||||
//var scId = data[nameof(SoundCloudClientId)];
|
//var scId = data[nameof(SoundCloudClientId)];
|
||||||
@ -107,6 +115,7 @@ namespace NadekoBot.Services.Impl
|
|||||||
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; } = "";
|
public string PatreonAccessToken { get; set; } = "";
|
||||||
|
public string ShardRunCommand { get; set; } = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
private class DbModel
|
private class DbModel
|
||||||
|
@ -13,7 +13,7 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
private readonly BotCredentials Credentials;
|
private readonly BotCredentials Credentials;
|
||||||
private Process[] ShardProcesses;
|
private Process[] ShardProcesses;
|
||||||
private ShardComMessage[] Statuses;
|
public ShardComMessage[] Statuses { get; }
|
||||||
private readonly Logger _log;
|
private readonly Logger _log;
|
||||||
private readonly ShardComServer _comServer;
|
private readonly ShardComServer _comServer;
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
Statuses[msg.ShardId] = msg;
|
Statuses[msg.ShardId] = msg;
|
||||||
if (msg.ConnectionState == Discord.ConnectionState.Disconnected || msg.ConnectionState == Discord.ConnectionState.Disconnecting)
|
if (msg.ConnectionState == Discord.ConnectionState.Disconnected || msg.ConnectionState == Discord.ConnectionState.Disconnecting)
|
||||||
_log.Error("!!! SHARD {0} IS IN {1} STATE", msg.ShardId, msg.ConnectionState);
|
_log.Error("!!! SHARD {0} IS IN {1} STATE", msg.ShardId, msg.ConnectionState.ToString());
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -46,13 +46,10 @@ namespace NadekoBot
|
|||||||
{
|
{
|
||||||
var p = Process.Start(new ProcessStartInfo()
|
var p = Process.Start(new ProcessStartInfo()
|
||||||
{
|
{
|
||||||
FileName = "dotnet",
|
FileName = Credentials.ShardRunCommand,
|
||||||
Arguments = $"run -c Debug -- {i} {curProcessId}",
|
Arguments = string.Format(Credentials.ShardRunArguments, i, curProcessId)
|
||||||
});
|
});
|
||||||
await Task.Delay(5000);
|
await Task.Delay(5000);
|
||||||
|
|
||||||
//Task.Run(() => { while (!p.HasExited) _log.Info($"S-{i}|" + p.StandardOutput.ReadLine()); });
|
|
||||||
//Task.Run(() => { while (!p.HasExited) _log.Error($"S-{i}|" + p.StandardError.ReadLine()); });
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,5 +15,6 @@
|
|||||||
"ConnectionString": "Filename=./data/NadekoBot.db"
|
"ConnectionString": "Filename=./data/NadekoBot.db"
|
||||||
},
|
},
|
||||||
"TotalShards": 1,
|
"TotalShards": 1,
|
||||||
"PatreonAccessToken": ""
|
"PatreonAccessToken": "",
|
||||||
|
"ShardRunCommand": ""
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user