Beispiel #1
0
        public async Task AddQuote(string quote, IGuildUser user)
        {
            IGuildUser cr = Context.Message.Author as IGuildUser;

            EntityUser creator = new EntityUser(Context.Message.Author as IGuildUser);
            EntityUser quotee  = new EntityUser(user);
            Quote      q       = new Quote(quote.Replace("`", "'"), creator, quotee, DateTime.Now, Context.Guild);

            _qouteRepo.AddQuote(q);
            _qouteRepo.SaveChanges();

            int id = _qouteRepo.GetId(q);
            await Context.Channel.SendMessageAsync($"added quote **{q.QuoteText.RemoveAbuseCharacters()}** from" +
                                                   $" **{user.Nickname ??user.Username}**  quoted by **{cr.Nickname ?? cr.Username}** with id {id}");
        }
Beispiel #2
0
        public static async Task BotAddQuote(IQouteRepository _quoteRepo, IScoreRepository _scoreRepo, IUserRepository _userRepo, IMessageChannel channel, string quote, ulong msgId, IGuildUser creator, IGuildUser quotee, DateTime time)
        {
            if (!_quoteRepo.MessageExists(quote, quotee, time))
            {
                EntityUser cr = _userRepo.GetUserById(creator.Id);

                if (cr == null)
                {
                    cr = new EntityUser(creator);
                    _userRepo.AddUser(cr);
                }

                EntityUser quotee2 = _userRepo.GetUserById(quotee.Id);

                if (quotee2 == null)
                {
                    quotee2 = new EntityUser(quotee);
                    _userRepo.AddUser(quotee2);
                }

                if (quote.Length >= 1024)
                {
                    await channel.SendMessageAsync("This quote is too long");

                    return;
                }

                Quote q = new Quote(quote, cr, quotee2, time, creator.Guild)
                {
                    msgId = msgId
                };

                _quoteRepo.AddQuote(q);
                _quoteRepo.SaveChanges();

                _scoreRepo.Increment(creator, ScoreType.Qouter);
                _scoreRepo.Increment(quotee, ScoreType.Qouted);

                int id = _quoteRepo.GetId(q);
                await channel.SendMessageAsync($"added quote **{q.QuoteText.RemoveAbuseCharacters()}**" +
                                               $" from **{quotee.Nickname ?? quotee.Username}** quoted by **{creator.Nickname ?? creator.Username}** " +
                                               $"with id {id}");
            }
        }
Beispiel #3
0
        public static async Task BotAddQuote(IQouteRepository _quoteRepo, IMessageChannel channel, string quote, ulong msgId, IGuildUser creator, IGuildUser quotee, DateTime time)
        {
            if (!_quoteRepo.MessageExists(quote, quotee, time))
            {
                EntityUser cr      = new EntityUser(creator);
                EntityUser quotee2 = new EntityUser(quotee);

                Quote q = new Quote(quote, cr, quotee2, time, creator.Guild)
                {
                    msgId = msgId
                };

                _quoteRepo.AddQuote(q);
                _quoteRepo.SaveChanges();

                int id = _quoteRepo.GetId(q);
                await channel.SendMessageAsync($"added quote **{q.QuoteText.RemoveAbuseCharacters()}**" +
                                               $" from **{quotee.Nickname ?? quotee.Username}** quoted by **{creator.Nickname ?? creator.Username}** " +
                                               $"with id {id}");
            }
        }
Beispiel #4
0
        public async Task AddQuote(string quote, IGuildUser user)
        {
            IGuildUser cr = Context.Message.Author as IGuildUser;

            EntityUser creator = _userRepo.GetUserById(cr.Id);

            if (creator == null)
            {
                creator = new EntityUser(cr);
                _userRepo.AddUser(creator);
            }

            EntityUser quotee = _userRepo.GetUserById(user.Id);

            if (quotee == null)
            {
                quotee = new EntityUser(user);
                _userRepo.AddUser(quotee);
            }

            if (quote.Length >= 1024)
            {
                await Context.Channel.SendMessageAsync("This quote is too long");

                return;
            }


            Quote q = new Quote(quote.Replace("`", "'"), creator, quotee, DateTime.Now, Context.Guild);

            _qouteRepo.AddQuote(q);
            _qouteRepo.SaveChanges();

            _scoreRepo.Increment(cr, ScoreType.Qouter);
            _scoreRepo.Increment(user, ScoreType.Qouted);

            int id = _qouteRepo.GetId(q);
            await Context.Channel.SendMessageAsync($"added quote **{q.QuoteText.RemoveAbuseCharacters()}** from" +
                                                   $" **{user.Nickname ??user.Username}**  quoted by **{cr.Nickname ?? cr.Username}** with id {id}");
        }