Closed joell closed 1 year ago
I think the thought behind that was, that "{}" already needs 2 characters.
But indeed, as sender.py:341 shows,
it will most certainly (if json parsing doesn't fail) be a dict
.
And Something > 0 totally makes sense.
If you like you can submit a PR, I am not sure when I get around to edit that in.
Hmm... so when I enter the program with a debugger, something
's value
isn't a str
or dict
... it's a list
. And that made sense to me, since telegram-cli returns a JSON array for its response to the history
command.
My eventual local solution to this was to change the history
check from res.something
to res.anything
, as even []
is a valid response from history
for an empty conversation (or one with an offset that precludes any messages that did exist).
However, if the expectation is that the result is either always a string or always a dictionary, then something much more serious might be going on.
Most of the command return values are not properly implemented, as I never needed them... heh. As I currently have no running cli, could you check if it is always a list? If yes, you could edit in a check for that, like mentioned in comment of #90? I'd much appreciate it.
If you attempt to retrieve the history of a conversation which has only a single message, pytg will fail with an
IllegalResponseException("Should return something.")
in thesomething
method inresult_parser.py
.What's happening is that telegram-cli is returning an array with a single JSON object for the single message in the conversation, exactly as it should. However,
something(value)
requires thatlen(value) > 1
, which is not the case since the length of the JSON array is exactly 1. This causes pytg to improperly fail.The fix should be as simple as replacing
len(value) > 1
withlen(value) >= 1
orlen(value) > 0
(which is what I would have expected "something" to imply).