pytg
pytg copied to clipboard
Error in function msg: parameter #1 <text> is not type UnicodeString
The problem
i've download command_send_message.py
from example directory and run it by python.
but return me this eror:
ValueError: Error in function msg: parameter #1 <text> is not type UnicodeString. (Not a string.)
I guess your input is no unicode string. So I assume python 2?
my trace:
Traceback (most recent call last):
File "command_send_message.py", line 13, in <module>
sender.msg("@ehsankhorasani", "text")
File "/home/fatman/w/pytg/.env/local/lib/python2.7/site-packages/pytg/sender.py", line 630, in command_alias
return self.execute_function(command_name, *args, **kwargs)
File "/home/fatman/w/pytg/.env/local/lib/python2.7/site-packages/pytg/sender.py", line 274, in execute_function
command_name, new_args = self._validate_input(function_name, arguments)
File "/home/fatman/w/pytg/.env/local/lib/python2.7/site-packages/pytg/sender.py", line 414, in _validate_input
function_name=function_name, number=i, type=func_type.__class__.__name__, param=str(func_type), error=str(err)))
ValueError: Error in function msg: parameter #1 <text> is not type UnicodeString. (Not a string.)
Edited by @luckydonald: Syntax highlighting
@ehsankhorasani you must decode
your text and username to send it via pytg
convert something like this
sender.send_msg("@somebody", "Hello World!")
to this
sender.send_msg("@somebody".decode("utf-8"), "Hello World!".decode("utf-8"))
EDIT: according to @luckydonald better way is this :
sender.send_msg(u"@somebody", u"Hello World!")
@shotgunner's comment applies to python 2. Python 3 works out of the box.
Actually
sender.send_msg(u"@somebody", u"Hello World!")
is possible too.