Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Normalize the telegram message #8

Open
CDimonaco opened this issue May 23, 2021 · 0 comments
Open

Normalize the telegram message #8

CDimonaco opened this issue May 23, 2021 · 0 comments
Assignees
Milestone

Comments

@CDimonaco
Copy link
Member

CDimonaco commented May 23, 2021

The telegram bot api, in each update, includes a message structure, we are interested in the entities section, in particular to the entities of type url and hashtag, the entities structure offers only the offset of entities, in the full text message.

So we should, take the original message, check for the entities, recover the full entities in the message text and create another data structure with only the relevant field and entities of the message.

We should pass the entity to the "validator", in order to check for valid links, as described in #1

Example

message {
  message_id: 6,
  from: {
    id: 32970657,
    is_bot: false,
    first_name: 'Guabanal',
    username: 'guabao',
    language_code: 'en'
  },
  chat: {
    id: 32970657,
    first_name: 'Guabanal',
    username: 'guabao',
    type: 'private'
  },
  date: 1621790947,
  text: 'ciao http://google.it #prova',
  entities: [
    { offset: 5, length: 16, type: 'url' },
    { offset: 22, length: 6, type: 'hashtag' }
  ]
}

We can use telegraf as bot framework, but we will have the same message data structure

CDimonaco added a commit that referenced this issue May 23, 2021
@brainrepo brainrepo added this to the 1.0 milestone Jun 3, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants