2017-12-03 20:22:18 +00:00
|
|
|
|
using Discord;
|
|
|
|
|
using Discord.Commands;
|
|
|
|
|
using Discord.WebSocket;
|
2017-12-09 05:59:43 +00:00
|
|
|
|
using dotbot.Core;
|
2017-12-05 05:59:37 +00:00
|
|
|
|
using dotbot.Services;
|
2017-12-03 20:59:01 +00:00
|
|
|
|
using Microsoft.Extensions.Configuration;
|
2017-12-03 20:22:18 +00:00
|
|
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace dotbot
|
|
|
|
|
{
|
|
|
|
|
public class Program
|
|
|
|
|
{
|
2017-12-03 20:59:01 +00:00
|
|
|
|
private IConfigurationRoot _config;
|
2017-12-03 20:22:18 +00:00
|
|
|
|
|
|
|
|
|
public static void Main(string[] args)
|
2017-12-03 20:59:01 +00:00
|
|
|
|
=> new Program().StartAsync().GetAwaiter().GetResult();
|
2017-12-03 20:22:18 +00:00
|
|
|
|
|
2017-12-03 20:59:01 +00:00
|
|
|
|
public async Task StartAsync()
|
2017-12-03 20:22:18 +00:00
|
|
|
|
{
|
2017-12-03 20:59:01 +00:00
|
|
|
|
var builder = new ConfigurationBuilder()
|
|
|
|
|
.SetBasePath(AppContext.BaseDirectory)
|
|
|
|
|
.AddJsonFile("_config.json");
|
|
|
|
|
_config = builder.Build();
|
2017-12-03 20:22:18 +00:00
|
|
|
|
|
2017-12-05 05:59:37 +00:00
|
|
|
|
var services = new ServiceCollection()
|
|
|
|
|
.AddSingleton(new DiscordSocketClient(new DiscordSocketConfig
|
|
|
|
|
{
|
|
|
|
|
LogLevel = LogSeverity.Verbose,
|
|
|
|
|
MessageCacheSize = 1000
|
|
|
|
|
}))
|
|
|
|
|
.AddSingleton(new CommandService(new CommandServiceConfig
|
|
|
|
|
{
|
|
|
|
|
LogLevel = LogSeverity.Verbose,
|
|
|
|
|
DefaultRunMode = RunMode.Async
|
|
|
|
|
}))
|
|
|
|
|
.AddSingleton<CommandHandlerService>()
|
|
|
|
|
.AddSingleton<LoggingService>()
|
|
|
|
|
.AddSingleton<StartupService>()
|
|
|
|
|
.AddSingleton<CleverBotCacheService>()
|
2017-12-09 05:59:43 +00:00
|
|
|
|
.AddSingleton<DotbotDb>()
|
2017-12-10 03:24:57 +00:00
|
|
|
|
.AddSingleton<PollService>()
|
2017-12-05 05:59:37 +00:00
|
|
|
|
.AddSingleton<Random>()
|
|
|
|
|
.AddSingleton(_config);
|
|
|
|
|
|
|
|
|
|
var provider = services.BuildServiceProvider();
|
|
|
|
|
|
|
|
|
|
provider.GetRequiredService<LoggingService>();
|
|
|
|
|
await provider.GetRequiredService<StartupService>().StartAsync();
|
|
|
|
|
provider.GetRequiredService<CommandHandlerService>();
|
2017-12-03 20:22:18 +00:00
|
|
|
|
|
|
|
|
|
await Task.Delay(-1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|