Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using Butterfly.HabboHotel.GameClients;
- using Butterfly.Communication.Packets.Outgoing.WebSocket;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Threading.Tasks;
- using Butterfly.Communication.Packets.Outgoing.Structure;
- using Butterfly.Communication.Packets.Outgoing.WebSocket.Mentions;
- using Butterfly.HabboHotel.WebClients;
- namespace Butterfly.HabboHotel.Rooms.Chat.Mentions
- {
- public class MentionManager
- {
- public string MentionPattern = @"@(.*?)(?=\s|$)";
- public string StylePrefix = "";
- public string StyleSuffix = "";
- public string Parse(GameClient Session, string Message)
- {
- string StyledMessage = Message;
- int ChangeLength = StylePrefix.Length + StyleSuffix.Length;
- int ChangeCount = 0;
- foreach (Match m in Regex.Matches(Message, MentionPattern))
- {
- string TargetUsername = m.Groups[1].Value;
- GameClient TargetClient = ButterflyEnvironment.GetGame().GetClientManager().GetClientByUsername(TargetUsername);
- StyledMessage = StyledMessage.Insert(ChangeCount * ChangeLength + m.Index, StylePrefix);
- StyledMessage = StyledMessage.Insert(ChangeCount * ChangeLength + m.Index + StylePrefix.Length + m.Length, StyleSuffix);
- ChangeCount++;
- if (TargetClient == null)
- {
- Session.SendPacket(RoomNotificationComposer.SendBubble("tag", $"Une erreur est survenue quand tu as tenté de mentionner {TargetUsername}, peut-être qu'il est hors ligne !"));
- continue;
- }
- if (TargetClient == Session)
- {
- continue;
- }
- TargetClient.SendPacket(RoomNotificationComposer.SendBubble("tag", $"Hey, " + Session.GetHabbo().Username + " a tagué ton pseudo.\n\nVoici son message: " + Message + "\n\nClique sur le message pour le rejoindre !", "event:navigator/goto/" + Session.GetHabbo().CurrentRoomId + " "));
- }
- return StyledMessage;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement