コード例 #1
0
        protected async Task <SocialTipResponse[]> SendTip(TContext context)
        {
            if (!await IsTip(context).ConfigureAwait(false))
            {
                return(new SocialTipResponse[0]);
            }

            ISocialUser fromUser = await GetFromUser(context).ConfigureAwait(false);

            string messageId = await GetMessageId(context).ConfigureAwait(false);

            ISocialUser[] mentionedUsers = await GetMessageMentionedUsers(context).ConfigureAwait(false);

            if (mentionedUsers.Length == 0)
            {
                throw new NoUserMentionedException("Learn about Kinny here (https://telegram.me/kinnytip_bot?start=kinny) \r\nHow to tip Kin using Kinny:\r\n1. For (new message) direct tips: @username +amount /kinnytips\r\n2. For direct reply tips: +amount /kinnytips");
            }

            string messageText = await GetMessageText(context).ConfigureAwait(false);

            double tipAmount = _tipParser.GetTipAmount(messageText);
            List <SocialTipResponse> listOfResponses = new List <SocialTipResponse>();

            foreach (ISocialUser mentionedUser in mentionedUsers)
            {
                SocialTipRequest socialTipRequest = new SocialTipRequest
                {
                    From     = fromUser.UserId,
                    To       = mentionedUser.UserId,
                    Amount   = tipAmount,
                    Provider = Platform,
                    OfferParticipantsData = new OfferParticipantsData
                    {
                        From = new OfferData
                        {
                            Description = $"You sent {tipAmount} KIN to {mentionedUser.Username}",
                            Title       = $"Sent Tip ({Platform})",
                            Username    = fromUser.Username
                        },
                        To = new OfferData
                        {
                            Description = $"{fromUser.Username} sent you {tipAmount} KIN",
                            Title       = $"Received Tip ({Platform})",
                            Username    = mentionedUser.Username
                        }
                    },
                    MessageId = messageId + mentionedUser.UserId
                };

                listOfResponses.Add(
                    await Tip(await GetSocialQueueItem(socialTipRequest, context).ConfigureAwait(false)));
            }

            return(listOfResponses.ToArray());
        }
コード例 #2
0
 public TelegramQueueItem(TelegramBotClient tg, Message message, SocialTipRequest socialTipRequest) : base(
         socialTipRequest)
 {
     TelegramBot = tg;
     Message     = message;
 }
コード例 #3
0
 protected abstract Task <SocialQueuedItem> GetSocialQueueItem(SocialTipRequest request, TContext context);
コード例 #4
0
 protected override Task <SocialQueuedItem> GetSocialQueueItem(SocialTipRequest request, Comment comment)
 {
     return(Task.FromResult((SocialQueuedItem) new RedditQueueItem(_client, comment, request)));
 }
コード例 #5
0
 protected override Task <SocialQueuedItem> GetSocialQueueItem(SocialTipRequest request, Update message)
 {
     return(Task.FromResult((SocialQueuedItem) new TelegramQueueItem(_client, message.Message, request)));
 }
コード例 #6
0
 protected override Task <SocialQueuedItem> GetSocialQueueItem(SocialTipRequest request,
                                                               SocketCommandContext context)
 {
     return(Task.FromResult((SocialQueuedItem) new DiscordQueueItem(context, request)));
 }
コード例 #7
0
 public RedditQueueItem(RedditSharp.Reddit reddit, Comment comment, SocialTipRequest socialTipRequest) : base(
         socialTipRequest)
 {
     Reddit  = reddit;
     Comment = comment;
 }
コード例 #8
0
 public DiscordQueueItem(SocketCommandContext context, SocialTipRequest socialTipRequest) : base(
         socialTipRequest)
 {
     Context = context;
 }