コード例 #1
0
        private string ConvertDuration(TLMessageActionBase action)
        {
            if (action is TLMessageActionPhoneCall phoneCallAction)
            {
                var missed = phoneCallAction.Reason is TLPhoneCallDiscardReasonMissed || phoneCallAction.Reason is TLPhoneCallDiscardReasonBusy;
                if (!missed && (phoneCallAction.Duration ?? 0) > 0)
                {
                    var duration = LocaleHelper.FormatCallDuration(phoneCallAction.Duration ?? 0);
                    return($", {duration}");
                }
            }

            return(string.Empty);
        }
コード例 #2
0
        private static string GetPaymentSentString(TLMessageActionBase action, TLMessageBase message, string fromUserFullName)
        {
            var actionPaymentSent = action as TLMessageActionPaymentSentBase;

            if (actionPaymentSent != null)
            {
                var serviceMessage49 = message as TLMessageService49;
                if (serviceMessage49 != null)
                {
                    var replyToMsgId = serviceMessage49.ReplyToMsgId;
                    if (replyToMsgId != null)
                    {
                        TLChannel channel = null;
                        if (serviceMessage49.ToId is TLPeerChannel)
                        {
                            channel = IoC.Get <ICacheService>().GetChat(serviceMessage49.ToId.Id) as TLChannel;
                        }

                        var reply =
                            IoC.Get <ICacheService>()
                            .GetMessage(serviceMessage49.ReplyToMsgId, channel != null ? channel.Id : null) as TLMessage;
                        if (reply != null)
                        {
                            var mediaInvoice = reply.Media as TLMessageMediaInvoice;
                            if (mediaInvoice != null)
                            {
                                return(string.Format(AppResources.MessageActionPaymentSentFor,
                                                     (actionPaymentSent.TotalAmount.Value / Math.Pow(10.0, Currency.GetPow(actionPaymentSent.Currency.ToString())) + " " + Currency.GetSymbol(actionPaymentSent.Currency.ToString())),
                                                     fromUserFullName, mediaInvoice.Title));
                            }
                        }
                    }

                    return(string.Format(AppResources.MessageActionPaymentSent,
                                         (actionPaymentSent.TotalAmount.Value / Math.Pow(10.0, Currency.GetPow(actionPaymentSent.Currency.ToString())) + " " + Currency.GetSymbol(actionPaymentSent.Currency.ToString())), fromUserFullName));
                }
            }

            return(null);
        }