Rocket.Chat icon indicating copy to clipboard operation
Rocket.Chat copied to clipboard

Telegram integration (Sticker attachments)

Open Againstreality opened this issue 9 years ago • 7 comments

Hi we like to integrate Telegram, The documented way is pure text to text. But Sticker Attachments etc are the real deal for any integration. Do you think its possible?

Thanks

Againstreality avatar Dec 21 '16 12:12 Againstreality

+1

Angl0r avatar Dec 21 '16 12:12 Angl0r

Please see https://rocket.chat/docs/administrator-guides/integrations/telegram#simple-telegram-bot-

engelgabriel avatar Dec 21 '16 12:12 engelgabriel

Would you please read what i have written? The Problem is that the solution from rocket.chat/docs is just a text to text way. We need a way to transfer attachments and Stickers

Againstreality avatar Dec 21 '16 12:12 Againstreality

HI there: The following worked for me @Againstreality:

class Script {
    process_incoming_request({ request }) {
        // COMMENT THE BELOW LINE THE AFTER YOU RUN THE INTEGRATION SUCCESSFULLY
        console.log(request.content);
        if ('edited_message' in request.content) {
            request.content.message = request.content.edited_message;
        }
        let who = request.content.message.from.username
        if(!who)  {
          who = `${request.content.message.from.first_name} ${request.content.message.from.last_name}`
        }
        let body = request.content.message.text
        
        if(!body) {
          if(request.content.message.sticker.emoji) {
            // It's a sticker
            body = request.content.message.sticker.emoji            
        } else {
           return {}
          }
        }
        
        return {
            content: {
                username: who,
                icon_url: '/avatar/' + request.content.message.from.username + '.jpg',
                text: body
            }
        };
    }
}

robbyoconnor avatar Jan 11 '17 22:01 robbyoconnor

PR made https://github.com/RocketChat/Rocket.Chat.Docs/pull/174/files

robbyoconnor avatar Jan 11 '17 22:01 robbyoconnor

you are awsome !! Thx have you found a way to transfer attachments?

Againstreality avatar Jan 12 '17 10:01 Againstreality

@Againstreality if you look at the sample code, I updated it to what I'm using right now.

robbyoconnor avatar Jan 12 '17 10:01 robbyoconnor