BinaryONe commited on
Commit
dc937f8
·
1 Parent(s): 513293c

Callback Update

Browse files
FileStream/Database/database.py CHANGED
@@ -17,10 +17,11 @@ class Database:
17
  self._client = motor.motor_asyncio.AsyncIOMotorClient(uri)
18
  self.db = self._client[database_name]
19
  self.users = self.db.Users
 
20
  self.files = self.db.Public_Files
21
  self.pfile = self.db.Private_Files
22
  self.web_upload = self.db.Web_Files
23
- self.web_upload = self.db.Temp_Files
24
 
25
  #---------------------[ SCHEMAS ]------------------------------#
26
  #---------------------[ NEW USER ]---------------------#
@@ -154,6 +155,12 @@ class Database:
154
  await self.count_links(file_info["user_id"], "+")
155
  return (await self.files.insert_one(file_info)).inserted_id
156
 
 
 
 
 
 
 
157
  # ---------------------[ FIND FILE IN DB for Bot and APIs]---------------------#
158
  async def get_file(self, _id):
159
  try:
 
17
  self._client = motor.motor_asyncio.AsyncIOMotorClient(uri)
18
  self.db = self._client[database_name]
19
  self.users = self.db.Users
20
+ self.tfiles = self.db.Temp_Files
21
  self.files = self.db.Public_Files
22
  self.pfile = self.db.Private_Files
23
  self.web_upload = self.db.Web_Files
24
+
25
 
26
  #---------------------[ SCHEMAS ]------------------------------#
27
  #---------------------[ NEW USER ]---------------------#
 
155
  await self.count_links(file_info["user_id"], "+")
156
  return (await self.files.insert_one(file_info)).inserted_id
157
 
158
+ # ---------------------[ ADD FILE TO Temp DB ]---------------------#
159
+ async def add_temp_file(self, file_info):
160
+ file_info["time"] = Time_ISTKolNow()
161
+ return (await self.tfiles.insert_one(file_info)).inserted_id
162
+
163
+
164
  # ---------------------[ FIND FILE IN DB for Bot and APIs]---------------------#
165
  async def get_file(self, _id):
166
  try:
FileStream/bot/plugins/FileHandlers/callback.py CHANGED
@@ -186,21 +186,18 @@ async def cb_data(bot: Client, update: CallbackQuery):
186
  title, year = Get_Title_Year(name)
187
  print(f"** ANY SEARCH :{name} YEAR :{year}")
188
  get_imdb_id = json.loads(imdb.search(title, year=int(year)))
189
- #print(f"ANY SEARCH :{title} YEAR :{year} IMDB Response :{res}")
190
- #print("TMDB",search_tmdb_any(title, year))
191
- #print(f"IMDB ID :{get_imdb_id['results'][0]['id']}")
192
  print(f"\n** GET_ID {get_imdb_id}")
193
  res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
194
  print(f"\n** IMDB Response :{res}")
195
  instruction = {
196
- "privacy_type": "PUBLIC",
197
  "user_id": user_id,
198
  "user_type": "TELEGRAM",
199
- "IMDB_id": get_imdb_id['results'][0]['id'],
200
- "poster": res['poster'],
201
- "title": res['name'],
202
- "release_date": res["datePublished"],
203
- "type": res['type'],
204
  "description":res["description"],
205
  "keywords":res["keywords"].split(",") if res.get("keywords") else [],
206
  "genre": res.get("genre", []) ,
@@ -208,7 +205,7 @@ async def cb_data(bot: Client, update: CallbackQuery):
208
 
209
  file_info = get_file_info(message, instruction)
210
  # Here we are Adding the File Into the database First
211
- inserted_id = await db.add_file(file_info)
212
  await get_file_ids(False, inserted_id, message)
213
  #All the Time Get_file_ids should be called before update privacy or else tagged_users will be {}
214
  await db.update_privacy(file_info)
 
186
  title, year = Get_Title_Year(name)
187
  print(f"** ANY SEARCH :{name} YEAR :{year}")
188
  get_imdb_id = json.loads(imdb.search(title, year=int(year)))
 
 
 
189
  print(f"\n** GET_ID {get_imdb_id}")
190
  res=json.loads(imdb.get_by_id(get_imdb_id['results'][0]['id']))
191
  print(f"\n** IMDB Response :{res}")
192
  instruction = {
193
+ "privacy_type": "TEMPORARY",
194
  "user_id": user_id,
195
  "user_type": "TELEGRAM",
196
+ "IMDB_id":get_imdb_id['results'][0]['id'] if get_imdb_id['results'][0]['id']else "None",
197
+ "poster": res['poster'] if res['poster'] else "None",
198
+ "title": res['name'] if res['name'] else "None",
199
+ "release_date": res["datePublished"] if res['datePublished'] else "None",
200
+ "type": res['type'] if res['type'] else "None",
201
  "description":res["description"],
202
  "keywords":res["keywords"].split(",") if res.get("keywords") else [],
203
  "genre": res.get("genre", []) ,
 
205
 
206
  file_info = get_file_info(message, instruction)
207
  # Here we are Adding the File Into the database First
208
+ inserted_id = await db.add_temp_file(file_info)
209
  await get_file_ids(False, inserted_id, message)
210
  #All the Time Get_file_ids should be called before update privacy or else tagged_users will be {}
211
  await db.update_privacy(file_info)
FileStream/config.py CHANGED
@@ -21,14 +21,14 @@ class Telegram:
21
  START_PIC = env.get('START_PIC',"https://graph.org/file/290af25276fa34fa8f0aa.jpg")
22
  VERIFY_PIC = env.get('VERIFY_PIC',"https://graph.org/file/736e21cc0efa4d8c2a0e4.jpg")
23
  MULTI_CLIENT = False
24
- FLOG_CHANNEL = int(env.get("FLOG_CHANNEL", None)) # Logs channel for file logs
25
- PFLOG_CHANNEL = int(env.get("PFLOG_CHANNEL"))
26
- TFLOG_CHANNEL = int(env.get("TFLOG_CHANNEL", None))
27
  ULOG_GROUP = int(env.get("ULOG_GROUP", None)) # Logs channel for user logs
28
  MODE = env.get("MODE", "primary")
29
  SECONDARY = True if MODE.lower() == "secondary" else False
30
  AUTH_USERS = list(set(int(x)for x in str(env.get("AUTH_USERS", "")).split()))
31
- DATA_SOURCES = [FLOG_CHANNEL, PFLOG_CHANNEL, ULOG_GROUP]
32
 
33
  class TMDB:
34
  API = str(env.get("TMDB_API", ""))
 
21
  START_PIC = env.get('START_PIC',"https://graph.org/file/290af25276fa34fa8f0aa.jpg")
22
  VERIFY_PIC = env.get('VERIFY_PIC',"https://graph.org/file/736e21cc0efa4d8c2a0e4.jpg")
23
  MULTI_CLIENT = False
24
+ FLOG_CHANNEL = int(env.get("FLOG_CHANNEL", None)) # Logs channel for file logs/Temporary Files
25
+ PFLOG_CHANNEL = int(env.get("PFLOG_CHANNEL", None)) #Private File Logs
26
+ DFLOG_CHANNEL = int(env.get("TFLOG_CHANNEL", None)) # Database File log All Public Files
27
  ULOG_GROUP = int(env.get("ULOG_GROUP", None)) # Logs channel for user logs
28
  MODE = env.get("MODE", "primary")
29
  SECONDARY = True if MODE.lower() == "secondary" else False
30
  AUTH_USERS = list(set(int(x)for x in str(env.get("AUTH_USERS", "")).split()))
31
+ DATA_SOURCES = [FLOG_CHANNEL, PFLOG_CHANNEL, DFLOG_CHANNEL, ULOG_GROUP]
32
 
33
  class TMDB:
34
  API = str(env.get("TMDB_API", ""))
FileStream/utils/FileProcessors/bot_utils.py CHANGED
@@ -157,8 +157,8 @@ async def gen_priv_file_link(_id):
157
  reply_markup = InlineKeyboardMarkup(
158
  [[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
159
  [
160
- InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link),
161
- InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",callback_data=f"msgdelpvt_{_id}")
162
  ], [InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]])
163
  return reply_markup, stream_text
164
 
@@ -177,24 +177,23 @@ async def gen_link(_id):
177
  file_link = f"https://t.me/{FileStream.username}?start=file_{_id}"
178
 
179
  if "video" in mime_type:
180
- stream_text = LANG.STREAM_TEXT.format(file_name, file_size, stream_link,page_link, file_link)
181
  reply_markup = InlineKeyboardMarkup(
182
  [[
183
- InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link),
184
- InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)
185
  ],
186
  [
187
- InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link),
188
- InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",callback_data=f"msgdelpvt_{_id}")
189
  ], [InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]])
190
  else:
191
  stream_text = LANG.STREAM_TEXT_X.format(file_name, file_size, stream_link,file_link)
192
  reply_markup = InlineKeyboardMarkup(
193
  [[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
194
  [
195
- InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link),
196
- InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",
197
- callback_data=f"msgdelpvt_{_id}")
198
  ], [InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]])
199
  return reply_markup, stream_text
200
 
 
157
  reply_markup = InlineKeyboardMarkup(
158
  [[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
159
  [
160
+ InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link),
161
+ InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",callback_data=f"msgdelpvt_{_id}")
162
  ], [InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]])
163
  return reply_markup, stream_text
164
 
 
177
  file_link = f"https://t.me/{FileStream.username}?start=file_{_id}"
178
 
179
  if "video" in mime_type:
180
+ stream_text = LANG.STREAM_TEXT.format(file_name, file_size, stream_link, page_link, file_link)
181
  reply_markup = InlineKeyboardMarkup(
182
  [[
183
+ InlineKeyboardButton("sᴛʀᴇᴀᴍ", url=page_link),
184
+ InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)
185
  ],
186
  [
187
+ InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link),
188
+ InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",callback_data=f"msgdelpvt_{_id}")
189
  ], [InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]])
190
  else:
191
  stream_text = LANG.STREAM_TEXT_X.format(file_name, file_size, stream_link,file_link)
192
  reply_markup = InlineKeyboardMarkup(
193
  [[InlineKeyboardButton("ᴅᴏᴡɴʟᴏᴀᴅ", url=stream_link)],
194
  [
195
+ InlineKeyboardButton("ɢᴇᴛ ғɪʟᴇ", url=file_link),
196
+ InlineKeyboardButton("ʀᴇᴠᴏᴋᴇ ғɪʟᴇ",callback_data=f"msgdelpvt_{_id}")
 
197
  ], [InlineKeyboardButton("ᴄʟᴏsᴇ", callback_data="close")]])
198
  return reply_markup, stream_text
199
 
FileStream/utils/FileProcessors/file_properties.py CHANGED
@@ -79,7 +79,8 @@ async def get_file_ids(client: Client | bool, db_id: str, message) -> Optional[F
79
  if file_info['location'] in Telegram.DATA_SOURCES:
80
  print("Already Present in Data Sources ", Telegram.DATA_SOURCES)
81
  else:
82
- log_msg = await send_file(FileStream, db_id,file_info['file']['file_id'], message,Telegram.FLOG_CHANNEL)
 
83
  #updated_info = update_file_info(log_msg)
84
  await db.update_file_info(db_id, update_file_info(log_msg))
85
  await db.update_file_ids(db_id, await update_file_id(await db.get_file(db_id),MULTI_CLIENTS))
 
79
  if file_info['location'] in Telegram.DATA_SOURCES:
80
  print("Already Present in Data Sources ", Telegram.DATA_SOURCES)
81
  else:
82
+ source = Telegram.DFLOG_CHANNEL if file_info['privacy_type']=="PUBLIC" else Telegram.FLOG_CHANNEL
83
+ log_msg = await send_file(FileStream, db_id, file_info['file']['file_id'], message, source)
84
  #updated_info = update_file_info(log_msg)
85
  await db.update_file_info(db_id, update_file_info(log_msg))
86
  await db.update_file_ids(db_id, await update_file_id(await db.get_file(db_id),MULTI_CLIENTS))