Skip to content

Commit d14a60b

Browse files
committed
Fix rss exclude filter
- other minor fixes Signed-off-by: anasty17 <[email protected]>
1 parent 1572068 commit d14a60b

File tree

6 files changed

+24
-19
lines changed

6 files changed

+24
-19
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ quotes, even if it's `Int`, `Bool` or `List`.
234234
generate database. Data will be saved in Database: bot settings, users settings, rss data and incomplete tasks. **NOTE**: You can always edit all settings that saved in database from the official site -> (Browse collections). `Str`
235235
- `DOWNLOAD_DIR`: The path to the vps local folder where the downloads should be downloaded to. `Str`
236236
- `CMD_SUFFIX`: Commands index number. This number will added at the end all commands. `Str`|`Int`
237-
- `AUTHORIZED_CHATS`: Fill user_id and chat_id of groups/users you want to authorize. To auth only specific topic write it in this format `chat_id|thread_id` Ex:-100XXXXXXXXXXX|10. Separate them by space. `Int`
237+
- `AUTHORIZED_CHATS`: Fill user_id and chat_id of groups/users you want to authorize. To auth only specific topic(s) write it in this format `chat_id|thread_id` Ex:-100XXXXXXXXXXX|10 or Ex:-100XXXXXXXXXXX|10|12. Separate them by space. `Int`
238238
- `SUDO_USERS`: Fill user_id of users whom you want to give sudo permission. Separate them by space. `Int`
239239
- `DEFAULT_UPLOAD`: Whether `rc` to upload to `RCLONE_PATH` or `gd` to upload to `GDRIVE_ID`. Default is `gd`. Read
240240
More [HERE](https://github.com/anasty17/mirror-leech-telegram-bot/tree/master#upload).`Str`

bot/__init__.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -239,14 +239,13 @@
239239
if len(AUTHORIZED_CHATS) != 0:
240240
aid = AUTHORIZED_CHATS.split()
241241
for id_ in aid:
242-
if "|" in id_:
243-
chat_id, thread_id = id_.split("|")
244-
user_data[int(chat_id.strip())] = {
245-
"is_auth": True,
246-
"thread_ids": [int(thread_id.strip())],
247-
}
242+
chat_id, *thread_ids = id_.split("|")
243+
chat_id = int(chat_id.strip())
244+
if thread_ids:
245+
thread_ids = list(map(lambda x: int(x.strip()), thread_ids))
246+
user_data[chat_id] = {"is_auth": True, "thread_ids": thread_ids}
248247
else:
249-
user_data[int(id_.strip())] = {"is_auth": True}
248+
user_data[chat_id] = {"is_auth": True}
250249

251250
SUDO_USERS = environ.get("SUDO_USERS", "")
252251
if len(SUDO_USERS) != 0:

bot/__main__.py

+2
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,8 @@ async def main():
274274
sync_to_async(start_aria2_listener, wait=False),
275275
)
276276
create_help_buttons()
277+
bot_settings.add_job()
278+
scheduler.start()
277279

278280
bot.add_handler(
279281
MessageHandler(

bot/modules/authorize.py

+7-3
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,10 @@ async def authorize(_, message):
2727
thread_id = message.message_thread_id
2828
chat_id = message.chat.id
2929
if chat_id in user_data and user_data[chat_id].get("is_auth"):
30-
if thread_id is not None and thread_id in user_data[chat_id].get(
31-
"thread_ids", []
30+
if (
31+
thread_id is not None
32+
and thread_id in user_data[chat_id].get("thread_ids", [])
33+
or thread_id is None
3234
):
3335
msg = "Already Authorized!"
3436
else:
@@ -65,7 +67,9 @@ async def unauthorize(_, message):
6567
thread_id = message.message_thread_id
6668
chat_id = message.chat.id
6769
if chat_id in user_data and user_data[chat_id].get("is_auth"):
68-
if thread_id is not None and thread_id in user_data[chat_id].get("thread_ids", []):
70+
if thread_id is not None and thread_id in user_data[chat_id].get(
71+
"thread_ids", []
72+
):
6973
user_data[chat_id]["thread_ids"].remove(thread_id)
7074
else:
7175
update_user_ldata(chat_id, "is_auth", False)

bot/modules/bot_settings.py

+6-7
Original file line numberDiff line numberDiff line change
@@ -974,14 +974,13 @@ async def load_config():
974974
if len(AUTHORIZED_CHATS) != 0:
975975
aid = AUTHORIZED_CHATS.split()
976976
for id_ in aid:
977-
if "|" in id_:
978-
chat_id, thread_id = id_.split("|")
979-
user_data[int(chat_id.strip())] = {
980-
"is_auth": True,
981-
"thread_ids": [int(thread_id.strip())],
982-
}
977+
chat_id, *thread_ids = id_.split("|")
978+
chat_id = int(chat_id.strip())
979+
if thread_ids:
980+
thread_ids = list(map(lambda x: int(x.strip()), thread_ids))
981+
user_data[chat_id] = {"is_auth": True, "thread_ids": thread_ids}
983982
else:
984-
user_data[int(id_.strip())] = {"is_auth": True}
983+
user_data[chat_id] = {"is_auth": True}
985984

986985
SUDO_USERS = environ.get("SUDO_USERS", "")
987986
if len(SUDO_USERS) != 0:

bot/modules/rss.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -717,7 +717,7 @@ async def rss_monitor():
717717
data.get("sensitive", False)
718718
and any(x.lower() in item_title.lower() for x in flist)
719719
) or (
720-
data.get("sensitive", False)
720+
not data.get("sensitive", False)
721721
and any(x in item_title for x in flist)
722722
):
723723
parse = False
@@ -770,6 +770,7 @@ def add_job():
770770
replace_existing=True,
771771
)
772772

773+
773774
bot.add_handler(
774775
MessageHandler(
775776
get_rss_menu,

0 commit comments

Comments
 (0)