mirror of
https://github.com/ClassiCube/MCGalaxy.git
synced 2025-09-22 12:05:51 -04:00
Replace custom chat tokens on IRC. (Thanks Joseph)
This commit is contained in:
parent
80c99fa2e9
commit
979b9b4763
@ -45,6 +45,15 @@ namespace MCGalaxy {
|
||||
sb.Replace(token.Key, token.Value);
|
||||
}
|
||||
|
||||
public static string ApplyCustom(string text) {
|
||||
if (CustomTokens.Count == 0) return text;
|
||||
StringBuilder sb = new StringBuilder(text);
|
||||
foreach (var token in CustomTokens)
|
||||
sb.Replace(token.Key, token.Value);
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
|
||||
internal static Dictionary<string, TokenParser> standardTokens = new Dictionary<string, TokenParser> {
|
||||
{ "$name", p => p.DisplayName == null ? null :
|
||||
(Server.dollarNames ? "$" : "") + Colors.StripColors(p.DisplayName) },
|
||||
|
@ -108,6 +108,7 @@ namespace MCGalaxy {
|
||||
message = ".";
|
||||
message = EmotesHandler.Replace(message);
|
||||
message = FullCP437Handler.Replace(message);
|
||||
message = ChatTokens.ApplyCustom(message);
|
||||
message = CP437Writer.ConvertToUnicode(message);
|
||||
|
||||
if (color)
|
||||
@ -174,21 +175,15 @@ namespace MCGalaxy {
|
||||
}
|
||||
|
||||
void Player_PlayerDisconnect(Player p, string reason) {
|
||||
if (!Server.irc ||!IsConnected()) return;
|
||||
if (!Server.irc ||!IsConnected() || p.hidden) return;
|
||||
if (!Server.guestLeaveNotify && p.Rank <= LevelPermission.Guest) return;
|
||||
|
||||
string msg = p.DisplayName + " %Sleft the game (" + reason + ")";
|
||||
msg = ConvertMessage(msg, true);
|
||||
if (!p.hidden) connection.Sender.PublicMessage(channel, msg);
|
||||
Say(p.DisplayName + " %Sjoined the game (" + reason + "%S)", false);
|
||||
}
|
||||
|
||||
void Player_PlayerConnect(Player p) {
|
||||
if (!Server.irc ||!IsConnected()) return;
|
||||
if (!Server.irc ||!IsConnected() || p.hidden) return;
|
||||
if (!Server.guestJoinNotify && p.Rank <= LevelPermission.Guest) return;
|
||||
|
||||
string msg = p.DisplayName + " %Sjoined the game";
|
||||
msg = ConvertMessage(msg, true);
|
||||
if (!p.hidden) connection.Sender.PublicMessage(channel, msg);
|
||||
Say(p.DisplayName + " %Sjoined the game", false);
|
||||
}
|
||||
|
||||
void Player_PlayerChat(Player p, string message) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user