Skip to content

Instantly share code, notes, and snippets.

@xDeda
Last active November 5, 2019 00:16
Show Gist options
  • Save xDeda/9bb5e84672475d359f70051053edfa67 to your computer and use it in GitHub Desktop.
Save xDeda/9bb5e84672475d359f70051053edfa67 to your computer and use it in GitHub Desktop.
Finding color in TFM chat
<?
function Colorify($q) {
$q = explode("<br />", $q);
foreach ($q as $qq) {
if (strpos($qq, "just connected.") || strpos($qq, "has disconnected.") || strpos($qq, "No cheese for you! ^_^") !== false) {
echo "<span class=\"connect\">" . $qq . "</span><br />";
} elseif (strpos($qq, "< [") !== false) {
echo "<span class=\"wout\">" . $qq . "</span><br />";
} elseif (strpos($qq, "is now your shaman, follow her!") !== false) {
echo "<span class=\"bluesham\">" . $qq . "</span><br />";
} elseif (strpos($qq, "name is already taken") !== false) {
echo "<span class=\"errors\">" . $qq . "</span><br />";
} elseif (strpos($qq, "You have joined the channel") !== false) {
echo "<span class=\"chat1\" style=\"color: #F0C5FE;\">" . $qq . "</span><br />";
} elseif (strpos($qq, "had just unlocked the") !== false) {
echo "<span class=\"special\">" . $qq . "</span><br />";
} elseif (strpos($qq, "> [") !== false) {
echo "<span class=\"wintext\">";
$qq = str_replace("[", "[<span class=\"winname\">", $qq);
echo str_replace("]", "</span>]", $qq);
echo "</span><br />";
} elseif (strpos($qq, "[Shaman ") !== false) {
$qq = str_replace("[Shaman ", "<span class=\"names\">[Shaman ", $qq);
echo str_replace("]", "]</span><span class=\"bluesham\"> ", $qq) . "</span><br />";
} elseif (strpos($qq, "[") == 0) {
$qq = str_replace("[", "<span class=\"names\">[", $qq);
echo str_replace("]", "]</span>", $qq) . "<br />";
} elseif (strpos($qq, "• [SERVER]") !== false) {
echo "<span class=\"mod\">" . $qq . "</span><br />";
} elseif (strpos($qq, "• [") == 0) {
$qq = str_replace("• [", "<span class=\"tc\">•</span> <span class=\"tn\">[", $qq);
echo str_replace("]", "]</span><span class=\"tc\">", $qq) . "</span><br />";
}
else {
echo $qq . "<br />";
}
}
}
?>
.errors {
color: #CB546B; /* This tribe name is already taken, please choose another. */
}
.info {
color: #6C77C1; /* Admshumaker is now your shaman, follow her! */
}
.special {
color: #BABD2F; /* Admshumaker had just unlocked the «Cheeeeeese *-*» title. */
}
.text {
color: #C2C2DA; /* [Admshumaker] Hello. */
}
.connect {
color: #606090; /* Admshumaker - disconnected */
}
.names {
color: #009D9D; /* [Admshumaker] */
}
.mod {
color: #ED67EA; /* • [SERVER] The server will restart in 2 minutes. */
}
.bluesham {
color: #98E2EB; /* Admshumaker is now your shaman, follow her! */
}
.pinksham {
color: #FEB1FC; /* [Shaman Admshumaker] Hello. */
}
.wout {
color: #EDCC8D; /* < [Evilsantah] hi qt */
}
.winname {
color: #E68D43; /* > [Evilsantah] */
}
.wintext {
color: #F0A78E; /* > [Evilsantah] hi qt */
}
.tn {
color: #30BA76; /* • [Admshumaker] */
}
.tc {
color: #92CF91; /* • [Admshumaker] Hello. */
}
.chat1 {
color: #F0C5FE; /* [20:13] [•] */
}
.chat2 {
color: #CAA5CE; /* [20:13] [•] You have joined the channel [#united kingdom] */
}
.server {
color: #12DA8A; /* • [en] Don't forget to nominate Transformice for "the Best Use Of A Farm Animal Award"! * /
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment