mirror of
https://github.com/tiennm99/forward-telegram-message.git
synced 2026-10-14 02:15:59 +00:00
[Add] init
This commit is contained in:
1 parent
4e6a6d1b71
commit
4073f2723d
5 files changed
+46
-3
No files matched your search
@@ -0,0 +1,5 @@
|
||||
PHONE=+1234567890
|
||||
API_ID=123456789
|
||||
API_HASH=0123456789abcdef0123456789abcdef
|
||||
SOURCE_GROUP_ID=-123456789
|
||||
DESTINATION_GROUP_ID=-123456789
|
||||
+5
-3
@@ -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
|
||||
@@ -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')
|
||||
@@ -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()
|
||||
Binary file not shown.
Reference in new issue
Block a user