Closed Conny225 closed 8 years ago
The failing part is the --permanent-peer-ids
parameter (introduced in bca30085a8a34a3363b278b65261afcd013013c2)
This was introduced recently.
You have currently 2 options:
This requires the telegram CLI from the test branch
git clone -b test --recursive https://github.com/vysheng/tg.git tg-dev
cd tg-dev
# Now follow the normal compiling instructions.
or
If you want instead to use the normal CLI,
the last compatible pytg release seems to be v0.4.5,
You can install that either from source (zip) or with pip install pytg==0.4.5
Time of writing this: pytg@ed8d62
, v0.4.8 and tg@160231
(test)
If you just want to send a message, the 2nd option is probably easier.
thx
change_user_group: can't find the user telegramd to switch to
Traceback (most recent call last):
File "anlage.py", line 13, in <module>
sender.send_msg('Constantin_Breuer', "Hello World!")
File "/usr/local/lib/python2.7/dist-packages/pytg/sender.py", line 570, in command_alias
return self.execute_function(command_name, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pytg/sender.py", line 250, in execute_function
command_name, new_args = self._validate_input(function_name, arguments)
File "/usr/local/lib/python2.7/dist-packages/pytg/sender.py", line 355, 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 send_msg: parameter #1 <test> is not type UnicodeString. (Not a string.)
Iam a very bad programmer pls help me agian
can't find the user telegramd to switch to
It tries to run with unix user telegramd
, but doesn't find such user.
You did probably start the cli with such parameter:
--username <user-name>/-U <user-name> change uid after start
But why Telegramd? Where i can Change it?
Huh, I was assuming you set it.
Can you post the output of your program when you turn on logging?
# add this to the first lines in your file, before using pytg
import logging
logging.basicConfig(level=logging.DEBUG)
INFO:pytg:Starting Telegram Executable: "/root/telegram-bot/tg/bin/telegram-cli -R -W -P 4458 -k /root/telegram-b ot/tg/tg-server.pub --json"
DEBUG:pytg.sender:Parsing raw: Argument help - <command> (needed)
DEBUG:pytg.sender:Sending command > [disable_preview] help
<
INFO:pytg:CLI did not responde.
change_user_group: can't find the user telegramd to switch to
DEBUG:pytg.sender:Parsing raw: Argument help - <command> (needed)
DEBUG:pytg.sender:Sending command > [disable_preview] help
<
DEBUG:pytg.sender:Socket Connected.
DEBUG:pytg.sender:All Sent.
INFO:pytg:CLI available.
DEBUG:pytg.sender:Parsing send_msg: Argument Constantin_Breuer - <peer> (needed)
DEBUG:pytg.sender:Parsing send_msg: Argument Hello World! - <test> (needed)
DEBUG:pytg.sender:Got error
Traceback (most recent call last):
File "/usr/local/lib/python2.7/dist-packages/pytg/sender.py", line 348, in _validate_input
arg_value = func_type.parse(arg)
File "/usr/local/lib/python2.7/dist-packages/pytg/argument_types.py", line 60, in parse
raise ArgumentParseError("Not a string.")
ArgumentParseError: Not a string.
Traceback (most recent call last):
File "anlage.py", line 17, in <module>
sender.send_msg('Constantin_Breuer', "Hello World!")
File "/usr/local/lib/python2.7/dist-packages/pytg/sender.py", line 570, in command_alias
return self.execute_function(command_name, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/pytg/sender.py", line 250, in execute_function
command_name, new_args = self._validate_input(function_name, arguments)
File "/usr/local/lib/python2.7/dist-packages/pytg/sender.py", line 355, 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 send_msg: parameter #1 <test> is not type UnicodeString. (Not a string.)
INFO:pytg.sender:Quit Sending. Not allowing sending anymore.
WARNING:pytg.sender:Terminating currently sending request.
INFO:pytg.sender:Currently not Sending.
INFO:pytg:Closing Connections.
DEBUG:pytg:Closing sender.
DEBUG:pytg.sender:Already did quit Sending. Not allowing sending.
WARNING:pytg.sender:Terminating currently sending request.
INFO:pytg.sender:Currently not Sending.
DEBUG:pytg:Closing sender.
DEBUG:pytg.receiver:receiver thread existing: Not created.
INFO:pytg:Asking to CLI to stop.
DEBUG:pytg:Sender already stopped. Unable to issue safe_quit or quit to exit via socket.
INFO:pytg:CLI did stop (0).
DEBUG:pytg.sender:Already did quit Sending. Not allowing sending.
INFO:pytg.sender:Quit Sending. Not allowing sending anymore.
WARNING:pytg.sender:Terminating currently sending request.
INFO:pytg.sender:Currently not Sending.
It gets the -k /root/telegram-b
parameter, that is the problem.
That is the Public Key you specified.
# location
tg/tg-server.pub # the key file.
tg/server.pub # this one is possible too.
tg/bin/telegram-cli # the executable.
In your case probably located in /root/telegram-bot/tg/server.pub
.
You can verify yourself, if the cli will run, or the error is in pytg, by executing the stuff directly behind Starting Telegram Executable:
.
Also please wrap the code in code blocks, that improves readability even more.
```python YOUR CODE ```
Meaning the pubkey_file
parameter of Telegram( ... )
should probably be:
pubkey_file="/root/telegram-bot/tg/server.pub"
After trying too start it with this Parameters,
-R -W -P 4458 -k /root/telegram-b
it stuck at this Point.
Loading plugin location Loading plugin media Loading plugin plugins Loading plugin channels Loading plugin set Loading plugin stats Loading plugin time Loading plugin version Loading plugin weather Loading plugin xkcd Loading plugin youtube Data loaded from file data/google.lua
That certainly is not coming from pytg or the telegram-cli.
What bot are you using?
Also, google.lua
indicates you are using lua, but this is using python.
i didnt use any bot. I only want to use my bot
You are loading plugin
s, that was your log said.
both pytg and the cli have no such plugins.
You need to find where they come from, they are not part of pytg.
I get the same errors too.
Maybe it is the CLI then... Strange...
Did you disable lua support while running configure
?
I moved on to Ubuntu, and downgraded the version of pytg to make it work.
@ziban please help me locate that issue. What was your system before? Did you disable liblua?
I was on mac. To reproduce the error, use Python 2.7.10, and install it using the standard instructions. I downgraded and also installed the test version but it did not work. The only thing I did not do was disable liblua. I will try to do that today during the day (2 a.m right now)
It seems ou already tried https://github.com/vysheng/tg/issues/1014 and https://github.com/vysheng/tg/issues/996 Yeah, timezones are a stange invention...
@ziban you could try my compiled binary: tg binaries
I could not make the binaries to work too. The error I got was dyld: Library not loaded: /usr/local/lib/libreadline.6.dylib Referenced from: /Users/collo/Desktop/Classwork/COMP150INT/project/tg/bin/telegram-cli Reason: image not found Trace/BPT trap: 5
.
Let me try to disable liblua and see how it would respond
I still get the initial error when I disable liblua.
@ziban I think that is libreadline
as seen in https://github.com/vysheng/tg/issues/199#issuecomment-66763098
This issue is no longer relevant because the dev branch of telegram-cli have been merged to master.
@Nanoseb thanks for the note.
Did you guys solved this problem? same problem plz help :( I started this
from pytg.sender import Sender
sender = Sender(host="localhost",port=4458) sender.send_msg("youngeun_kwon","hello")
and here is the error.
Traceback (most recent call last):
File "msgtest.py", line 5, in
You need unicode. You have 3 options:
sender.send_msg(u"youngeun_kwon",u"hello")
from __future__ import unicode_literals
from pytg.sender import Sender
sender = Sender(host="localhost",port=4458) sender.send_msg(u"youngeun_kwon",u"hello")
u mean like this?
Traceback (most recent call last):
File "msgtest.py", line 5, in
I got this :(
@youngeunkwon This means, you don't have a CLI connected. Did you run telegram from the code? Like in the Documentation: https://github.com/luckydonald/pytg#start-telegram
I know I have to start telegram-cli in json mode port 4458, but I don't know how
@youngeunkwon You can let it run on default, and turn on logging. to see how it will be launched: https://github.com/luckydonald/pytg#in-case-of-errors
from pytg import Telegram tg = Telegram( telegram="/home/pi/tg/bin/telegram-cli", pubkey_file="/home/pi/tg/tg-server.pub") receiver = tg.receiver sender = tg.sender
from pytg.sender import Sender
sender = Sender(host="localhost",port=4458) sender.send_msg(u"youngeun_kwon",u"hello")
start Telegram-cli like this? I got
Traceback (most recent call last):
File "msgtest.py", line 11, in
@youngeunkwon If you start the CLI manually again, with the command arguments as seen in the debug mode, does sending it manually in the CLI work?
So msg youngeun_kwon "hello"
?
bin/telegram-cli -k tg-server.pub --json -P 4458 -W
Telegram-cli version 1.4.1, Copyright (C) 2013-2015 Vitaly Valtman
Telegram-cli comes with ABSOLUTELY NO WARRANTY; for details type `show_license'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show_license' for details.
Telegram-cli uses libtgl version 2.1.0
Telegram-cli includes software developed by the OpenSSL Project
for use in the OpenSSL Toolkit. (http://www.openssl.org/)
I: config dir=[/home/pi/.config/telegram-cli]
> msg youngeun_kwon "hello?"
{"text": "hello?", "event": "message", "id": "010000009162cd10880000000000000006a4c20e3fb5f96c", "out": true, "flags": 16643, "from": {"id": "$010000009162cd1006a4c20e3fb5f96c", "phone": "821029061008", "peer_type": "user", "peer_id": 281895569, "print_name": "youngeun_kwon", "last_name": "kwon", "flags": 720897, "first_name": "youngeun", "username": "yskwon"}, "date": 1478391342, "to": {"id": "$010000009162cd1006a4c20e3fb5f96c", "phone": "821029061008", "peer_type": "user", "peer_id": 281895569, "print_name": "youngeun_kwon", "last_name": "kwon", "flags": 720897, "first_name": "youngeun", "username": "yskwon"}, "unread": true, "service": false}
{"result": "SUCCESS"}
>
you mean this? Yeah this works
You can probably try to replace youngeun_kwon
with chat#281895569
(id of peer) or @ yskwon
(username).
from pytg import Telegram tg = Telegram( telegram="/home/pi/tg/bin/telegram-cli", pubkey_file="/home/pi/tg/tg-server.pub") receiver = tg.receiver sender = tg.sender
from pytg.sender import Sender
sender = Sender(host="localhost",port=4458) sender.send_msg(u"chat#281895569",u"hello")
u mean this? I got this
Traceback (most recent call last): File "msgtest.py", line 11, in <module> sender.send_msg(u"chat#281895569",u"hello") File "build/bdist.linux-armv7l/egg/pytg/sender.py", line 630, in command_alias File "build/bdist.linux-armv7l/egg/pytg/sender.py", line 354, in execute_function pytg.exceptions.FailException: Error 38: u'can not parse arg #1' (command u"[disable_preview] msg chat#281895569 'hello'\n")
Could you try [disable_preview] msg chat#281895569 'hello'
manually again?
msg chat#28185569 'hello' {"error": "can not parse arg #1", "result": "FAIL", "error_code": 38}
like this?
huh. maybe it is chatid#28185569
now.
Try [disable_preview] msg youngeun_kwon 'hello'
With the [disable_preview]
part
msg youngeun_kwon 'hello' {"event": "message", "id": "010000009162cd10890000000000000006a4c20e3fb5f96c", "from": {"id": "$010000009162cd1006a4c20e3fb5f96c", "peer_type": "user", "peer_id": 281895569, "print_name": "youngeun_kwon", "first_name": "youngeun", "flags": 720897, "last_name": "kwon", "phone": "821029061008", "username": "yskwon"}, "flags": 16643, "text": "hello", "to": {"id": "$010000009162cd1006a4c20e3fb5f96c", "peer_type": "user", "peer_id": 281895569, "print_name": "youngeun_kwon", "first_name": "youngeun", "flags": 720897, "last_name": "kwon", "phone": "821029061008", "username": "yskwon"}, "out": true, "unread": true, "service": false, "date": 1478392342} {"result": "SUCCESS"}
weird. it works
Traceback (most recent call last): File "msgtest.py", line 11, in
sender.send_msg(u"youngeun_kwon",u"hello") File "build/bdist.linux-armv7l/egg/pytg/sender.py", line 630, in command_alias File "build/bdist.linux-armv7l/egg/pytg/sender.py", line 354, in execute_function pytg.exceptions.FailException: Error 38: u'can not parse arg #1' (command u"[disable_preview] msg youngeun_kwon 'hello'\n")
but this doesn't hmm... I can't understand
This means something in the cli might have changed, rendering [disable_preview] unusable. Please open a new issue with that.
It actually still seems to exist in the cli. interface.c:2248
Then you mean I can't make it work?
I don't know. As I am not using the CLI anywhere anymore (switched to using the bot api with pytgbot) I can't really help in detail, sorry. Still, maybe you can keep us updated on your findings?
Sure. I'm a highschool student and I'm doing a little project I want to talk with bot messenger to send me some pictures of my house or text me for gas stove alarms. can you recommend me some other ways to make my project work?
And thx for your advise though.
@youngeunkwon Yeah, if the bot api is available to you, try that instead. The mentioned pytgbot library. If you need help with that, just join me on telegram: https://telegram.me/pytg_group
I Need your Help. i can´t start my script.
Sorry for my Bad English
I want to Send a Message, when a sensor is false. i only Need the code to send the Message.