dog command and namespace fixes

This commit is contained in:
Runebaas 2017-05-06 20:35:31 +02:00
parent c670bf7ae3
commit 8703a64556
13 changed files with 57 additions and 12 deletions

View file

@ -1,6 +1,6 @@
using RestSharp; using RestSharp;
namespace Geekbot.net.Modules namespace Geekbot.net.Lib.IClients
{ {
public interface ICatClient public interface ICatClient
{ {

View 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; }
}
}

View file

@ -1,7 +1,7 @@
using System; using System;
using StackExchange.Redis; using StackExchange.Redis;
namespace Geekbot.net.Lib namespace Geekbot.net.Lib.IClients
{ {
public interface IRedisClient public interface IRedisClient
{ {

View file

@ -1,6 +1,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord.WebSocket; using Discord.WebSocket;
using Geekbot.net.Lib.IClients;
using StackExchange.Redis; using StackExchange.Redis;
namespace Geekbot.net.Lib namespace Geekbot.net.Lib

View file

@ -1,6 +1,6 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib.IClients;
namespace Geekbot.net.Modules namespace Geekbot.net.Modules
{ {

View file

@ -1,6 +1,6 @@
using System; using System.Threading.Tasks;
using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib.IClients;
using RestSharp; using RestSharp;
namespace Geekbot.net.Modules namespace Geekbot.net.Modules

View file

@ -2,7 +2,7 @@
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib.IClients;
namespace Geekbot.net.Modules namespace Geekbot.net.Modules
{ {

View 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"]);
}
}
}

View file

@ -4,6 +4,7 @@ using Discord.Commands;
using Discord; using Discord;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using System.Linq; using System.Linq;
using Geekbot.net.Lib.IClients;
namespace Geekbot.net.Modules namespace Geekbot.net.Modules
{ {

View file

@ -1,10 +1,7 @@
using System; using System.Threading.Tasks;
using System.Collections.Generic;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib.IClients;
namespace Geekbot.net.Modules namespace Geekbot.net.Modules
{ {

View file

@ -3,6 +3,7 @@ using System.Threading.Tasks;
using Discord; using Discord;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib;
using Geekbot.net.Lib.IClients;
namespace Geekbot.net.Modules namespace Geekbot.net.Modules
{ {

View file

@ -1,7 +1,7 @@
using System; using System;
using System.Threading.Tasks; using System.Threading.Tasks;
using Discord.Commands; using Discord.Commands;
using Geekbot.net.Lib; using Geekbot.net.Lib.IClients;
using Google.Apis.Services; using Google.Apis.Services;
using Google.Apis.YouTube.v3; using Google.Apis.YouTube.v3;

View file

@ -54,6 +54,7 @@ namespace Geekbot.net
map = new DependencyMap(); map = new DependencyMap();
map.Add<ICatClient>(new CatClient()); map.Add<ICatClient>(new CatClient());
map.Add<IDogClient>(new DogClient());
map.Add(redis); map.Add(redis);
map.Add<IRandomClient>(new RandomClient()); map.Add<IRandomClient>(new RandomClient());