ready for prod :D
This commit is contained in:
parent
5f437d74ea
commit
f52893e696
5 changed files with 34 additions and 11 deletions
|
@ -1,7 +1,11 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.Serialization.Json;
|
||||
using System.Threading.Tasks;
|
||||
using Geekbot.net.Modules;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
|
@ -12,5 +16,25 @@ namespace Geekbot.net.Lib
|
|||
// ToDO: Check settings file, if invalid, reconfig it
|
||||
// Console.WriteLine(Path.GetFullPath("./settings.json"));
|
||||
}
|
||||
|
||||
public static void ParseOldDatabase(string path)
|
||||
{
|
||||
Console.WriteLine("Starting Database Conversion...");
|
||||
path = Path.GetFullPath(path);
|
||||
Console.WriteLine($"Old db location: {path}");
|
||||
var redis = new RedisClient().Client;
|
||||
Console.WriteLine("Connected to Redis...");
|
||||
var allfiles = Directory.GetFiles(path, "*.json", SearchOption.AllDirectories);
|
||||
foreach ( var file in allfiles)
|
||||
{
|
||||
var info = new FileInfo(file);
|
||||
if (info.Name.StartsWith("-")) continue;
|
||||
Console.WriteLine(info.FullName);
|
||||
dynamic json = JObject.Parse(File.ReadAllText(file));
|
||||
var key = info.Name.Substring(0, info.Name.Length - 5) + "-messages";
|
||||
Console.WriteLine($"{key} - {json.messages}");
|
||||
redis.StringSet(key, json.messages.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -9,7 +9,6 @@ namespace Geekbot.net.Modules
|
|||
|
||||
public class CatClient : ICatClient
|
||||
{
|
||||
//Manage a restClient
|
||||
public CatClient()
|
||||
{
|
||||
Client = new RestClient("http://random.cat");
|
||||
|
|
|
@ -15,7 +15,7 @@ namespace Geekbot.net.Lib
|
|||
try
|
||||
{
|
||||
var redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
|
||||
Client = redis.GetDatabase();
|
||||
Client = redis.GetDatabase(6);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue