@@ -1549,16 +1549,22 @@ def set_uservars(self, user, data=None):
15491549 for key , value in uservars .items ():
15501550 self ._users [uid ][key ] = value
15511551
1552- elif type (user ) in [text_type ] and type (data ) is dict :
1552+ elif type (user ) in [text_type , str ] and type (data ) is dict :
15531553 # Setting variables for a single user.
1554+ if not user in self ._users :
1555+ self ._users [user ] = dict (topic = "random" )
1556+
15541557 for key , value in data .items ():
15551558 self ._users [user ][key ] = value
15561559
15571560 else :
15581561 raise TypeError (
1559- "set_uservars() may only be called with types (str, dict) or "
1560- "(dict<str, dict>) but you called it with types ({}, {})" .format (
1561- type (user ), type (data ),
1562+ "set_uservars() may only be called with types ({str}, dict) or "
1563+ "(dict<{str}, dict>) but you called it with types ({a}, {b})"
1564+ .format (
1565+ str = "unicode" if sys .version_info [0 ] < 3 else "str" ,
1566+ a = type (user ),
1567+ b = type (data ),
15621568 ),
15631569 )
15641570
@@ -1831,7 +1837,7 @@ def _format_message(self, msg, botreply=False):
18311837
18321838 # Make sure the string is Unicode for Python 2.
18331839 if sys .version_info [0 ] < 3 and isinstance (msg , str ):
1834- msg = msg .decode ('utf8' )
1840+ msg = msg .decode ()
18351841
18361842 # Lowercase it.
18371843 msg = msg .lower ()
0 commit comments