Strip nick colors

This commit is contained in:
Pedro de Oliveira 2019-12-05 21:28:05 +00:00
parent 4d7b6725af
commit 6c78fdcdd5
1 changed files with 6 additions and 1 deletions

View File

@ -38,6 +38,7 @@ except ImportError:
# without the i18n module
_ = lambda x: x
import re
from .doomserver import IndividualServer
from .huffman import HuffmanObject, SKULLTAG_FREQS
@ -45,6 +46,10 @@ class Doom(callbacks.Plugin):
"""Zandronum Server Query"""
threaded = True
def __strip_colors(self, nick):
regex = r"\x1C[A-Za-z\-\+\*\!]?|\[\w+\]?"
return re.sub(regex, "", nick, 0)
def __format_message(self, info):
message = "{} @ {} [ {} ] - Players:4 {} ".format(
info['name'],
@ -55,7 +60,7 @@ class Doom(callbacks.Plugin):
if info['num_players'] > 0:
for player in info['players']:
message += "{} [Kills: {}] ".format(player['nick'], player['kills'])
message += "{} [Kills: {}] ".format(self.__strip_colors(player['nick']), player['kills'])
return message[:-1]