* Created first dev version of Telegram channels parser * Created endpoint for get Telegram Channel RSS * Added *.session and venv/ in .gitignore * Added dependency telethon * Added script for init Telethon * Removed unnecessary script parse.py * Added possibility for dynamic generate RSS feeds from Telegram channel * Deleted saving Telegram messages in database * Minor refactor Created separated files: parsers.py and utils.py * Enhanced text parser: parse title and description if can * Added attachment parsers: video, photo, voice and file parsers * Added possibility for merge grouped messages into one item * Renamed url for parse Telegram channel from "rss/telegram/<str:channel>" to "parsing/telegram/<str:channel>/" * Format code with black * Refactor: created package parsing.telegram and rename utils to models * Added Makefile target telegram
12 lines
352 B
Python
12 lines
352 B
Python
import os
|
|
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "infomate.settings")
|
|
import django
|
|
django.setup()
|
|
|
|
from telethon.sync import TelegramClient
|
|
from django.conf import settings
|
|
|
|
|
|
with TelegramClient(settings.TELEGRAM_SESSION_FILE, settings.TELEGRAM_APP_ID, settings.TELEGRAM_APP_HASH) as client:
|
|
print("Successfully setup Telegram session.")
|