예제 #1
0
        public static string GetMessageHeaderText(Message message, User user, User user2)
        {
            if (!string.IsNullOrWhiteSpace(message.body))
            {
                string input = BrowserNavigationService.Regex_DomainMention.Replace(message.body, "[$2|$4]");
                return(BrowserNavigationService.Regex_Mention.Replace(input, "$4"));
            }
            if (!string.IsNullOrWhiteSpace(message.action))
            {
                return(SystemMessageTextHelper.GenerateText(message, user, user2, false));
            }
            if (message.attachments != null && message.attachments.Count > 0)
            {
                Attachment firstAttachment = message.attachments.First <Attachment>();
                int        num             = message.attachments.Count <Attachment>((Func <Attachment, bool>)(a => a.type == firstAttachment.type));
                string     lowerInvariant  = firstAttachment.type.ToLowerInvariant();

                if (lowerInvariant == "money_transfer")
                {
                    return(CommonResources.MoneyTransfer);
                }
                else if (lowerInvariant == "link")
                {
                    return(CommonResources.Link);
                }
                else if (lowerInvariant == "wall")
                {
                    return(CommonResources.Conversation_WallPost);
                }
                else if (lowerInvariant == "gift")
                {
                    return(CommonResources.Gift);
                }
                else if (lowerInvariant == "photo")
                {
                    if (num == 1)
                    {
                        return(CommonResources.Conversations_OnePhoto);
                    }
                    if (num < 5)
                    {
                        return(string.Format(CommonResources.Conversations_TwoFourPhotosFrm, num));
                    }
                    return(string.Format(CommonResources.Conversations_FiveOrMorePhotosFrm, num));
                }
                else if (lowerInvariant == "wall_reply")
                {
                    return(CommonResources.Comment);
                }
                else if (lowerInvariant == "sticker")
                {
                    return(CommonResources.Conversation_Sticker);
                }
                else if (lowerInvariant == "market")
                {
                    return(CommonResources.Product);
                }
                else if (lowerInvariant == "doc")
                {
                    Doc doc1 = firstAttachment.doc;
                    if ((doc1 != null ? (doc1.IsGraffiti ? 1 : 0) : 0) != 0)
                    {
                        return(CommonResources.Graffiti);
                    }
                    Doc doc2 = firstAttachment.doc;
                    if ((doc2 != null ? (doc2.IsVoiceMessage ? 1 : 0) : 0) != 0)
                    {
                        return(CommonResources.VoiceMessage);
                    }
                    if (num == 1)
                    {
                        return(CommonResources.Conversations_OneDocument);
                    }
                    if (num < 5)
                    {
                        return(string.Format(CommonResources.Conversations_TwoFourDocumentsFrm, num));
                    }
                    return(string.Format(CommonResources.Conversations_FiveMoreDocumentsFrm, num));
                }

                else if (lowerInvariant == "audio")
                {
                    if (num == 1)
                    {
                        return(CommonResources.Conversations_OneAudio);
                    }
                    if (num < 5)
                    {
                        return(string.Format(CommonResources.Conversations_TwoFourAudioFrm, num));
                    }
                    return(string.Format(CommonResources.Conversations_FiveOrMoreAudioFrm, num));
                }

                else if (lowerInvariant == "video")
                {
                    if (num == 1)
                    {
                        return(CommonResources.Conversations_OneVideo);
                    }
                    if (num < 5)
                    {
                        return(string.Format(CommonResources.Conversations_TwoFourVideosFrm, num));
                    }
                    return(string.Format(CommonResources.Conversations_FiveOrMoreVideosFrm, num));
                }
            }


            if (message.geo != null)
            {
                return(CommonResources.Conversations_Location);
            }
            if (message.fwd_messages == null || message.fwd_messages.Count <= 0)
            {
                return(string.Empty);
            }
            int count = message.fwd_messages.Count;

            if (count == 1)
            {
                return(CommonResources.Conversations_OneForwardedMessage);
            }
            if (count < 5)
            {
                return(string.Format(CommonResources.Conversations_TwoFourForwardedMessagesFrm, count));
            }
            return(string.Format(CommonResources.Conversations_FiveMoreForwardedMessagesFrm, count));
        }
예제 #2
0
        public static string GenerateText(Message message, User user1, User user2, bool extendedText)
        {
            if (message == null)
            {
                return("");
            }
            if (user1 == null)
            {
                user1 = new User();
            }
            if (user2 == null)
            {
                user2 = new User();
            }
            string str1 = SystemMessageTextHelper.CreateUserNameText(user1, false, extendedText);
            string str2 = user2.id > -2000000000L ? SystemMessageTextHelper.CreateUserNameText(user2, true, extendedText) : message.action_email;

            if (!extendedText)
            {
                str1 = "";
            }
            string str3   = "";
            string action = message.action;

            if (!(action == "chat_photo_update"))
            {
                if (!(action == "chat_photo_remove"))
                {
                    if (!(action == "chat_create"))
                    {
                        if (!(action == "chat_title_update"))
                        {
                            if (!(action == "chat_invite_user"))
                            {
                                if (action == "chat_kick_user")
                                {
                                    str3 = message.action_mid != (long)message.uid ? (!user1.IsFemale ? string.Format(CommonResources.ChatKickoutMaleFrm, str1, str2) : string.Format(CommonResources.ChatKickoutFemaleFrm, str1, str2)) : (!user1.IsFemale ? string.Format(CommonResources.ChatLeftConversationMaleFrm, str1) : string.Format(CommonResources.ChatLeftConversationFemaleFrm, str1));
                                }
                            }
                            else
                            {
                                str3 = message.action_mid != (long)message.uid ? (!user1.IsFemale ? string.Format(CommonResources.ChatInviteMaleFrm, str1, str2) : string.Format(CommonResources.ChatInviteFemaleFrm, str1, str2)) : (!user1.IsFemale ? string.Format(CommonResources.ChatReturnedToConversationMaleFrm, str1) : string.Format(CommonResources.ChatReturnedToConversationFemaleFrm, str1));
                            }
                        }
                        else
                        {
                            str3 = !user1.IsFemale ? string.Format(CommonResources.ChatTitleUpdateMaleFrm, str1, message.action_text) : string.Format(CommonResources.ChatTitleUpdateFemaleFrm, str1, message.action_text);
                        }
                    }
                    else
                    {
                        str3 = !user1.IsFemale ? string.Format(CommonResources.ChatCreateMaleFrm, str1, message.action_text) : string.Format(CommonResources.ChatCreateFemaleFrm, str1, message.action_text);
                    }
                }
                else
                {
                    str3 = !user1.IsFemale ? string.Format(CommonResources.ChatPhotoDeleteMaleFrm, str1) : string.Format(CommonResources.ChatPhotoDeleteFemaleFrm, str1);
                }
            }
            else
            {
                str3 = !user1.IsFemale ? string.Format(CommonResources.ChatPhotoUpdateMaleFrm, str1) : string.Format(CommonResources.ChatPhotoUpdateFemaleFrm, str1);
            }
            return(str3.Trim());
        }