youtube, welcome messages and futher code improvements

This commit is contained in:
dboerlage 2017-04-17 12:55:20 +02:00
parent 8d838eaae1
commit 59d0a5e135
No known key found for this signature in database
GPG key ID: BDA07B7D3FCF147F
7 changed files with 132 additions and 12 deletions

View file

@ -0,0 +1,16 @@
using System;
using System.IO;
using System.Threading.Tasks;
using Geekbot.net.Modules;
namespace Geekbot.net.Lib
{
public class BootTasks
{
public static async Task CheckSettingsFile()
{
// ToDO: Check settings file, if invalid, reconfig it
// Console.WriteLine(Path.GetFullPath("./settings.json"));
}
}
}

View file

@ -3,6 +3,46 @@ using StackExchange.Redis;
namespace Geekbot.net.Lib
{
// public class RedisClient
// {
// private static readonly Lazy<RedisClient> _instance
// = new Lazy<RedisClient>(() => new RedisClient());
// private static readonly object ThreadLock = new object();
// public static IDatabase Client;
//
// private RedisClient()
// { }
//
// public static RedisClient Instance
// {
// get
// {
// if (_instance.IsValueCreated)
// {
// return _instance.Value;
// }
// lock (ThreadLock)
// {
// if (Client == null)
// {
// try
// {
// var redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
// Client = redis.GetDatabase();
// }
// catch (Exception)
// {
// Console.WriteLine("Start Reids already you fucking faggot!");
// Environment.Exit(69);
// }
// }
// }
// return _instance.Value;
// }
// }
// }
public interface IRedisClient
{
IDatabase Client { get; set; }
@ -12,12 +52,16 @@ namespace Geekbot.net.Lib
{
public RedisClient()
{
var redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
if (!redis.IsConnected)
try
{
Console.WriteLine("Could not Connect to the Server...");
var redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
Client = redis.GetDatabase();
}
catch (Exception)
{
Console.WriteLine("Start Redis already you fucking faggot!");
Environment.Exit(69);
}
Client = redis.GetDatabase();
}
public IDatabase Client { get; set; }

View file

@ -23,7 +23,6 @@ namespace Geekbot.net.Lib
var key = guildId + "-" + message.Author.Id + "-messages";
var messages = (int)redis.StringGet(key);
redis.StringSet(key, (messages + 1).ToString());
await Task.FromResult(true);
}
public async Task UpdateGuildRecordAsync()
@ -32,7 +31,6 @@ namespace Geekbot.net.Lib
var key = guildId + "-messages";
var messages = (int)redis.StringGet(key);
redis.StringSet(key, (messages + 1).ToString());
await Task.FromResult(true);
}
}
}