Skip to content

Commit

Permalink
fixes filters error
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Jul 9, 2020
1 parent 7299c38 commit 5c3a0b3
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 41 deletions.
2 changes: 1 addition & 1 deletion userge/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ class Config:
"cp -r Userge-Plugins/resources/* resources/",
"rm -rf Userge-Plugins/"]
os.system(" && ".join(_CMDS)) # nosec
_LOG.info("UnOfficial Plugins Loaded Successfully!") # nosec
_LOG.info("UnOfficial Plugins Loaded Successfully!")


def get_version() -> str:
Expand Down
76 changes: 39 additions & 37 deletions userge/core/types/new/channel_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,40 +249,42 @@ async def forward_stored(self,
Returns:
None
"""
message = await self._client.get_messages(chat_id=Config.LOG_CHANNEL_ID,
message_ids=message_id)
caption = ''
file_id = file_ref = None
if message.caption:
caption = message.caption.html.split('\n\n', maxsplit=1)[-1]
elif message.text:
caption = message.text.html.split('\n\n', maxsplit=1)[-1]
if caption:
u_dict = await self._client.get_user_dict(user_id)
chat = await self._client.get_chat(chat_id)
u_dict.update({
'chat': chat.title if chat.title else "this group", 'count': chat.members_count})
caption = caption.format_map(SafeDict(**u_dict))
file_id, file_ref = _get_file_id_and_ref(message)
caption, buttons = _parse_buttons(caption)
if message.media and file_id and file_ref:
msg = await client.send_cached_media(
chat_id=chat_id,
file_id=file_id,
file_ref=file_ref,
caption=caption,
reply_to_message_id=reply_to_message_id,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(buttons)
if hasattr(client, 'ubot') and buttons else None)
else:
msg = await client.send_message(
chat_id=chat_id,
text=caption,
reply_to_message_id=reply_to_message_id,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(buttons)
if hasattr(client, 'ubot') and buttons else None)
if del_in and msg:
await asyncio.sleep(del_in)
await msg.delete()
if message_id and isinstance(message_id, int):
message = await self._client.get_messages(chat_id=Config.LOG_CHANNEL_ID,
message_ids=message_id)
caption = ''
file_id = file_ref = None
if message.caption:
caption = message.caption.html.split('\n\n', maxsplit=1)[-1]
elif message.text:
caption = message.text.html.split('\n\n', maxsplit=1)[-1]
if caption:
u_dict = await self._client.get_user_dict(user_id)
chat = await self._client.get_chat(chat_id)
u_dict.update({
'chat': chat.title if chat.title else "this group",
'count': chat.members_count})
caption = caption.format_map(SafeDict(**u_dict))
file_id, file_ref = _get_file_id_and_ref(message)
caption, buttons = _parse_buttons(caption)
if message.media and file_id and file_ref:
msg = await client.send_cached_media(
chat_id=chat_id,
file_id=file_id,
file_ref=file_ref,
caption=caption,
reply_to_message_id=reply_to_message_id,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(buttons)
if hasattr(client, 'ubot') and buttons else None)
else:
msg = await client.send_message(
chat_id=chat_id,
text=caption,
reply_to_message_id=reply_to_message_id,
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(buttons)
if hasattr(client, 'ubot') and buttons else None)
if del_in and msg:
await asyncio.sleep(del_in)
await msg.delete()
2 changes: 1 addition & 1 deletion userge/plugins/tools/executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ async def eval_(message: Message):
stdout, stderr, exc = None, None, None

async def aexec(code):
exec("async def __aexec(userge, message):\n " # nosec
exec("async def __aexec(userge, message):\n " # nosec pylint: disable=W0122
+ '\n '.join(line for line in code.split('\n')))
return await locals()['__aexec'](userge, message)
try:
Expand Down
4 changes: 2 additions & 2 deletions userge/plugins/utils/direct_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@ def zippy_share(url: str) -> str:
script.text).group('url')
math = re.search(r'= (?P<url>\".+\" \+ (?P<math>\(.+\)) .+);',
script.text).group('math')
dl_url = url_raw.replace(math, '"' + str(eval(math)) + '"')
dl_url = url_raw.replace(math, '"' + str(eval(math)) + '"') # pylint: disable=W0123
break

dl_url = base_url + eval(dl_url)
dl_url = base_url + eval(dl_url) # pylint: disable=W0123
name = urllib.parse.unquote(dl_url.split('/')[-1])
reply += f'[{name}]({dl_url})\n'

Expand Down

0 comments on commit 5c3a0b3

Please sign in to comment.