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 });
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); }
public async Task Raw(Group group, MessageChain chain) { MessageChain raw = await chain.OfMessageRepliedByAsync(); await group.SendPlainAsync(raw?.Flatten() ?? "没有哦"); }