How can I prevent my Telegram bot from disconnecting unexpectedly?

hey man, i’ve dealt with this before. try using a keep-alive mechanism. send a ping to the telegram api every few mins to keep the connection active. also, wrap ur main loop in a begin-rescue block to catch and log errors. that way u can see whats causing the disconnect. good luck!