From d59d17a6d96f91a9d70f503e16fd02c9aca3a0bc Mon Sep 17 00:00:00 2001 From: bakatrouble Date: Sun, 3 Mar 2019 21:34:28 +0300 Subject: [PATCH] add get users list script --- .idea/deployment.xml | 15 +++++++++++++++ .idea/encodings.xml | 4 ++++ .idea/lono.iml | 2 +- .idea/misc.xml | 2 +- get_users_list.py | 20 ++++++++++++++++++++ 5 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 .idea/deployment.xml create mode 100644 .idea/encodings.xml create mode 100644 get_users_list.py diff --git a/.idea/deployment.xml b/.idea/deployment.xml new file mode 100644 index 0000000..d5d0de2 --- /dev/null +++ b/.idea/deployment.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml new file mode 100644 index 0000000..15a15b2 --- /dev/null +++ b/.idea/encodings.xml @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/.idea/lono.iml b/.idea/lono.iml index 6711606..148add1 100644 --- a/.idea/lono.iml +++ b/.idea/lono.iml @@ -2,7 +2,7 @@ - + diff --git a/.idea/misc.xml b/.idea/misc.xml index 9a28146..0347726 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -78,5 +78,5 @@ - + \ No newline at end of file diff --git a/get_users_list.py b/get_users_list.py new file mode 100644 index 0000000..80515ba --- /dev/null +++ b/get_users_list.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python3 + +from html import escape + +from models import Subscriber +from telegram import Bot + +from config import BOT_TOKEN + + +bot = Bot(BOT_TOKEN) + +subs = Subscriber.select() +messages = [] +for sub in subs: + chat = bot.send_message(sub.user_id, '.').chat + chat_name = escape(f'{chat.first_name or ""} {chat.last_name or ""} {chat.title or ""}'.rstrip()) + messages.append(f'#{sub.id:>4} {sub.user_id:>20} {chat_name}') + +bot.send_message(98934915, '\n'.join(messages))