Skip to content

Commit bf45dfd

Browse files
committed
feat: Add process_message method for Telegram polling support
- Add process_message method to handle polling messages - Convert polling messages to webhook format for compatibility - Enables processing of messages received through polling in addition to webhooks
1 parent a6e5c72 commit bf45dfd

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

app/services/telegram_bot_service.rb

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,27 @@ def process_webhook(update)
9292
end
9393
end
9494

95+
def process_message(message)
96+
Rails.logger.info "Processing polling message: #{message.inspect}"
97+
98+
# Convert polling message to webhook format for compatibility with existing code
99+
if message.text
100+
update = {
101+
"message" => {
102+
"chat" => { "id" => message.chat.id },
103+
"from" => {
104+
"id" => message.from.id,
105+
"username" => message.from.username
106+
},
107+
"text" => message.text
108+
}
109+
}
110+
process_text_message(update)
111+
else
112+
Rails.logger.info "Received non-text message type from polling: #{message.inspect}"
113+
end
114+
end
115+
95116
private
96117

97118
def process_text_message(update)

0 commit comments

Comments
 (0)