add get users list script

This commit is contained in:
bakatrouble 2019-03-03 21:34:28 +03:00
parent d4a877175d
commit d59d17a6d9
5 changed files with 41 additions and 2 deletions

15
.idea/deployment.xml Normal file
View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="PublishConfigData" autoUpload="Always" serverName="bakatrouble.pw">
<serverData>
<paths name="bakatrouble.pw">
<serverdata>
<mappings>
<mapping deploy="/tmp/pycharm_project_802" local="$PROJECT_DIR$" />
</mappings>
</serverdata>
</paths>
</serverData>
<option name="myAutoUpload" value="ALWAYS" />
</component>
</project>

4
.idea/encodings.xml Normal file
View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="Encoding" addBOMForNewFiles="with NO BOM" />
</project>

View File

@ -2,7 +2,7 @@
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$" />
<orderEntry type="inheritedJdk" />
<orderEntry type="jdk" jdkName="Remote Python 3.7.2 (sftp://root@bakatrouble.pw:22/srv/apps/lono/venv/bin/python)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">

View File

@ -78,5 +78,5 @@
<textMaps />
</LinkMapSettings>
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (lono)" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Remote Python 3.7.2 (sftp://root@bakatrouble.pw:22/srv/apps/lono/venv/bin/python)" project-jdk-type="Python SDK" />
</project>

20
get_users_list.py Normal file
View File

@ -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))