Pandas, rip restsharp, stuff

This commit is contained in:
Runebaas 2017-09-19 20:39:49 +02:00
parent 3a5a0df846
commit d88e9a6f18
10 changed files with 182 additions and 73 deletions

View file

@ -9,7 +9,7 @@ namespace Geekbot.net.Lib
private readonly Random rnd;
private readonly int totalCheckEmImages;
public CheckEmImageProvider()
public CheckEmImageProvider(Random rnd)
{
var path = Path.GetFullPath("./Storage/checkEmPics");
if (File.Exists(path))
@ -17,8 +17,8 @@ namespace Geekbot.net.Lib
var rawCheckEmPics = File.ReadAllText(path);
checkEmImageArray = rawCheckEmPics.Split("\n");
totalCheckEmImages = checkEmImageArray.Length;
rnd = new Random();
Console.WriteLine($"- Loaded {totalCheckEmImages} CheckEm Images");
this.rnd = rnd;
Console.WriteLine($"-- Loaded {totalCheckEmImages} CheckEm Images");
}
else
{

View file

@ -9,7 +9,7 @@ namespace Geekbot.net.Lib
private readonly Random rnd;
private readonly int totalFortunes;
public FortunesProvider()
public FortunesProvider(Random rnd)
{
var path = Path.GetFullPath("./Storage/fortunes");
if (File.Exists(path))
@ -17,8 +17,8 @@ namespace Geekbot.net.Lib
var rawFortunes = File.ReadAllText(path);
fortuneArray = rawFortunes.Split("%");
totalFortunes = fortuneArray.Length;
rnd = new Random();
Console.WriteLine($"- Loaded {totalFortunes} Fortunes");
this.rnd = rnd;
Console.WriteLine($"-- Loaded {totalFortunes} Fortunes");
}
else
{
@ -31,16 +31,10 @@ namespace Geekbot.net.Lib
{
return fortuneArray[rnd.Next(0, totalFortunes)];
}
public string GetFortune(int id)
{
return fortuneArray[id];
}
}
public interface IFortunesProvider
{
string GetRandomFortune();
string GetFortune(int id);
}
}

View file

@ -0,0 +1,40 @@
using System;
using System.IO;
namespace Geekbot.net.Lib
{
public class PandaProvider : IPandaProvider
{
private readonly string[] PandaArray;
private readonly Random rnd;
private readonly int totalPandas;
public PandaProvider(Random rnd)
{
var path = Path.GetFullPath("./Storage/pandas");
if (File.Exists(path))
{
var rawFortunes = File.ReadAllText(path);
PandaArray = rawFortunes.Split("\n");
totalPandas = PandaArray.Length;
this.rnd = rnd;
Console.WriteLine($"-- Loaded {totalPandas} Panda Images");
}
else
{
Console.WriteLine("Pandas File not found");
Console.WriteLine($"Path should be {path}");
}
}
public string GetRandomPanda()
{
return PandaArray[rnd.Next(0, totalPandas)];
}
}
public interface IPandaProvider
{
string GetRandomPanda();
}
}