Skip to content

Commit

Permalink
multi Owner id support (UsergeTeam#190)
Browse files Browse the repository at this point in the history
* fix f-string

* multiple Owner Id Support

* fixed for Multiple owner id support

* some tweaks

* added missing parameter in conversation.py (UsergeTeam#192)

* fix download TypeError + friendly method to handle downloads

* fix showing unloaded and disabled plugins in help

* deepsource fix

* some cleanup + optimize upload plugin + fix promote

* ignore updater issue

* optimizing

Co-authored-by: rking32 <[email protected]>
Co-authored-by: Phyco-Ninja <[email protected]>
  • Loading branch information
3 people authored Nov 14, 2020
1 parent 1eea59e commit 837bec5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion userge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class Config:
WORKERS = min(32, int(os.environ.get("WORKERS")) or os.cpu_count() + 4)
BOT_TOKEN = os.environ.get("BOT_TOKEN", None)
HU_STRING_SESSION = os.environ.get("HU_STRING_SESSION", None)
OWNER_ID = int(os.environ.get("OWNER_ID", 0))
OWNER_ID = tuple(filter(lambda x: x, map(int, os.environ.get("OWNER_ID", "0").split())))
LOG_CHANNEL_ID = int(os.environ.get("LOG_CHANNEL_ID"))
DB_URI = os.environ.get("DATABASE_URL")
LANG = os.environ.get("PREFERRED_LANGUAGE")
Expand Down
2 changes: 1 addition & 1 deletion userge/core/types/raw/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ def parse(cls, command: str, # pylint: disable=arguments-differ
and not m.outgoing
and trigger
and m.from_user and m.text
and ((m.from_user.id == Config.OWNER_ID)
and ((m.from_user.id in Config.OWNER_ID)
or (Config.SUDO_ENABLED and (m.from_user.id in Config.SUDO_USERS)
and (cname.lstrip(trigger) in Config.ALLOWED_COMMANDS)))
and m.text.startswith(Config.SUDO_TRIGGER))
Expand Down
8 changes: 4 additions & 4 deletions userge/plugins/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ async def helpme(message: Message) -> None: # pylint: disable=missing-function-
if userge.has_bot:
def check_owner(func):
async def wrapper(_, c_q: CallbackQuery):
if c_q.from_user and c_q.from_user.id == Config.OWNER_ID:
if c_q.from_user and c_q.from_user.id in Config.OWNER_ID:
try:
await func(c_q)
except MessageNotModified:
Expand All @@ -93,7 +93,7 @@ async def wrapper(_, c_q: CallbackQuery):
await c_q.answer("Sorry, I Don't Have Permissions to edit this 😔",
show_alert=True)
else:
user_dict = await userge.bot.get_user_dict(Config.OWNER_ID)
user_dict = await userge.bot.get_user_dict(Config.OWNER_ID[0])
await c_q.answer(
f"Only {user_dict['flname']} Can Access this...! Build Your Own @TheUserge 🤘",
show_alert=True)
Expand Down Expand Up @@ -211,7 +211,7 @@ async def prvt_msg(_, c_q: CallbackQuery):
await c_q.answer("message now outdated !", show_alert=True)
return
user_id, flname, msg = PRVT_MSGS[msg_id]
if c_q.from_user.id == user_id or c_q.from_user.id == Config.OWNER_ID:
if c_q.from_user.id == user_id or c_q.from_user.id in Config.OWNER_ID:
await c_q.answer(msg, show_alert=True)
else:
await c_q.answer(
Expand Down Expand Up @@ -371,7 +371,7 @@ async def inline_answer(_, inline_query: InlineQuery):
)
)
]
if inline_query.from_user and inline_query.from_user.id == Config.OWNER_ID:
if inline_query.from_user and inline_query.from_user.id in Config.OWNER_ID:
results.append(
InlineQueryResultArticle(
id=uuid4(),
Expand Down
2 changes: 1 addition & 1 deletion userge/plugins/utils/notes.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def get_note(message: Message) -> None:
return
can_access = message.from_user.is_self or message.from_user.id in Config.SUDO_USERS
if Config.OWNER_ID:
can_access = can_access or message.from_user.id == Config.OWNER_ID
can_access = can_access or message.from_user.id in Config.OWNER_ID
notename = message.matches[0].group(1).lower()
mid, is_global = (0, False)
for note in NOTES_DATA[message.chat.id]:
Expand Down

0 comments on commit 837bec5

Please sign in to comment.