Upgrading Dependencies and start restructure
This commit is contained in:
parent
44a80d76a9
commit
e97ebf86ef
5 changed files with 54 additions and 78 deletions
|
@ -1,33 +1,43 @@
|
||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>Exe</OutputType>
|
<OutputType>Exe</OutputType>
|
||||||
<TargetFramework>netcoreapp1.1</TargetFramework>
|
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||||
</PropertyGroup>
|
<ApplicationIcon>derp.ico</ApplicationIcon>
|
||||||
<ItemGroup>
|
<Version>1.1.0</Version>
|
||||||
<PackageReference Include="Cleverbot" Version="0.9.0" />
|
<Company>Pizza and Coffee Studios</Company>
|
||||||
<PackageReference Include="Discord.Net">
|
<Authors>Pizza and Coffee Studios</Authors>
|
||||||
<Version>1.0.0-rc</Version>
|
<Description>A Discord bot</Description>
|
||||||
</PackageReference>
|
<RepositoryUrl>https://github.com/pizzaandcoffee/Geekbot.net</RepositoryUrl>
|
||||||
<PackageReference Include="Google.Apis.YouTube.v3">
|
</PropertyGroup>
|
||||||
<Version>1.25.0.760</Version>
|
<ItemGroup>
|
||||||
</PackageReference>
|
<PackageReference Include="Discord.Net">
|
||||||
<PackageReference Include="HtmlAgilityPack.NetCore">
|
<Version>1.0.2</Version>
|
||||||
<Version>1.5.0.1</Version>
|
</PackageReference>
|
||||||
</PackageReference>
|
<PackageReference Include="Google.Apis.YouTube.v3">
|
||||||
<PackageReference Include="RestSharp.NetCore">
|
<Version>1.29.1.976</Version>
|
||||||
<Version>105.2.4-rc4-24214-01</Version>
|
</PackageReference>
|
||||||
</PackageReference>
|
<PackageReference Include="HtmlAgilityPack.NetCore">
|
||||||
<PackageReference Include="StackExchange.Redis">
|
<Version>1.5.0.1</Version>
|
||||||
<Version>1.2.1</Version>
|
</PackageReference>
|
||||||
</PackageReference>
|
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
|
||||||
<PackageReference Include="System.Net.Http">
|
<PackageReference Include="Microsoft.Extensions.Logging" Version="2.0.0" />
|
||||||
<Version>4.3.1</Version>
|
<PackageReference Include="Microsoft.Extensions.Options" Version="2.0.0" />
|
||||||
</PackageReference>
|
<PackageReference Include="Newtonsoft.Json" Version="10.0.3" />
|
||||||
<PackageReference Include="System.Runtime.Serialization.Json">
|
<PackageReference Include="RestSharp.NetCore">
|
||||||
<Version>4.3.0</Version>
|
<Version>105.2.3</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="System.Runtime.Serialization.Primitives">
|
<PackageReference Include="StackExchange.Redis">
|
||||||
<Version>4.3.0</Version>
|
<Version>1.2.6</Version>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
</ItemGroup>
|
<PackageReference Include="System.Net.Http">
|
||||||
|
<Version>4.3.2</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.Runtime.Serialization.Formatters" Version="4.3.0" />
|
||||||
|
<PackageReference Include="System.Runtime.Serialization.Json">
|
||||||
|
<Version>4.3.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
<PackageReference Include="System.Runtime.Serialization.Primitives">
|
||||||
|
<Version>4.3.0</Version>
|
||||||
|
</PackageReference>
|
||||||
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
|
@ -1,38 +0,0 @@
|
||||||
using RestSharp;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using static Geekbot.net.Lib.Dtos.FourChanDto;
|
|
||||||
|
|
||||||
namespace Geekbot.net.Lib.IClients
|
|
||||||
{
|
|
||||||
|
|
||||||
class FourChanBoardClient
|
|
||||||
{
|
|
||||||
private BoardList boards;
|
|
||||||
private static FourChanBoardClient instace;
|
|
||||||
|
|
||||||
private FourChanBoardClient()
|
|
||||||
{
|
|
||||||
Console.WriteLine("Fetching Boards");
|
|
||||||
var boardClient = new RestClient("https://a.4cdn.org");
|
|
||||||
var boardRequest = new RestRequest("boards.json", Method.GET);
|
|
||||||
var boardResult = boardClient.Execute<BoardList>(boardRequest);
|
|
||||||
this.boards = boardResult.Data;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FourChanBoardClient Boards()
|
|
||||||
{
|
|
||||||
if (instace == null)
|
|
||||||
{
|
|
||||||
instace = new FourChanBoardClient();
|
|
||||||
}
|
|
||||||
|
|
||||||
return instace;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Board> getBoards()
|
|
||||||
{
|
|
||||||
return this.boards.Boards;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -2,6 +2,10 @@
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System.Runtime.InteropServices.ComTypes;
|
using System.Runtime.InteropServices.ComTypes;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.Extensions.Configuration;
|
||||||
|
using Microsoft.Extensions.DependencyInjection;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.Extensions.Options;
|
||||||
using Discord;
|
using Discord;
|
||||||
using Discord.Commands;
|
using Discord.Commands;
|
||||||
using Discord.WebSocket;
|
using Discord.WebSocket;
|
||||||
|
@ -16,9 +20,9 @@ namespace Geekbot.net
|
||||||
{
|
{
|
||||||
private CommandService commands;
|
private CommandService commands;
|
||||||
private DiscordSocketClient client;
|
private DiscordSocketClient client;
|
||||||
private DependencyMap map;
|
|
||||||
private IRedisClient redis;
|
private IRedisClient redis;
|
||||||
private RedisValue token;
|
private RedisValue token;
|
||||||
|
private ServiceCollection services;
|
||||||
|
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
|
@ -30,7 +34,7 @@ namespace Geekbot.net
|
||||||
Console.WriteLine("=========================================");
|
Console.WriteLine("=========================================");
|
||||||
Console.WriteLine("Starting...");
|
Console.WriteLine("Starting...");
|
||||||
|
|
||||||
Task.WaitAll(new Program().MainAsync());
|
new Program().MainAsync().GetAwaiter().GetResult();
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task MainAsync()
|
public async Task MainAsync()
|
||||||
|
@ -52,11 +56,11 @@ namespace Geekbot.net
|
||||||
redis.Client.StringSet("botOwner", ownerId);
|
redis.Client.StringSet("botOwner", ownerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
map = new DependencyMap();
|
services = new ServiceCollection();
|
||||||
map.Add<ICatClient>(new CatClient());
|
services.AddSingleton<ICatClient>(new CatClient());
|
||||||
map.Add<IDogClient>(new DogClient());
|
services.AddSingleton<IDogClient>(new DogClient());
|
||||||
map.Add(redis);
|
services.AddSingleton<IRandomClient>(new RandomClient());
|
||||||
map.Add<IRandomClient>(new RandomClient());
|
services.AddSingleton(redis);
|
||||||
|
|
||||||
Console.WriteLine("Connecting to Discord...");
|
Console.WriteLine("Connecting to Discord...");
|
||||||
|
|
||||||
|
@ -127,7 +131,7 @@ namespace Geekbot.net
|
||||||
// }
|
// }
|
||||||
if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos))) return;
|
if (!(message.HasCharPrefix('!', ref argPos) || message.HasMentionPrefix(client.CurrentUser, ref argPos))) return;
|
||||||
var context = new CommandContext(client, message);
|
var context = new CommandContext(client, message);
|
||||||
Task.Run(async () => await commands.ExecuteAsync(context, argPos, map));
|
Task.Run(async () => await commands.ExecuteAsync(context, argPos, services));
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task HandleMessageReceived(SocketMessage messsageParam)
|
public async Task HandleMessageReceived(SocketMessage messsageParam)
|
||||||
|
|
BIN
Geekbot.net/derp.ico
Normal file
BIN
Geekbot.net/derp.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
BIN
derp.ico
Normal file
BIN
derp.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 361 KiB |
Loading…
Reference in a new issue