Comments (4)
Thank you for reporting this issue! I will look at it closer later this week.
from telegram-bot-simple.
I think it could be lost exception in https://github.com/fizruk/telegram-bot-simple/blob/master/src/Telegram/Bot/Simple.hs#L119 on request error
from telegram-bot-simple.
@anpryl yes, there are actually two places in that function where exceptions might ruin things:
and
Now when I was working on this before I was not concerned with exception handling for some reason.
For now, to fix your issue, you can simply ignore exceptions and try update in the next iteration.
However, I think it would be good to introduce a friendly way to deal with exceptions (or at least report them). The library design basically follows simple MVC like gloss, The Elm Architecture and Miso, and not one of those deals with user exceptions AFAIK (Elm does not even have those).
Perhaps we should merely add a new handler to the Bot
definition:
import Control.Monad.Catch
data BotApp model action = BotApp
{ botExceptionHandlers :: [Handler BotM Action]
, ...
}
Then we could use it like this (untested):
shieldWith :: [Handler BotM Action] -> ClientM () -> ClientM ()
shieldWith handlers m = runBotM Nothing (BotM (lift m) `catches` handlers)
startPolling :: [Handler BotM Action] -> (Update -> ClientM ()) -> ClientM ()
startPolling handlers handleUpdate = go Nothing
where
go lastUpdateId = do
...
res <- getUpdates (GetUpdatesRequest offset Nothing Nothing Nothing)
`shieldWith` handlers
...
mapM_ (flip runBotM (reader handleUpdate `catches` handlers)) updates
...
In the code above I need also to pass generated actions back for processing and probably run handlers in forks. We probably don't want to handle exceptions inside exception handlers. And we probably want to add a catch-all default exception handler to the end of botExceptionHandlers
list.
@anpryl what do you think?
from telegram-bot-simple.
@fizruk I like the idea to have separate exception handlers for handleUpdate
.
But I doubt if it needed for getUpdates
. I think that getUpdates
exceptions should be logged with a subsequent retry. It might be a good idea to add LoggingT
to allow library users control logging destination.
from telegram-bot-simple.
Related Issues (20)
- What is callbackQueryDataRead? HOT 1
- `command` UpdateParser is eating newlines HOT 2
- High CPU usage HOT 6
- Add support for bot mention in command HOT 1
- `Telegram.Bot.API.UpdatingMessages.editMessageReplyMarkup` is seemingly broken HOT 1
- Bot API 6.6 HOT 1
- telegram-bot-simple-0.11 + telegram-bot-api-6.5 as dependencies
- Bot API 6.7
- Inline mode is broken HOT 1
- SendMessage hangs indefinitely on some sendMessageText field values HOT 1
- Telegram-bot-simple hangs when something kills the thread responsible for actions processing HOT 1
- Bot API 6.8
- Bot API 6.9
- Bot API 7.0 🔥 HOT 1
- Support Mini Apps (WebApp)
- Update UpdateType
- Bot API 7.1 (February 16, 2024)
- Bot API 7.2 (March 31, 2024)
- Bot API 7.3 (May 6, 2024)
- Bot API 7.4 (May 28, 2024)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from telegram-bot-simple.