haskell-telegram-api
haskell-telegram-api copied to clipboard
Automatically add "bot"-prefix to tokens in URLs
The telegram bot API requires URLs to be of the form https://api.telegram.org/bot<token>/... but this library constructs them as https://api.telegram.org/<token>/... , so users have to add the "bot" manually to the token. This is surprising as the "bot" prefix isn't part of the token given by telegram.
I'd be willing to work on this if there's a chance that it would be merged. I believe just adding the "bot" prefix as a breaking change and bumping the major version is the cleanest solution. But if backwards-compatibility absolutely has to be maintained, something like
addBotPrefix (Token tok) =
Token (if "bot" `Text.isPrefixOf` tok then tok else "bot" <> tok)
would work because the token apparently always start with digits, so the strings should be prefix-free.