some small fixes
This commit is contained in:
parent
557450fefa
commit
4954d44b5a
@ -51,7 +51,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
switch (i)
|
switch (i)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
await Migrate0_9To1_0();
|
Migrate0_9To1_0();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -64,19 +64,20 @@ namespace NadekoBot.Modules.Administration
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private async Task Migrate0_9To1_0()
|
private void Migrate0_9To1_0()
|
||||||
{
|
{
|
||||||
using (var uow = DbHandler.UnitOfWork())
|
using (var uow = DbHandler.UnitOfWork())
|
||||||
{
|
{
|
||||||
var botConfig = uow.BotConfig.GetOrCreate();
|
var botConfig = uow.BotConfig.GetOrCreate();
|
||||||
MigrateConfig0_9(uow, botConfig);
|
MigrateConfig0_9(uow, botConfig);
|
||||||
MigratePermissions0_9(uow);
|
//MigratePermissions0_9(uow);
|
||||||
MigrateServerSpecificConfigs0_9(uow);
|
MigrateServerSpecificConfigs0_9(uow);
|
||||||
MigrateDb0_9(uow);
|
//MigrateDb0_9(uow);
|
||||||
|
|
||||||
//NOW save it
|
//NOW save it
|
||||||
botConfig.MigrationVersion = 1;
|
botConfig.MigrationVersion = 1;
|
||||||
await uow.CompleteAsync().ConfigureAwait(false);
|
_log.Warn("Writing to disc");
|
||||||
|
uow.Complete();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,6 +96,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
com.CommandText = "SELECT * FROM Announcement";
|
com.CommandText = "SELECT * FROM Announcement";
|
||||||
|
|
||||||
var reader = com.ExecuteReader();
|
var reader = com.ExecuteReader();
|
||||||
|
var i = 0;
|
||||||
while (reader.Read())
|
while (reader.Read())
|
||||||
{
|
{
|
||||||
var gid = (ulong)(long)reader["ServerId"];
|
var gid = (ulong)(long)reader["ServerId"];
|
||||||
@ -106,7 +108,7 @@ namespace NadekoBot.Modules.Administration
|
|||||||
var byeDM = (long)reader["ByePM"] == 1;
|
var byeDM = (long)reader["ByePM"] == 1;
|
||||||
var byeChannel = (ulong)(long)reader["ByeChannelId"];
|
var byeChannel = (ulong)(long)reader["ByeChannelId"];
|
||||||
var byeMsg = (string)reader["ByeText"];
|
var byeMsg = (string)reader["ByeText"];
|
||||||
bool grdel = (long)reader["DeleteGreetMessages"] == 1;
|
var grdel = false;
|
||||||
var byedel = grdel;
|
var byedel = grdel;
|
||||||
var gc = uow.GuildConfigs.For(gid);
|
var gc = uow.GuildConfigs.For(gid);
|
||||||
|
|
||||||
@ -122,14 +124,17 @@ namespace NadekoBot.Modules.Administration
|
|||||||
gc.ChannelByeMessageText = byeMsg;
|
gc.ChannelByeMessageText = byeMsg;
|
||||||
|
|
||||||
gc.AutoDeleteByeMessages = gc.AutoDeleteGreetMessages = grdel;
|
gc.AutoDeleteByeMessages = gc.AutoDeleteGreetMessages = grdel;
|
||||||
|
_log.Info(++i);
|
||||||
}
|
}
|
||||||
|
|
||||||
var com2 = db.CreateCommand();
|
var com2 = db.CreateCommand();
|
||||||
com.CommandText = "SELECT * FROM CurrencyState";
|
com.CommandText = "SELECT * FROM CurrencyState";
|
||||||
|
|
||||||
|
i = 0;
|
||||||
var reader2 = com.ExecuteReader();
|
var reader2 = com.ExecuteReader();
|
||||||
while (reader2.Read())
|
while (reader2.Read())
|
||||||
{
|
{
|
||||||
|
_log.Info(++i);
|
||||||
uow.Currency.Add(new Currency()
|
uow.Currency.Add(new Currency()
|
||||||
{
|
{
|
||||||
Amount = (long)reader2["Value"],
|
Amount = (long)reader2["Value"],
|
||||||
@ -171,20 +176,24 @@ namespace NadekoBot.Modules.Administration
|
|||||||
_log.Warn(ex, "ServerSpecificConfig deserialization failed");
|
_log.Warn(ex, "ServerSpecificConfig deserialization failed");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
var i = 0;
|
||||||
foreach (var config in configs)
|
var selfAssRoles = new ConcurrentHashSet<SelfAssignedRole>();
|
||||||
|
configs
|
||||||
|
.Select(p => new { data = p.Value, gconfig = uow.GuildConfigs.For(p.Key) })
|
||||||
|
.AsParallel()
|
||||||
|
.ForAll(config =>
|
||||||
{
|
{
|
||||||
var guildId = config.Key;
|
try
|
||||||
var data = config.Value;
|
{
|
||||||
|
var guildConfig = config.gconfig;
|
||||||
var guildConfig = uow.GuildConfigs.For(guildId);
|
var data = config.data;
|
||||||
|
|
||||||
guildConfig.AutoAssignRoleId = data.AutoAssignedRole;
|
guildConfig.AutoAssignRoleId = data.AutoAssignedRole;
|
||||||
guildConfig.DeleteMessageOnCommand = data.AutoDeleteMessagesOnCommand;
|
guildConfig.DeleteMessageOnCommand = data.AutoDeleteMessagesOnCommand;
|
||||||
guildConfig.DefaultMusicVolume = data.DefaultMusicVolume;
|
guildConfig.DefaultMusicVolume = data.DefaultMusicVolume;
|
||||||
guildConfig.ExclusiveSelfAssignedRoles = data.ExclusiveSelfAssignedRoles;
|
guildConfig.ExclusiveSelfAssignedRoles = data.ExclusiveSelfAssignedRoles;
|
||||||
guildConfig.GenerateCurrencyChannelIds = new HashSet<GCChannelId>(data.GenerateCurrencyChannels.Select(gc => new GCChannelId() { ChannelId = gc.Key }));
|
guildConfig.GenerateCurrencyChannelIds = new HashSet<GCChannelId>(data.GenerateCurrencyChannels.Select(gc => new GCChannelId() { ChannelId = gc.Key }));
|
||||||
uow.SelfAssignedRoles.AddRange(data.ListOfSelfAssignableRoles.Select(r => new SelfAssignedRole() { GuildId = guildId, RoleId = r }).ToArray());
|
selfAssRoles.AddRange(data.ListOfSelfAssignableRoles.Select(r => new SelfAssignedRole() { GuildId = guildConfig.GuildId, RoleId = r }).ToArray());
|
||||||
var logSetting = guildConfig.LogSetting;
|
var logSetting = guildConfig.LogSetting;
|
||||||
guildConfig.LogSetting.IsLogging = data.LogChannel != null;
|
guildConfig.LogSetting.IsLogging = data.LogChannel != null;
|
||||||
guildConfig.LogSetting.ChannelId = data.LogChannel ?? 0;
|
guildConfig.LogSetting.ChannelId = data.LogChannel ?? 0;
|
||||||
@ -215,13 +224,20 @@ namespace NadekoBot.Modules.Administration
|
|||||||
return new FollowedStream()
|
return new FollowedStream()
|
||||||
{
|
{
|
||||||
ChannelId = x.ChannelId,
|
ChannelId = x.ChannelId,
|
||||||
GuildId = guildId,
|
GuildId = guildConfig.GuildId,
|
||||||
Username = x.Username.ToLowerInvariant(),
|
Username = x.Username.ToLowerInvariant(),
|
||||||
Type = type
|
Type = type
|
||||||
};
|
};
|
||||||
}));
|
}));
|
||||||
guildConfig.VoicePlusTextEnabled = data.VoicePlusTextEnabled;
|
guildConfig.VoicePlusTextEnabled = data.VoicePlusTextEnabled;
|
||||||
|
_log.Info("Migrating SpecificConfig for {0} done ({1})", guildConfig.GuildId, ++i);
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.Error(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
uow.SelfAssignedRoles.AddRange(selfAssRoles.ToArray());
|
||||||
try { File.Move("data/ServerSpecificConfigs.json", "data/DELETE_ME_ServerSpecificCOnfigs.json"); } catch { }
|
try { File.Move("data/ServerSpecificConfigs.json", "data/DELETE_ME_ServerSpecificCOnfigs.json"); } catch { }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,14 +261,16 @@ namespace NadekoBot.Modules.Administration
|
|||||||
}
|
}
|
||||||
catch { }
|
catch { }
|
||||||
}
|
}
|
||||||
foreach (var perms in PermissionsDict)
|
var i = 0;
|
||||||
|
PermissionsDict
|
||||||
|
.Select(p => new { data = p.Value, gconfig = uow.GuildConfigs.For(p.Key) })
|
||||||
|
.AsParallel()
|
||||||
|
.ForAll(perms =>
|
||||||
{
|
{
|
||||||
var guildId = perms.Key;
|
try
|
||||||
var data = perms.Value;
|
{
|
||||||
|
var data = perms.data;
|
||||||
_log.Info("Migrating data from permissions folder for {0}", guildId);
|
var gconfig = perms.gconfig;
|
||||||
|
|
||||||
var gconfig = uow.GuildConfigs.For(guildId);
|
|
||||||
|
|
||||||
gconfig.PermissionRole = data.PermissionsControllerRole;
|
gconfig.PermissionRole = data.PermissionsControllerRole;
|
||||||
gconfig.VerbosePermissions = data.Verbose;
|
gconfig.VerbosePermissions = data.Verbose;
|
||||||
@ -283,10 +301,15 @@ namespace NadekoBot.Modules.Administration
|
|||||||
CommandName = cc.Key,
|
CommandName = cc.Key,
|
||||||
Seconds = cc.Value
|
Seconds = cc.Value
|
||||||
}));
|
}));
|
||||||
var smodules = data.Permissions.Modules.Where(m => !m.Value);
|
_log.Info("Migrating data from permissions folder for {0} done ({1})", gconfig.GuildId, ++i);
|
||||||
|
|
||||||
try { Directory.Move("data/permissions","data/DELETE_ME_permissions"); } catch { }
|
|
||||||
}
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
_log.Error(ex);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
try { Directory.Move("data/permissions", "data/DELETE_ME_permissions"); } catch { }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ namespace NadekoBot.Modules.Utility
|
|||||||
//need to do this the first time
|
//need to do this the first time
|
||||||
if (uow.ConverterUnits.Empty())
|
if (uow.ConverterUnits.Empty())
|
||||||
{
|
{
|
||||||
var content = JsonConvert.DeserializeObject<List<MeasurementUnit>>(File.ReadAllText("units.json")).Select(u => new ConvertUnit()
|
var content = JsonConvert.DeserializeObject<List<MeasurementUnit>>(File.ReadAllText("data/units.json")).Select(u => new ConvertUnit()
|
||||||
{
|
{
|
||||||
Modifier = u.Modifier,
|
Modifier = u.Modifier,
|
||||||
UnitType = u.UnitType,
|
UnitType = u.UnitType,
|
||||||
|
@ -15,5 +15,8 @@
|
|||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<SchemaVersion>2.0</SchemaVersion>
|
<SchemaVersion>2.0</SchemaVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<DnxInvisibleFolder Include="data\permissions\" />
|
||||||
|
</ItemGroup>
|
||||||
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
<Import Project="$(VSToolsPath)\DotNet\Microsoft.DotNet.targets" Condition="'$(VSToolsPath)' != ''" />
|
||||||
</Project>
|
</Project>
|
@ -38,16 +38,17 @@ namespace NadekoBot.Services.Database.Repositories.Impl
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public GuildConfig For(ulong guildId)
|
public GuildConfig For(ulong guildId)
|
||||||
{
|
{
|
||||||
var config = _set.Include(gc => gc.FollowedStreams)
|
var config = _set
|
||||||
.Include(gc => gc.LogSetting)
|
//.Include(gc => gc.FollowedStreams)
|
||||||
.ThenInclude(ls => ls.IgnoredChannels)
|
// .Include(gc => gc.LogSetting)
|
||||||
.Include(gc => gc.LogSetting)
|
// .ThenInclude(ls => ls.IgnoredChannels)
|
||||||
.ThenInclude(ls => ls.IgnoredVoicePresenceChannelIds)
|
//.Include(gc => gc.LogSetting)
|
||||||
.Include(gc => gc.FilterInvitesChannelIds)
|
// .ThenInclude(ls => ls.IgnoredVoicePresenceChannelIds)
|
||||||
.Include(gc => gc.FilterWordsChannelIds)
|
//.Include(gc => gc.FilterInvitesChannelIds)
|
||||||
.Include(gc => gc.FilteredWords)
|
//.Include(gc => gc.FilterWordsChannelIds)
|
||||||
.Include(gc => gc.GenerateCurrencyChannelIds)
|
//.Include(gc => gc.FilteredWords)
|
||||||
.Include(gc => gc.CommandCooldowns)
|
//.Include(gc => gc.GenerateCurrencyChannelIds)
|
||||||
|
//.Include(gc => gc.CommandCooldowns)
|
||||||
.FirstOrDefault(c => c.GuildId == guildId);
|
.FirstOrDefault(c => c.GuildId == guildId);
|
||||||
|
|
||||||
if (config == null)
|
if (config == null)
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
using ImageProcessorCore;
|
using ImageProcessorCore;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Concurrent;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -31,6 +32,14 @@ namespace NadekoBot.Extensions
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void AddRange<T>(this ConcurrentHashSet<T> target, IEnumerable<T> elements) where T : class
|
||||||
|
{
|
||||||
|
foreach (var item in elements)
|
||||||
|
{
|
||||||
|
target.Add(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static bool IsInteger(this decimal number) => number == Math.Truncate(number);
|
public static bool IsInteger(this decimal number) => number == Math.Truncate(number);
|
||||||
|
|
||||||
public static string SanitizeMentions(this string str) =>
|
public static string SanitizeMentions(this string str) =>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
"emitEntryPoint": true,
|
"emitEntryPoint": true,
|
||||||
"allowUnsafe": true,
|
"allowUnsafe": true,
|
||||||
"compile": {
|
"compile": {
|
||||||
"exclude": [ ],
|
"exclude": [ "data" ]
|
||||||
},
|
},
|
||||||
"copyToOutput": {
|
"copyToOutput": {
|
||||||
"include": [ "data", "libs" ],
|
"include": [ "data", "libs" ],
|
||||||
|
Loading…
Reference in New Issue
Block a user