mirror of
https://gitlab.com/Kwoth/nadekobot.git
synced 2024-10-02 20:13:13 +00:00
Cleanup, Added string and repeat limit fixes from 1.9 branch
This commit is contained in:
parent
797e93da1d
commit
81406cb46a
5 changed files with 3 additions and 163 deletions
|
@ -77,17 +77,6 @@ namespace NadekoBot.Db
|
|||
.Sum(x => x.Price);
|
||||
}
|
||||
|
||||
public static int AffinityCount(this DbSet<WaifuUpdate> updates, ulong userId)
|
||||
{
|
||||
return updates
|
||||
.FromSqlInterpolated($@"SELECT 1
|
||||
FROM WaifuUpdates
|
||||
WHERE UserId = (SELECT Id from DiscordUser WHERE UserId={userId}) AND
|
||||
UpdateType = 0 AND
|
||||
NewId IS NOT NULL")
|
||||
.Count();
|
||||
}
|
||||
|
||||
public static ulong GetWaifuUserId(this DbSet<WaifuInfo> waifus, ulong ownerId, string name)
|
||||
{
|
||||
return waifus
|
||||
|
|
|
@ -20,154 +20,4 @@ namespace NadekoBot.Modules.Games.Services
|
|||
ConfigPrinters.ToString, val => val >= 0);
|
||||
}
|
||||
}
|
||||
|
||||
// public sealed class GamesConfigMigrator : IConfigMigrator
|
||||
// {
|
||||
// // private readonly DbService _db;
|
||||
// private readonly GamesConfigService _gss;
|
||||
//
|
||||
// public GamesConfigMigrator(DbService dbService, GamesConfigService gss)
|
||||
// {
|
||||
// _log = LogManager.GetCurrentClassLogger();
|
||||
// _db = dbService;
|
||||
// _gss = gss;
|
||||
// }
|
||||
//
|
||||
// public void EnsureMigrated()
|
||||
// {
|
||||
// using var uow = _db.GetDbContext();
|
||||
// using var conn = uow.Database.GetDbConnection();
|
||||
// MigrateRaceAnimals(conn);
|
||||
// MigrateEightBall(conn);
|
||||
// }
|
||||
//
|
||||
// private void MigrateTrivia(DbConnection conn)
|
||||
// {
|
||||
// using (var checkTableCommand = conn.CreateCommand())
|
||||
// {
|
||||
// // make sure table still exists
|
||||
// checkTableCommand.CommandText =
|
||||
// "SELECT name FROM sqlite_master WHERE type='table' AND name='BotConfig';";
|
||||
// var checkReader = checkTableCommand.ExecuteReader();
|
||||
// if (!checkReader.HasRows)
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// Log.Information("Migrating trivia...");
|
||||
//
|
||||
// using var com = conn.CreateCommand();
|
||||
// com.CommandText = $@"SELECT MinimumTriviaWinReq, TriviaCurrencyReward FROM BotConfig";
|
||||
// using var reader = com.ExecuteReader();
|
||||
//
|
||||
// if (!reader.Read())
|
||||
// return;
|
||||
//
|
||||
// _gss.ModifyConfig(ModifyTriviaAction(reader));
|
||||
//
|
||||
// Log.Information("Trivia config migrated to data/games.yml");
|
||||
// }
|
||||
//
|
||||
// private static Action<GamesConfig> ModifyTriviaAction(DbDataReader reader)
|
||||
// => realConfig =>
|
||||
// {
|
||||
// var val = (int) (long) reader["MinimumTriviaWinReq"];
|
||||
// realConfig.Trivia.MinimumWinReq = val <= 0 ? 1 : val;
|
||||
// realConfig.Trivia.CurrencyReward = (long) reader["TriviaCurrencyReward"];
|
||||
// };
|
||||
//
|
||||
// private void MigrateEightBall(DbConnection conn)
|
||||
// {
|
||||
// using (var checkTableCommand = conn.CreateCommand())
|
||||
// {
|
||||
// // make sure table still exists
|
||||
// checkTableCommand.CommandText =
|
||||
// "SELECT name FROM sqlite_master WHERE type='table' AND name='EightBallResponses';";
|
||||
// var checkReader = checkTableCommand.ExecuteReader();
|
||||
// if (!checkReader.HasRows)
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// using (var com = conn.CreateCommand())
|
||||
// {
|
||||
// com.CommandText = $@"SELECT Text FROM EightBallResponses";
|
||||
// using var reader = com.ExecuteReader();
|
||||
//
|
||||
// if (!reader.Read())
|
||||
// return;
|
||||
//
|
||||
// Log.Information("Migrating eightball...");
|
||||
// _gss.ModifyConfig(Modify8ballAction(reader));
|
||||
// }
|
||||
//
|
||||
// Log.Information("Eightball migrated to data/games.yml");
|
||||
// MigrateTrivia(conn);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
//
|
||||
// using var deleteEightBallCommand = conn.CreateCommand();
|
||||
// deleteEightBallCommand.CommandText = "DROP TABLE IF EXISTS EightBallResponses";
|
||||
// deleteEightBallCommand.ExecuteNonQuery();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
//
|
||||
// private static Action<GamesConfig> Modify8ballAction(DbDataReader reader)
|
||||
// => realConfig =>
|
||||
// {
|
||||
// realConfig.EightBallResponses.Clear();
|
||||
// do
|
||||
// {
|
||||
// realConfig.EightBallResponses.Add((string) reader["Text"]);
|
||||
// } while (reader.Read());
|
||||
// };
|
||||
//
|
||||
// private void MigrateRaceAnimals(DbConnection conn)
|
||||
// {
|
||||
// using (var checkTableCommand = conn.CreateCommand())
|
||||
// {
|
||||
// // make sure table still exists
|
||||
// checkTableCommand.CommandText =
|
||||
// "SELECT name FROM sqlite_master WHERE type='table' AND name='RaceAnimals';";
|
||||
// var checkReader = checkTableCommand.ExecuteReader();
|
||||
// if (!checkReader.HasRows)
|
||||
// return;
|
||||
// }
|
||||
//
|
||||
// using (var com = conn.CreateCommand())
|
||||
// {
|
||||
// com.CommandText = $@"SELECT Name, Icon FROM RaceAnimals";
|
||||
// using var reader = com.ExecuteReader();
|
||||
//
|
||||
// if (!reader.Read())
|
||||
// return;
|
||||
//
|
||||
// Log.Information("Migrating race animals...");
|
||||
// _gss.ModifyConfig(ModifyRaceAnimalsAction(reader));
|
||||
// }
|
||||
//
|
||||
// Log.Information("Race animals migrated to data/games.yml");
|
||||
//
|
||||
// using var deleteRaceAnimalsCommand = conn.CreateCommand();
|
||||
// deleteRaceAnimalsCommand.CommandText = "DROP TABLE IF EXISTS RaceAnimals";
|
||||
// deleteRaceAnimalsCommand.ExecuteNonQuery();
|
||||
// }
|
||||
//
|
||||
// private static Action<GamesConfig> ModifyRaceAnimalsAction(DbDataReader reader)
|
||||
// => realConfig =>
|
||||
// {
|
||||
// realConfig.RaceAnimals.Clear();
|
||||
//
|
||||
// do
|
||||
// {
|
||||
// realConfig.RaceAnimals.Add(new RaceAnimal()
|
||||
// {
|
||||
// Icon = (string) reader["Icon"],
|
||||
// Name = (string) reader["Name"]
|
||||
// });
|
||||
// } while (reader.Read());
|
||||
// };
|
||||
// }
|
||||
}
|
|
@ -343,7 +343,7 @@ where ((guildid >> 22) % {_creds.TotalShards}) == {_client.ShardId};")
|
|||
|
||||
using var uow = _db.GetDbContext();
|
||||
|
||||
if (await uow.Repeaters.AsNoTracking().CountAsyncEF() < MAX_REPEATERS)
|
||||
if (await uow.Repeaters.AsNoTracking().CountAsyncEF(x => x.GuildId == guildId) < MAX_REPEATERS)
|
||||
uow.Repeaters.Add(rep);
|
||||
else
|
||||
return null;
|
||||
|
|
|
@ -70,7 +70,7 @@
|
|||
</ItemGroup>
|
||||
|
||||
<PropertyGroup Condition=" '$(Version)' == '' ">
|
||||
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">2.0.0</VersionPrefix>
|
||||
<VersionPrefix Condition=" '$(VersionPrefix)' == '' ">3.0.0</VersionPrefix>
|
||||
<Version Condition=" '$(VersionSuffix)' != '' ">$(VersionPrefix).$(VersionSuffix)</Version>
|
||||
<Version Condition=" '$(Version)' == '' ">$(VersionPrefix)</Version>
|
||||
</PropertyGroup>
|
||||
|
|
|
@ -626,6 +626,7 @@
|
|||
"messages": "Messages",
|
||||
"repeater_created": "Repeater Created",
|
||||
"repeater_removed": "Repeater #{0} Removed",
|
||||
"repeater_exceed_limit": "You cannot have more than {0} repeaters per server.",
|
||||
"repeater_remove_fail": "Failed removing repeater on that index. Either you've specified invalid index, or repeater was in executing state at that time, in which case, try again in a few seconds.",
|
||||
"interval:": "Interval:",
|
||||
"executes_in:": "Executes in:",
|
||||
|
|
Loading…
Reference in a new issue