sudo apt install python3-pip
pip3 install pipenv
curl https://pyenv.run | zsh
pyenv install 3.9.2
pipenv install --python 3.9
pipenv shell
snap install pycharm-community --classic
이유는 모르겠지만 ubuntu 20.04에서 python3.9가 설치 오류가 발생한다.
telethon은 파이썬의 텔레그램 클라이언트 모듈이다. 클라이언트 모듈이기 때문에 일반 유저로 공개방에 접근하여 작업을 하는게 가능하다.
인원이 많은 방의 수신이 1분이상 지연되는 문제가 있다.
telethon에 지연현상이 있어서 최종 선택한 클라이언트 모듈이다.
pip3 install telethon
pip3 install pyrogram
api 키는 https://my.telegram.org 에서 발급할 수 있으며 한개만 발급가능하고 삭제도 안되므로 주의하자.
# test telethon
from telethon import TelegramClient, events, sync
# These example values won't work. You must get your own api_id and
# api_hash from https://my.telegram.org, under API Development.
api_id = xxx
api_hash = 'xxxxxxx'
client = TelegramClient('session_name', api_id, api_hash)
client.start()
api 키를 가지고 텔레그램 클라이언트로서 접속을 하는 예제이다. 실행 해 보면 전화번호 인증을 통해 텔레그램에 실제 접속까지 이루어진다.