telegram-bot-ruby
telegram-bot-ruby copied to clipboard
RAW json message AS IS it came from Telegram
Problem: I want to log all income messages to PostgreSQL jsonb field AS IS. But I can't without useless empty json keys overhead.
Telegram::Bot::Client.run(token) do |bot|
bot.listen do |message|
message.to_json
end
end
Contains a lot of useless empty data:
"forward_from":null,"forward_from_chat":null,"forward_from_message_id":null,"forward_signature":null,"forward_date":null,"reply_to_message":null,"edit_date":null,"author_signature":null,"text":"/start","entities":[{"type":"bot_command","offset":0,"length":6,"url":null,"user":null}],"caption_entities":[],"audio":null,"document":null,"game":null,"photo":[],"sticker":null,"video":null,"voice":null,"video_note":null,"caption":null,"contact":null,"location":null,"venue":null,"new_chat_members":[],"left_chat_member":null,"new_chat_title":null,"new_chat_photo":[],"delete_chat_photo":null,"group_chat_created":null,"supergroup_chat_created":null,"channel_chat_created":null,"migrate_to_chat_id":null,"migrate_from_chat_id":null,"pinned_message":null,"invoice":null,"successful_payment":null}
What is your proposal?
@ivanovaleksey message.raw method to access original message hash
This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days.