dog command and namespace fixes
This commit is contained in:
parent
c670bf7ae3
commit
8703a64556
13 changed files with 57 additions and 12 deletions
|
@ -1,6 +1,6 @@
|
|||
using RestSharp;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
namespace Geekbot.net.Lib.IClients
|
||||
{
|
||||
public interface ICatClient
|
||||
{
|
||||
|
|
19
Geekbot.net/Lib/IClients/DogClient.cs
Normal file
19
Geekbot.net/Lib/IClients/DogClient.cs
Normal file
|
@ -0,0 +1,19 @@
|
|||
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,7 +1,7 @@
|
|||
using System;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
namespace Geekbot.net.Lib.IClients
|
||||
{
|
||||
public interface IRedisClient
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.WebSocket;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
using StackExchange.Redis;
|
||||
|
||||
namespace Geekbot.net.Lib
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
using RestSharp;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
|
|
25
Geekbot.net/Modules/Dog.cs
Normal file
25
Geekbot.net/Modules/Dog.cs
Normal file
|
@ -0,0 +1,25 @@
|
|||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
using RestSharp;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
public class Dog : ModuleBase
|
||||
{
|
||||
private readonly IDogClient dogClient;
|
||||
public Dog(IDogClient dogClient)
|
||||
{
|
||||
this.dogClient = dogClient;
|
||||
}
|
||||
|
||||
[Command("dog", RunMode = RunMode.Async), Summary("Return a random image of a dog.")]
|
||||
public async Task Say()
|
||||
{
|
||||
var request = new RestRequest("woof.json", Method.GET);
|
||||
|
||||
dynamic response = dogClient.Client.Execute<dynamic>(request);
|
||||
await ReplyAsync(response.Data["url"]);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -4,6 +4,7 @@ using Discord.Commands;
|
|||
using Discord;
|
||||
using Geekbot.net.Lib;
|
||||
using System.Linq;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
|
|
|
@ -1,10 +1,7 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
|
|
|
@ -3,6 +3,7 @@ using System.Threading.Tasks;
|
|||
using Discord;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
|
||||
namespace Geekbot.net.Modules
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Discord.Commands;
|
||||
using Geekbot.net.Lib;
|
||||
using Geekbot.net.Lib.IClients;
|
||||
using Google.Apis.Services;
|
||||
using Google.Apis.YouTube.v3;
|
||||
|
||||
|
|
|
@ -54,6 +54,7 @@ namespace Geekbot.net
|
|||
|
||||
map = new DependencyMap();
|
||||
map.Add<ICatClient>(new CatClient());
|
||||
map.Add<IDogClient>(new DogClient());
|
||||
map.Add(redis);
|
||||
map.Add<IRandomClient>(new RandomClient());
|
||||
|
||||
|
|
Loading…
Reference in a new issue