Esempio n. 1
0
        private async IAsyncEnumerable <MessageResponse> TransferCoreAsync(UserInfo sender, UserInfo receiver, decimal amount, string symbol)
        {
            symbol = symbol.ToUpperInvariant();

            var content = $@"转账方:[{sender.Name}]({_matatakiService.GetUserPageUrl(sender.Id)})
被转账方:[{receiver.Name}]({_matatakiService.GetUserPageUrl(receiver.Id)})
转账数目:{amount} {symbol}";

            yield return(new MessageResponse("转账交易进行中...", content, parseMode: ParseMode.Markdown));

            MessageResponse finalResponse;

            try
            {
                var hash = await _matatakiService.TransferAsync(sender.Id, receiver.Id, amount, symbol);

                finalResponse = new MessageResponse("*转账成功*", content, parseMode: ParseMode.Markdown).WithInlineButtons(
                    InlineButton.WithUrl("交易详情", "https://rinkeby.etherscan.io/tx/" + hash)
                    );
            }
            catch
            {
                finalResponse = new MessageResponse("*转账失败*", content, parseMode: ParseMode.Markdown);
            }

            yield return(finalResponse);
        }
Esempio n. 2
0
        public async IAsyncEnumerable <MessageResponse> GroupHandler(Message message, long groupId)
        {
            yield return("查询中……");

            if (!await _groupService.IsGroupExistsAsync(groupId))
            {
                yield return("没有这样的群");

                yield break;
            }

            var chat = await _botClient.GetChatAsync(groupId);

            var inviteLink = chat.InviteLink ?? await _botClient.ExportChatInviteLinkAsync(groupId);

            yield return(Text("您可以进入该群")
                         .WithInlineButtons(InlineButton.WithUrl(chat.Title, inviteLink)));
        }