Skip to content
This repository was archived by the owner on Sep 13, 2023. It is now read-only.

Commit b6acab4

Browse files
committed
Fixed allowed ids not working
1 parent 69fcf47 commit b6acab4

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ according to your configuration.
8989
> - **id**: List of telegram IDs allowed in the bot, without password. Obtain
9090
> if from bots like [@getmyid\_bot](https://t.me/getmyid_bot).
9191
> ```json
92-
> "ids": [
92+
> "id": [
9393
> 123123123,
9494
> 132322322
9595
> ]

src/cmds.py

+5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
async def unlock(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
1919
cid = ut.cid(update)
20+
ut.add_whitelisted(cid)
2021
if (
2122
context.args
2223
and ut.passwd_correct(context.args[0])
@@ -30,6 +31,7 @@ async def new(
3031
update: Update, context: ContextTypes.DEFAULT_TYPE, callback: bool = False
3132
) -> None:
3233
cid = ut.cid(update)
34+
ut.add_whitelisted(cid)
3335
if db.cached(cid):
3436
if callback:
3537
await ut.remove_keyboard(update)
@@ -38,6 +40,7 @@ async def new(
3840

3941
async def settings(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
4042
cid = ut.cid(update)
43+
ut.add_whitelisted(cid)
4144
if db.cached(cid):
4245
btn_lst = [
4346
ut.button([("Language/Voice", "lang_menu")]),
@@ -211,6 +214,7 @@ async def tts(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
211214

212215
async def voice(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
213216
cid = ut.cid(update)
217+
ut.add_whitelisted(cid)
214218
if db.cached(cid):
215219
status = await ut.is_active_conversation(update)
216220
if status:
@@ -244,6 +248,7 @@ async def message(
244248
update: Update, context: ContextTypes.DEFAULT_TYPE, text: str = None
245249
) -> None:
246250
cid = ut.cid(update)
251+
ut.add_whitelisted(cid)
247252
if db.cached(cid):
248253
status = await ut.is_active_conversation(update)
249254
if status:

src/utils.py

+13
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ def settings(key: str) -> str:
8989
return DATA["config"]["settings"][key]
9090

9191

92+
def chats(key: str) -> str:
93+
return DATA["config"]["chats"][key]
94+
95+
9296
def path(key: str) -> str:
9397
return Path(PATH["dir"]).joinpath(PATH[key])
9498

@@ -101,6 +105,15 @@ def passwd_correct(passwd: str) -> bool:
101105
return passwd == DATA["config"]["chats"]["password"]
102106

103107

108+
def whitelisted(cid: int) -> bool:
109+
return cid in chats("id")
110+
111+
112+
def add_whitelisted(cid: int) -> None:
113+
if whitelisted(cid) and not db.cached(cid):
114+
db.add_user(cid)
115+
116+
104117
def cid(update: Update) -> int:
105118
return update.effective_chat.id
106119

0 commit comments

Comments
 (0)