private static DkpBotConfiguration GetBotConfiguration(IConfigurationSection configuration) { DkpBotConfiguration botConfig = new DkpBotConfiguration(); configuration.Bind(botConfig); return(botConfig); }
public AuctionProcessor(DkpBotConfiguration configuration, AuctionState state, IItemProcessor itemProcessor, IDkpProcessor dkpProcessor, ILogger <AuctionProcessor> log) { ranks = configuration.ExpandedRanks; this.configuration = configuration; this.state = state; this.itemProcessor = itemProcessor; this.dkpProcessor = dkpProcessor; this.log = log; }
public DkpBot(DkpBotConfiguration configuration, DiscordSocketClient client, ICommandProcessor commandProcessor, ILogger <DkpBot> log) { this.client = client; this.commandProcessor = commandProcessor; this.log = log; token = configuration.Discord.Token; this.client.Log += LogAsync; this.client.Ready += ReadyAsync; this.client.MessageReceived += MessageReceivedAsync; }
public void SetUp() { state = new AuctionState(); dkpProcessor = new Mock <IDkpProcessor>(); itemProcessor = new Mock <IItemProcessor>(); configuration = new DkpBotConfiguration { Ranks = new[] { alt, box, main } }; raid = new RaidInfo(); Mock <IMessageChannel> channel = new Mock <IMessageChannel>(); channel.Setup(x => x.SendMessageAsync(It.IsAny <string>(), It.IsAny <bool>(), It.IsAny <Embed>(), It.IsAny <RequestOptions>())) .Returns(Task.FromResult(new Mock <IUserMessage>().Object)); message = new Mock <IMessage>(); message.SetupGet(x => x.Channel).Returns(channel.Object); target = new AuctionProcessor(configuration, state, itemProcessor.Object, dkpProcessor.Object, new Mock <ILogger <AuctionProcessor> >().Object); }
private static IServiceCollection AddDkpBot(this IServiceCollection services, IConfigurationSection dkpBotConfiguration) { DkpBotConfiguration config = GetBotConfiguration(dkpBotConfiguration); return(services .AddSingleton(config) .AddSingleton(config.EqDkpPlus) .AddSingleton(config.Discord) .AddSingleton(config.Ranks) .AddHttpClient() .AddChatCommands() .AddSingleton <EqDkpPlusClient>() .AddSingleton <IDkpProcessor, EqDkpPlusProcessor>() .AddSingleton <IAttendanceParser, RaidWindowParser>() .AddItemSource(config) .AddDefaultImplementations() .AddSingleton <AuctionState>() .AddSingleton <DkpState>() .AddSingleton <DkpBot>() .AddDiscordNet() ); }
private static IServiceCollection AddItemSource(this IServiceCollection services, DkpBotConfiguration config) { if (config.ItemSource.Equals("Wowhead", StringComparison.OrdinalIgnoreCase)) { services.AddSingleton <IItemSource, WowheadItemSource>(); } else if (config.ItemSource.Equals("WowheadClassic", StringComparison.OrdinalIgnoreCase)) { services.AddSingleton <IItemSource, WowheadClassicItemSource>(); } else { services.AddSingleton <IItemSource, AllakhazamItemSource>(); } return(services); }
public EqDkpPlusClient(DkpBotConfiguration config, IHttpClientFactory clientFactory, ILogger <EqDkpPlusClient> log) { this.config = config; this.clientFactory = clientFactory; this.log = log; }