Upgraded to dotnet core 2 and small arch restructure
This commit is contained in:
parent
e97ebf86ef
commit
7d0b0c4634
20 changed files with 438 additions and 591 deletions
|
@ -1,20 +0,0 @@
|
|||
using System.Collections.Generic;
|
||||
|
||||
namespace Geekbot.net.Lib.Dtos
|
||||
{
|
||||
class FourChanDto
|
||||
{
|
||||
public class BoardList
|
||||
{
|
||||
public List<Board> Boards { get; set; }
|
||||
}
|
||||
|
||||
public class Board
|
||||
{
|
||||
public string board { get; set; }
|
||||
public string title { get; set; }
|
||||
public string ws_board { get; set; }
|
||||
public string meta_description { get; set; }
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
using RestSharp;
|
||||
|
||||
namespace Geekbot.net.Lib.IClients
|
||||
{
|
||||
public interface ICatClient
|
||||
{
|
||||
IRestClient Client { get; set; }
|
||||
}
|
||||
|
||||
public class CatClient : ICatClient
|
||||
{
|
||||
public CatClient()
|
||||
{
|
||||
Client = new RestClient("http://random.cat");
|
||||
}
|
||||
|
||||
public IRestClient Client { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,19 +0,0 @@
|
|||
using RestSharp;
|
||||
|
||||
namespace Geekbot.net.Lib.IClients
|
||||
{
|
||||
public interface IDogClient
|
||||
{
|
||||
IRestClient Client { get; set; }
|
||||
}
|
||||
|
||||
public class DogClient : IDogClient
|
||||
{
|
||||
public DogClient()
|
||||
{
|
||||
Client = new RestClient("http://random.dog");
|
||||
}
|
||||
|
||||
public IRestClient Client { get; set; }
|
||||
}
|
||||
}
|
|
@ -1,29 +0,0 @@
|
|||
using System;
|
||||
|
||||
namespace Geekbot.net.Lib.IClients
|
||||
{
|
||||
|
||||
public interface IRandomClient
|
||||
{
|
||||
Random Client { get; set; }
|
||||
}
|
||||
|
||||
public sealed class RandomClient : IRandomClient
|
||||
{
|
||||
public RandomClient()
|
||||
{
|
||||
try
|
||||
{
|
||||
Client = new Random();
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("Start Redis pls...");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public Random Client { get; set; }
|
||||
}
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
using System;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib.IClients
|
||||
{
|
||||
public interface IRedisClient
|
||||
{
|
||||
IDatabase Client { get; set; }
|
||||
}
|
||||
|
||||
public sealed class RedisClient : IRedisClient
|
||||
{
|
||||
public RedisClient()
|
||||
{
|
||||
try
|
||||
{
|
||||
var redis = ConnectionMultiplexer.Connect("127.0.0.1:6379");
|
||||
Client = redis.GetDatabase(6);
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
Console.WriteLine("Start Redis pls...");
|
||||
Environment.Exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
public IDatabase Client { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -1,35 +1,34 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.WebSocket;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
public class StatsRecorder
|
||||
{
|
||||
|
||||
private readonly SocketMessage message;
|
||||
private readonly IDatabase redis;
|
||||
|
||||
public StatsRecorder(SocketMessage message, IRedisClient redisClient)
|
||||
{
|
||||
this.message = message;
|
||||
redis = redisClient.Client;
|
||||
}
|
||||
|
||||
public async Task UpdateUserRecordAsync()
|
||||
{
|
||||
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
|
||||
var key = guildId + "-" + message.Author.Id + "-messages";
|
||||
await redis.StringIncrementAsync(key);
|
||||
}
|
||||
|
||||
public async Task UpdateGuildRecordAsync()
|
||||
{
|
||||
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
|
||||
var key = guildId + "-messages";
|
||||
await redis.StringIncrementAsync(key);
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.WebSocket;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
public class StatsRecorder
|
||||
{
|
||||
|
||||
private readonly SocketMessage message;
|
||||
private readonly IDatabase redis;
|
||||
|
||||
public StatsRecorder(SocketMessage message, IDatabase redis)
|
||||
{
|
||||
this.message = message;
|
||||
this.redis = redis;
|
||||
}
|
||||
|
||||
public async Task UpdateUserRecordAsync()
|
||||
{
|
||||
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
|
||||
var key = guildId + "-" + message.Author.Id + "-messages";
|
||||
await redis.StringIncrementAsync(key);
|
||||
}
|
||||
|
||||
public async Task UpdateGuildRecordAsync()
|
||||
{
|
||||
var guildId = ((SocketGuildChannel) message.Channel).Guild.Id;
|
||||
var key = guildId + "-messages";
|
||||
await redis.StringIncrementAsync(key);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue