private async Task ReactionAdded(Cacheable <IUserMessage, ulong> ch, ISocketMessageChannel chanel, SocketReaction reaction) { IUserMessage msg = await ch.GetOrDownloadAsync(); if (msg == null) { return; } if (QuoteModule._trackedQuoteList.Keys.Contains(msg.Id) && !reaction.User.Value.IsBot) { if (reaction.Emote.Name == "✅") { await chanel.DeleteMessageAsync(msg.Id); QuoteModule._trackedQuoteList.Remove(msg.Id); } else { //add to file File.AppendAllLines(fileName, new string[] { QuoteModule._trackedQuoteList[msg.Id].Id.ToString() }); await chanel.DeleteMessageAsync(msg.Id); QuoteModule._trackedQuoteList.Remove(msg.Id); } } if (reaction.Emote.Name == "💬" && !msg.Author.IsBot) { try { await QuoteModule.BotAddQuote(_services.GetService <IQouteRepository>(), _services.GetService <IScoreRepository>(), _services.GetService <IUserRepository>(), chanel, msg.Content, msg.Id, reaction.User.GetValueOrDefault(null) as IGuildUser , msg.Author as IGuildUser, msg.Timestamp.DateTime); } catch (Exception e) { if (e.GetType().Equals(typeof(QuotingYourselfException))) { await msg.Channel.SendMessageAsync("A bit narcissistic to quote yourself, no?"); } else { await EmbedBuilderFunctions.UnhandledException(e.Message, msg.Channel as ISocketMessageChannel); } } } }
private async Task ReactionAdded(Cacheable <IUserMessage, ulong> ch, ISocketMessageChannel chanel, SocketReaction reaction) { IUserMessage msg = await ch.GetOrDownloadAsync(); if ((/*msg.Id == SearchModule._tracked?.Id || */ AdminModule._trackedList?.Id == msg.Id) && reaction.UserId != _client.CurrentUser.Id) { if (reaction.Emote.Name == "➡") { /* if(msg.Id == SearchModule._tracked?.Id) * SearchModule.ChangeFrame(true);*/ //else await AdminModule.ChangeIndex((ISocketMessageChannel)msg.Channel, true); } if (reaction.Emote.Name == "⬅") { /* if (msg.Id == SearchModule._tracked?.Id) * SearchModule.ChangeFrame(false); * else*/ await AdminModule.ChangeIndex((ISocketMessageChannel)msg.Channel, false); } } if (reaction.Emote.Name == "💬" && !msg.Author.IsBot) { try { await QuoteModule.BotAddQuote(_services.GetService <IQouteRepository>(), chanel, msg.Content, msg.Id, reaction.User.GetValueOrDefault(null) as IGuildUser , msg.Author as IGuildUser, msg.Timestamp.DateTime); } catch (Exception e) { if (e.GetType().Equals(typeof(QuotingYourselfException))) { await msg.Channel.SendMessageAsync("A bit narcissistic to quote yourself, no?"); } } } }
public void SetUp() { _client = MockRepository.GenerateStub<IIrcClient>(); _repository = MockRepository.GenerateStub<IQuoteRepository>(); _module = new QuoteModule(_client, _repository); var unitOfWork = MockRepository.GenerateStub<IUnitOfWork>(); var unitOfWorkFactory = MockRepository.GenerateStub<IUnitOfWorkFactory>(); unitOfWorkFactory.Stub(x => x.Create()).Return(unitOfWork); var container = MockRepository.GenerateStub<IWindsorContainer>(); container.Stub(x => x.Resolve<IUnitOfWorkFactory>()) .Return(unitOfWorkFactory); IoC.Initialize(container); }