Add Checkem Command
This commit is contained in:
parent
ee4c09e7ea
commit
1295ed6206
7 changed files with 211 additions and 8 deletions
40
Geekbot.net/Lib/CheckEmImageProvider.cs
Normal file
40
Geekbot.net/Lib/CheckEmImageProvider.cs
Normal file
|
@ -0,0 +1,40 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
public class CheckEmImageProvider : ICheckEmImageProvider
|
||||
{
|
||||
private string[] checkEmImageArray;
|
||||
private int totalCheckEmImages;
|
||||
private Random rnd;
|
||||
|
||||
public CheckEmImageProvider()
|
||||
{
|
||||
var path = Path.GetFullPath("./Storage/checkEmPics");
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var rawCheckEmPics = File.ReadAllText(path);
|
||||
checkEmImageArray = rawCheckEmPics.Split("\n");
|
||||
totalCheckEmImages = checkEmImageArray.Length;
|
||||
rnd = new Random();
|
||||
Console.WriteLine($"- Loaded {totalCheckEmImages} CheckEm Images");
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine("checkEmPics File not found");
|
||||
Console.WriteLine($"Path should be {path}");
|
||||
}
|
||||
}
|
||||
|
||||
public string GetRandomCheckEmPic()
|
||||
{
|
||||
return checkEmImageArray[rnd.Next(0, totalCheckEmImages)];
|
||||
}
|
||||
}
|
||||
|
||||
public interface ICheckEmImageProvider
|
||||
{
|
||||
string GetRandomCheckEmPic();
|
||||
}
|
||||
}
|
|
@ -6,21 +6,22 @@ using System.Text.RegularExpressions;
|
|||
|
||||
namespace Geekbot.net.Lib
|
||||
{
|
||||
class Fortunes : IFortunes
|
||||
class FortunesProvider : IFortunesProvider
|
||||
{
|
||||
private string[] fortuneArray;
|
||||
private int totalFortunes;
|
||||
private Random rnd;
|
||||
|
||||
public Fortunes()
|
||||
public FortunesProvider()
|
||||
{
|
||||
var path = Path.GetFullPath("./fortunes");
|
||||
var path = Path.GetFullPath("./Storage/fortunes");
|
||||
if (File.Exists(path))
|
||||
{
|
||||
var rawFortunes= File.ReadAllText(path);
|
||||
fortuneArray = rawFortunes.Split("%");
|
||||
totalFortunes = fortuneArray.Length;
|
||||
rnd = new Random();
|
||||
Console.WriteLine($"- Loaded {totalFortunes} Fortunes");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -40,7 +41,7 @@ namespace Geekbot.net.Lib
|
|||
}
|
||||
}
|
||||
|
||||
public interface IFortunes
|
||||
public interface IFortunesProvider
|
||||
{
|
||||
string GetRandomFortune();
|
||||
string GetFortune(int id);
|
Loading…
Add table
Add a link
Reference in a new issue