A quick tool for listing the Telegram Messenger groups that a user-account is invited into and listing the users within groups.
- A Telegram Messenger account invited into one or more group chat channels.
- Setup API credentials on the Telegram Messenger account core.telegram.org/api/obtaining_api_id
The following environment variables must be set with their associated values:-
telegram_api_idtelegram_api_hashtelegram_api_phone
All output is JSON data-structures making it easier to chain with other tools such as jq for further parsing and
filtering if required.
Log status messages are sent to stderr and do not get in the way of pipe style tool chaining.
telegram-interface.py -g | jq .[].name
20190804Z085638 - Telegram Interface
20190804Z085638 - Saving to data file: +000000000000-20190804Z072817.json
20190804Z085638 - Connected to Telegram with api_id: 12345
"Awesome Group A"
"Another Group"
"A Chat Forum"
...
telegram-interface.py -f +000000000000-20190804Z072817.json -u | jq -r '(.[0] | keys_unsorted) as $keys | $keys, map([.[ $keys[] ]])[] | @csv'
20190804Z145459 - Telegram Interface
20190804Z145459 - Loading data file: +000000000000-20190804Z072817.json
"id","username","firstname","lastname"
123456789,"awesomeuser","Awesome","User"
234567878,"someotheruser","Some","Other User"
236423423,"givemeuser","Give","Me"
...
cat +000000000000-20190804Z072817.json | jq '.chat_groups[]| "\(.id)~,~\(.title)~,~\(.megagroup)"' | tr '~' '"'
"183982374","Awesome Group A","true"
"198123123","Another Group","null"
"1734975345","A Chat Forum","true"
...
usage: telegram-interface.py [-h] [-e] [-f <filename>] [-o <filename>] [-g]
[-u]
Telegram Interface
optional arguments:
-h, --help show this help message and exit
-e Output the current environment variable values and exit.
-f <filename> Data filename to use, if the file already exists it will be
loaded as input without connecting to Telegram. By default
auto-generates a filename in the <cwd>.
-o <filename> Output filename, by default to <stdout>
-g Output groups, can be used with -u to obtain users in groups
-u Output users
BSD-2-Clause - see LICENSE file for full details.