Telegram

Telegram

This feeder creates a stream using the Telegram API.
In order to use this feeder, you need to create a Telegram Application and get app_id and app_hash.
If you set the session folder the session will be stored and only the first run it will ask for the code received from the phone number specified in the config.

Based on gotd/td

Parameters

ParameterTypeDefaultDescription
app_idSTRINGemptyapp ID (see this)
app_hashSTRINGemptyApp hash (see this)
phone_numberSTRINGemptyPhone number of the account to use (it should contain the country code)
session_folderSTRINGemptyPath of the folder where storing the sessions

*events = “channel_message”,“chat_message”

... | <telegram: app_id="xxx", app_hash="yyyy", phone_number="+1123654789", session_folder="/tmp/sessions"> | ...

Output

The messages propagated by this feeder could contain different info and they depend from the type of the event received.

Every propagated Message will have a type extra field with the name of the events (see the above list).

Event chat_message

We received a message from a group or a user.
The main field of the Message contains the text of the message.

NameDescription
typeit contains channel_message for this event
msg_edited“true” if it is an edit event of a message
texttext of the message
msg_hasmedia“true” if the message contains a media (photo or doc)
msg_medianamename of the file sent
msg_mediaextextension of the file sent
chat_callactive“true” if there is a call active
chat_creator“true” if the user is the creator
chat_deactivated“true” if the chat has been deactivated
chat_idID of the chat
chat_partecipantscountnumber of partecipants
chat_titletitle of the chat
chat_versionversion of the chat
user_bot“true” if the user is a bot
user_isclosefriend“true” if the user is a close friend
user_iscontact“true” if the user is a contact
user_isdeleted“true” if the user has been deleted
user_isfake“true” if the user has been flagged as fake/spam
user_idID of the user
user_accesshashaccess hash of the user
user_mutualcontact“true” if we are a contact of the user and viceversa
user_premium“true” if the user has a premium account
user_verified“true” if the user is verified
user_firstnamename of the user
user_lastnamelastname of the user
user_usernameusername of the user
user_languagelanguage of the user
user_phonephone number of the user

Event channel_message

We received a message from a group or a user.
The main field of the Message contain the text of the message.

NameDescription
typeit contains channel_message for this event
msg_edited“true” if it is an edit event of a message
texttext of the message
msg_hasmedia“true” if the message contains a media (photo or doc)
chan_broadcast“true” if it is a broadcast channel
chan_callactive“true” if there is a call active
chan_creator“true” if the user is the creator
chan_fake“true” if the channel has been flagged as fake
chan_forum“true” if the channel is a forum
chan_gigagroup“true” if the channel is a gigagroup
chan_hasgeo“true” if the channel has geoposition
chan_haslink“true” if the channel has a link
chan_idID of the channel
chan_hasJoinRequest“true” if the users has to be approved by admins
chan_ismegagroup“true” if the channel is a megagroup
chan_isrestricted“true” if the channel is restricted
chan_titletitle of the channel
chan_verified“true” if the channel is verified
chan_partecipantscountnumber of partecipants
chan_usernameusername of the channel
user_bot“true” if the user is a bot
user_isclosefriend“true” if the user is a close friend
user_iscontact“true” if the user is a contact
user_isdeleted“true” if the user has been deleted
user_isfake“true” if the user has been flagged as fake/spam
user_idID of the user
user_accesshashaccess hash of the user
user_mutualcontact“true” if we are a contact of the user and viceversa
user_premium“true” if the user has a premium account
user_verified“true” if the user is verified
user_firstnamename of the user
user_lastnamelastname of the user
user_usernameusername of the user
user_languagelanguage of the user
user_phonephone number of the user

Examples

telegramRule => <telegram: app_id="xxx", app_hash="yyyy", phone_number="+1123654789", session_folder="/tmp/sessions"> | text(target="chan_id", pattern="123456") | telegram(action="download_file", filename="/tmp/{{ .msg_filename }}") | telegram(action="send_message", to="@username", text="the file '{{ .msg_filename }}' received from {{ .user_username }} has been downloaded.")