LPgenerator/mattermost_bot

Unicode issue in Message._gen_at_message method

Closed this issue · 0 comments

Hi all,

First, Thank you for providing a useful library.
It really good and easy to use.

But I have trouble with unicode

It is the code of issue

# -*- coding: utf-8 -*-

....

    def _gen_at_message(self, text):
        return '@{}: {}'.format(self.get_username(), text)

if self.get_username() was returning unicode chars,
Exception was occured

File "/home/abyss/mattermost/mattermost_bot/dispatcher.py", line 200, in _gen_at_message
return '@{}: {}'.format(self.get_username(), text)

becuase,
'@{}: {}' it is utf-8 encoded text
but
self.get_username() is unicode text
it can't merged without converting.

All literal string should use unicode
for example, This code should fixed like below

    def _gen_at_message(self, text):
        return u'@{}: {}'.format(self.get_username(), text)