Ejemplo n.º 1
0
        public async Task Signin(Member member, Group group, MessageChain raw)
        {
            var coin = _service.Inspect <Coin>(member);
            var now  = DateTime.Now;

            if (coin == null || coin.LastModified.Date < now.Date)
            {
                var up = coin != null && coin.LastModified.Date.AddDays(1) == now.Date ? 15 : 10;
                _service.PutCoin(member, up);
                var builder = raw.CanBeReplied() ? raw.MakeReply() : new MessageChainBuilder();
                builder.AddPlain($"签到成功, 硬币+{up}🎉");
                await group.SendAsync(builder.Build());
            }
            else
            {
                var builder = raw.CanBeReplied() ? raw.MakeReply() : new MessageChainBuilder();
                builder.AddPlain("你已经签到过了😥");
                await group.SendAsync(builder.Build());
            }
        }
Ejemplo n.º 2
0
        public async Task CommitMessage(Group group, MessageChain chain)
        {
            string txt = null;
            await Wapoo
            .Wohoo("http://whatthecommit.com/index.txt")
            .ViaGet()
            .ForStringResult(x => txt = x)
            .FetchAsync();

            var builder = chain.CanBeReplied() ? chain.MakeReply() : new MessageChainBuilder();

            builder.AddPlain(txt.Trim());
            await group.SendAsync(builder.Build());
        }
Ejemplo n.º 3
0
        public async Task Profile(Member member, Group group, MessageChain raw)
        {
            var           builder = raw.CanBeReplied() ? raw.MakeReply() : new MessageChainBuilder();
            StringBuilder sb      = new();

            sb.Append("你, ");
            sb.AppendLine(member.DisplayName);
            sb.AppendLine("\n库存: ");
            var cnt = 0;

            foreach (var item in _service.Items(member))
            {
                cnt++;
                sb.AppendLine($"{cnt}.{item.DisplayName} - {item.Stack} 个");
            }

            builder.AddPlain(sb.ToString().Trim());
            await group.SendAsync(builder.Build());
        }
Ejemplo n.º 4
0
        public async Task GetSauce(Group group, MessageChain raw, Member sender)
        {
            ImageBase img = null;

            if (raw.Any(x => x is Quote))
            {
                var source = await raw.OfMessageRepliedByAsync();

                img = (ImageBase)source.FirstOrDefault(x => x is ImageBase);
            }

            if (img != null && img.Source is UrlSource)
            {
                await group.SendPlainAsync("在找了在找了😚");

                SauceNETClient client = new("653f4b7eb41179c20dc473f3500005fbad22ab3e");
                try
                {
                    var results = await client.GetSauceAsync(((UrlSource)img.Source).Url.AbsoluteUri, "999", "3");

                    var builder = raw.CanBeReplied() ? raw.MakeReply() : new MessageChainBuilder();
                    builder.Add(new At(sender.Identity));
                    builder.AddPlain("来啦来啦😘");

                    foreach (var result in results.Results)
                    {
                        builder.AddImage(null, new UrlSource(new Uri(result.ThumbnailURL, UriKind.Absolute)));
                        builder.AddPlain($"{result.Name}[{result.Similarity}]\n{result.SourceURL}\n");
                    }

                    await group.SendAsync(builder.Build());
                }
                catch
                {
                    await group.SendPlainAsync("出错了出错了😫");
                }
            }
            else
            {
                await group.SendPlainAsync("木有图片😥");
            }
        }