rapierorg / telegram-bot-swift

Telegram Bot SDK for Swift (unofficial)
https://github.com/rapierorg/telegram-bot-swift/wiki
Apache License 2.0
375 stars 63 forks source link

Fatal error: Server stopped due to error: Hü… #119

Closed Butanediol closed 2 years ago

Butanediol commented 2 years ago

Sorry for the vague title of this issue.

I test my bot with a fresh token (a new bot) and it works fine. But when I switched to my old one, it always throws an weird error:

截屏2021-08-10 下午11.49.50.png

Based on my digging, it was a decoding error:

Error: keyNotFound(CodingKeys(stringValue: "location", intValue: nil), Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "result", intValue: nil), _JSONKey(stringValue: "Index 1", intValue: 1), CodingKeys(stringValue: "chosenInlineResult", intValue: nil)], debugDescription: "No value associated with key CodingKeys(stringValue: \"location\", intValue: nil) (\"location\").", underlyingError: nil))

But how could it possibly run properly on one bot while generates error on another one?

So I compared their settings via @botfather. The only difference is Inline feedback. The failed bot is set to 100% and the other one is 0.

So maybe the parameter chosenInlineResult.location should be an Optional?

zmeyc commented 2 years ago

Thank you for reporting the issue! Fixed in master, please try if it works.

Regenerating bindings is easy: edit API/TelegramAPIDefinition.yml, then in API/ dir:

make
make install

to regenerate Swift bindings.

Butanediol commented 2 years ago

Sorry to bother. Something similar happened to Poll.explanation which also should be optional.

image.png

https://github.com/rapierorg/telegram-bot-swift/pull/123

zmeyc commented 2 years ago

@Butanediol Thanks for the PR!