[Add] init

This commit is contained in:
tiennm99 committed 2024-06-22 18:22:19 +07:00
1 parent 4e6a6d1b71
commit 4073f2723d
5 files changed
+46 -3

No files matched your search

+5
View File
@@ -0,0 +1,5 @@
PHONE=+1234567890
API_ID=123456789
API_HASH=0123456789abcdef0123456789abcdef
SOURCE_GROUP_ID=-123456789
DESTINATION_GROUP_ID=-123456789
+5 -3
View File
@@ -106,10 +106,8 @@ ipython_config.py
#pdm.lock
# pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
# in version control.
# https://pdm.fming.dev/latest/usage/project/#working-with-version-control
# https://pdm.fming.dev/#use-with-ide
.pdm.toml
.pdm-python
.pdm-build/
# PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
__pypackages__/
@@ -160,3 +158,7 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
.idea/
*.session
*.csv
+11
View File
@@ -0,0 +1,11 @@
import os
from dotenv import load_dotenv
load_dotenv()
phone = os.getenv('PHONE')
api_id = os.getenv('API_ID')
api_hash = os.getenv('API_HASH')
source_group_id = os.getenv('SOURCE_GROUP_ID')
destination_group_id = os.getenv('DESTINATION_GROUP_ID')
+25
View File
@@ -0,0 +1,25 @@
import getpass
from telethon.errors import SessionPasswordNeededError
from telethon.sync import TelegramClient
from config import *
# client = TelegramClient(phone, api_id, api_hash)
# client.connect()
# if not client.is_user_authorized():
# client.send_code_request(phone)
# try:
# client.sign_in(code=input('Enter code: '))
# except SessionPasswordNeededError:
# client.sign_in(password=getpass.getpass())
# client.start(phone)
with TelegramClient('session_name', api_id, api_hash) as client:
@client.on(events.NewMessage(chats=source_group_id))
async def handler(event):
await client.forward_messages(destination_group_id, event.message)
client.run_until_disconnected()
BIN
View File
Binary file not shown.