Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in function msg: parameter #1 <text> is not type UnicodeString #111

Open
mohamadiank opened this issue Mar 13, 2017 · 4 comments
Open

Comments

@mohamadiank
Copy link

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.)

@luckydonald
Copy link
Owner

luckydonald commented Mar 13, 2017

I guess your input is no unicode string.
So I assume python 2?

@mohamadiank
Copy link
Author

mohamadiank commented Mar 14, 2017

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

@shotgunner
Copy link

shotgunner commented Jun 18, 2017

@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!")

@luckydonald
Copy link
Owner

luckydonald commented Jun 20, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants