Artur Galyamov
2 years ago
2 changed files with 33 additions and 0 deletions
@ -0,0 +1,9 @@ |
|||||||
|
TELEGRAM_BOT_TOKEN=fdaTTdf |
||||||
|
TELEGRAM_CHAT_ID=-1 |
||||||
|
JOOMLA_TOKEN=c2ddd |
||||||
|
VK_LOGIN=user@mail.pro |
||||||
|
VK_PASSWORD=123123 |
||||||
|
VK_OWNER_ID=-2 |
||||||
|
OK_ACCESS_TOKEN=aatk |
||||||
|
OK_APPLICATION_KEY=FFCF |
||||||
|
OK_APPLICATION_SECRET_KEY=GGD |
@ -0,0 +1,24 @@ |
|||||||
|
import requests |
||||||
|
from django.core.management import BaseCommand |
||||||
|
|
||||||
|
from crossposting_backend.settings import promoter_secrets |
||||||
|
|
||||||
|
|
||||||
|
class Command(BaseCommand): |
||||||
|
|
||||||
|
def handle(self, *args, **options): |
||||||
|
bot_token = promoter_secrets['TELEGRAM_BOT_TOKEN'] |
||||||
|
get_updates_url = f'https://api.telegram.org/bot{bot_token}/getUpdates' |
||||||
|
response = requests.get(get_updates_url) |
||||||
|
if response.ok: |
||||||
|
json_body = response.json() |
||||||
|
if json_body['ok']: |
||||||
|
if 'result' in json_body and len(json_body['result']) > 0: |
||||||
|
print(json_body['result'][0]['channel_post']['sender_chat']['id']) |
||||||
|
else: |
||||||
|
print('Нет обновлений') |
||||||
|
else: |
||||||
|
print(json_body['error_code']) |
||||||
|
else: |
||||||
|
print(response.status_code) |
||||||
|
return 0 |
Loading…
Reference in new issue