hello
Browse files- App/__init__.py +6 -24
- App/app.py +2 -10
App/__init__.py
CHANGED
@@ -1,38 +1,20 @@
|
|
1 |
-
import uuid, contextvars
|
2 |
from telethon import TelegramClient
|
3 |
-
import
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
-
def genUUID():
|
11 |
-
uuid_value = uuid.uuid4()
|
12 |
-
short_uuid = str(uuid_value)[:6]
|
13 |
-
return short_uuid
|
14 |
|
15 |
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
api_id=870972,
|
21 |
api_hash="ce2efaca02dfcd110941be6025e9ac0d",
|
22 |
-
)
|
23 |
-
await client.start(bot_token="6183919505:AAEhHFt4mI18bQeAf2Lj7AePXFRPVLrOFM8")
|
24 |
-
... # use the client
|
25 |
-
|
26 |
-
# Save the string session as a string; you should decide how
|
27 |
-
# you want to save this information (over a socket, remote
|
28 |
-
# database, print it and then paste the string in the code,
|
29 |
-
# etc.); the advantage is that you don't need to save it
|
30 |
-
# on the current disk as a separate file, and can be reused
|
31 |
-
# anywhere else once you log in.
|
32 |
-
temp= client.session.save()
|
33 |
-
SESSION.set(temp)
|
34 |
-
|
35 |
-
bot:TelegramClient = None
|
36 |
|
37 |
|
38 |
|
|
|
|
|
1 |
from telethon import TelegramClient
|
2 |
+
from telethon.sessions import StringSession
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
|
|
|
|
|
|
|
|
9 |
|
10 |
|
11 |
+
|
12 |
+
|
13 |
+
bot:TelegramClient = TelegramClient(
|
14 |
+
StringSession('1BVtsOIwBuxTiAi57fIIpM_mCJiic5U36YhvLughpTdbevbbipZPNIeTzhTi6KvPdigX9zFnvrLzFDthiat20fy44fpMuZMAKNO5mFg1LCGus1PeiQAOqhCO0LZbmBG3BNB5vgbuTJL9TgTUeY-QcFXlUVABwhYO9UiDBkS7IZCNa9eRsYBEVhXUc6O4kENQUerCCAwWFxAx9mxCkh7ADWsw5bNptl1pNvcdaUes6Zq_GW1eraTZ4mR2piiE3vyoqfzuRy40apmzvyFVkgtyD4p5-MCoIdVoS5zQONP2GA6G5Bw7Z2YOWI5D_Y51DxjQICnS2UDMLxqKhaqkUKeMR5GC-5RyNKVw='),
|
15 |
api_id=870972,
|
16 |
api_hash="ce2efaca02dfcd110941be6025e9ac0d",
|
17 |
+
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
|
20 |
|
App/app.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
from fastapi import FastAPI, Request
|
2 |
from fastapi.responses import JSONResponse
|
3 |
from fastapi.middleware.gzip import GZipMiddleware
|
4 |
-
from App import bot
|
5 |
from telethon import TelegramClient
|
6 |
from telethon.sessions import StringSession
|
7 |
from .Users.UserRoutes import user_router
|
@@ -47,15 +47,7 @@ def authjwt_exception_handler(request: Request, exc: AuthJWTException):
|
|
47 |
|
48 |
@app.on_event("startup")
|
49 |
async def startup_event():
|
50 |
-
|
51 |
-
await create_memsession()
|
52 |
-
bot = TelegramClient(
|
53 |
-
StringSession(SESSION.get()),
|
54 |
-
api_id=870972,
|
55 |
-
api_hash="ce2efaca02dfcd110941be6025e9ac0d",
|
56 |
-
)
|
57 |
-
|
58 |
-
# await bot.start(bot_token="6183919505:AAEhHFt4mI18bQeAf2Lj7AePXFRPVLrOFM8")
|
59 |
# await upload_bot.start()
|
60 |
# await models.create_all()
|
61 |
# models.metadata.create_all()
|
|
|
1 |
from fastapi import FastAPI, Request
|
2 |
from fastapi.responses import JSONResponse
|
3 |
from fastapi.middleware.gzip import GZipMiddleware
|
4 |
+
from App import bot
|
5 |
from telethon import TelegramClient
|
6 |
from telethon.sessions import StringSession
|
7 |
from .Users.UserRoutes import user_router
|
|
|
47 |
|
48 |
@app.on_event("startup")
|
49 |
async def startup_event():
|
50 |
+
await bot.start()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
# await upload_bot.start()
|
52 |
# await models.create_all()
|
53 |
# models.metadata.create_all()
|