How to strip color codes used by mIRC users?

前端 未结 6 1526
小鲜肉
小鲜肉 2020-12-16 06:15

I\'m writing a IRC bot in Python using irclib and I\'m trying to log the messages on certain channels.
The issue is that some mIRC users and some Bots write using color

6条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-16 06:55

    AutoDl-irssi had a very good one written in perl, here it is in python:

    def stripMircColorCodes(line) : line = re.sub("\x03\d\d?,\d\d?","",line) line = re.sub("\x03\d\d?","",line) line = re.sub("[\x01-\x1F]","",line) return line

提交回复
热议问题