Пример #1
0
        public GroupReplyPiece Get(MessageChain chain, long groupId)
        {
            var msg     = chain.Flatten();
            var results = _repository.Query <GroupReplyPiece>().Where(x => x.Trigger == msg && x.GroupId == groupId);
            int count   = results.Count();

            return(count switch
            {
                1 => results.First(),
                > 1 => results.Skip(random.Next(count)).First(),
                _ => null
            });
Пример #2
0
        public void Add(long groupId, long operatorId, MessageChain trigger, MessageChain reply)
        {
            var piece = new GroupReplyPiece()
            {
                CreatedAt  = DateTime.Now,
                GroupId    = groupId,
                OperatorId = operatorId,
                Trigger    = trigger.Flatten(),
                Reply      = reply.Flatten()
            };

            _repository.Store(piece);
        }
Пример #3
0
        public async Task Raw(Group group, MessageChain chain)
        {
            MessageChain raw = await chain.OfMessageRepliedByAsync();

            await group.SendPlainAsync(raw?.Flatten() ?? "没有哦");
        }