Skip to contents

A method for obtaining data on the mentions of a keyword / phrase grouped by channel. Suitable for tracking channels that often write on a given topic, mention a brand or person in Telegram publications. Returns information about the channel, the number of mentions, reach, and the date of the last mention of the keyword in the channel.

Usage

tg_mentions_by_channels(
  query,
  peer_type = c("all", "channel", "chat"),
  start_date = Sys.Date() - 15,
  end_date = Sys.Date(),
  hide_forwards = 0,
  strong_search = 0,
  minus_mords = NULL,
  extended_syntax = 0
)

Arguments

query

Search query

peer_type

Source type (channel, chat, all)

start_date

Published date from (timestamp)

end_date

Date published to (timestamp)

hide_forwards

Hide reposts from search results

strong_search

Enable strict search (disables morphology and search by part of a word)

minus_mords

List of negative words (separator - space)

extended_syntax

Whether the request uses extended query syntax, see details

Value

list

Details

Keyword / phrase search methods support extended query syntax. You must pass the extendedSyntax parameter (or extended_syntax in newer API methods) to indicate to the parser that the search query contains statements from the extended query language.

Morphology:

Regardless of the form in which you used a word in a query, by default all its morphological forms are taken into account (in any case, singular and plural). That is, by request mom will also find publications in which mom, mom, mom, mom, etc. are found. To change this behavior, you must use the = operator.

Exact occurrence of the word. Operator =

The = operator in front of a word tells the analyzer that the given word should be searched for in an exact match with the transmitted one. The query =mom will only find posts with the word mom. Publications containing the words mum, mum, mum, mum in the text will NOT be found.

Search by multiple words

When transferring several words separated by spaces to a search query, publications will be found in which each of these words occurs at the same time. The request mom dad will find publications in the text of which both of these words appear simultaneously in any order and case, at any distance from each other.

OR operator |

If you need to find publications in which at least one of the words occurs, you must use the OR operator |. Request Mom | dad will find publications in the text of which at least one of these words is found.

Search for a phrase. Operator ""

The query mama washed the frame, enclosed in double quotes, sets a strict word order, explaining to the analyzer that it needs to find the entire phrase passed. Only those publications will be found in which these three words appear side by side in the same order as specified in the request. Publications containing these words in word forms other than those submitted will also be found. To change this behavior, you must use the = operator. The query = "mama soap frame" will only find publications in which these three words appear side by side in the same order and in the same case as indicated in the query.

Using negative keywords. Operator -

Using the operator - you can specify which words should not appear in the text of the publication. The query "mama soap" -frame will show publications that contain the phrases mummy soap, mummy washed, ..., but do not contain the words frame, frame, etc.

Grouping words. Operator ()

Using parentheses in a search query allows you to group parts of a query and make more complex combinations using the operators described above. The query (mom | dad | brother | sister) (soap | painted) (frame | door) will find publications in the text of which at least one word from each word group is necessarily found. Those. publications will be found containing: mom washed the frame, dad washed the frame, sister painted the door, etc. The query (mom | dad) (dyed) - (frame | door | hair) will find publications, the text of which must contain at least one of the words of the first group mom, dad, it must contain a word from the second group painted, dyed, dyed, but not contains words from the last group frame, door, hair.

You can practice writing search queries in our publication search tool (do not forget to check the "Advanced language" checkbox to enable the advanced query syntax mode).

Examples

if (FALSE) {
mentions_data <- tg_mentions_by_channels(
    query = 'Alexey Seleznev',
    start_date = '2021-09-01',
    end_date = '2021-09-30'
)

mentions <- mentions_data$items
channels <- mentions_data$channels
}