Skip to content

Commit

Permalink
minor fixes + security patch
Browse files Browse the repository at this point in the history
  • Loading branch information
rking32 committed Jan 16, 2021
1 parent 487dbc3 commit 7f43a13
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 44 deletions.
3 changes: 0 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -134,17 +134,14 @@ dmypy.json
.heroku/
.profile.d/
vendor/
config.ini
config.env
.vscode/
.idea/
*.session
log.txt
unknown_errors.txt
logs/
bin/
resources/base_profile_pic.jpg
resources/mdfy_profile_pic.jpg
pictest.py
resources/MutantAcademyBB.ttf
userge/plugins/dev/
1 change: 0 additions & 1 deletion Aptfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
tree
wget2
pv
p7zip-full
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
# Userge 🔥

[![Build Status](https://travis-ci.com/UsergeTeam/Userge.svg?branch=alpha)](https://travis-ci.com/UsergeTeam/Userge)
![Python Version](https://img.shields.io/badge/python-3.8-lightgrey)
![Python Version](https://img.shields.io/badge/python-3.8/3.9-lightgrey)
![Release](https://img.shields.io/github/v/release/UsergeTeam/Userge)
![Stars](https://img.shields.io/github/stars/UsergeTeam/Userge)
![Forks](https://img.shields.io/github/forks/UsergeTeam/Userge)
Expand Down
2 changes: 1 addition & 1 deletion app.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"DATABASE_URL": {"description": "Mongodb url from https://cloud.mongodb.com/"},
"LOG_CHANNEL_ID": {"description": "Telegram Log Channel ID"},
"HU_STRING_SESSION": {
"description": "[USER MODE] - Get this using '@genStr_Bot' or `bash genStr`",
"description": "[USER MODE] - Get this using `bash genStr`",
"required": false},
"BOT_TOKEN": {
"description": "[BOT MODE] - Get this from https://t.me/botfather",
Expand Down
10 changes: 9 additions & 1 deletion init/logbot/core/api.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
# All rights reserved.

declare -r _api_url="https://api.telegram.org/bot"
declare -i _mid=0
declare -i _mid=0 _isChecked=0
declare -a _allMessages=()

_getResponse() {
Expand All @@ -22,6 +22,14 @@ _getResponse() {
local ok=$(echo $rawUpdate | jq .ok)
test -z $ok && return 1
if test $ok = true; then
if test $_isChecked -eq 0; then
local chatType=$(echo $rawUpdate | jq .result.chat.type)
[[ $chatType == \"supergroup\" || $chatType == \"channel\" ]] || \
quit "invalid log chat type ! [$chatType]"
local chatUsername=$(echo $rawUpdate | jq .result.chat.username)
test $chatUsername != null && quit "log chat should be private !"
_isChecked=1
fi
if test $parse = true; then
local msg="msg$_mid"
Message $msg
Expand Down
13 changes: 6 additions & 7 deletions init/utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@ declare -r minPVer=8
declare -r maxPVer=9

getPythonVersion() {
local -i count
local tmp found
[[ $DYNO ]] && count=$maxPVer || count=$minPVer
local -i count=$minPVer
local found
while true; do
tmp=$(python3.$count -V 2> /dev/null)
found=$(grep "^Python 3." <<< "$tmp")
[[ -n $found ]] && break
found=$(python3.$count -c "print('hi')" 2> /dev/null)
test "$found" && break
count+=1
[[ $count -gt $maxPVer ]] && break
done
declare -gr pVer=$(sed -E 's/Python (3\.[0-9]{1,2}\.[0-9]{1,2}).*/\1/g' <<< "$tmp")
declare -gr pVer=$(sed -E 's/Python (3\.[0-9]{1,2}\.[0-9]{1,2}).*/\1/g' <<< \
"$(python3.$count -V 2> /dev/null)")
}
log() {
Expand Down
39 changes: 21 additions & 18 deletions userge/core/types/new/channel_logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import asyncio
from typing import Optional, Union

from pyrogram.errors import ChatWriteForbidden
from pyrogram.types import Message as RawMessage
from pyrogram.errors.exceptions import MessageTooLong

Expand Down Expand Up @@ -183,7 +184,6 @@ async def forward_stored(self,
message = await client.get_messages(chat_id=self._id,
message_ids=message_id)
caption = ''
file_id = None
if message.caption:
caption = message.caption.html.split('\n\n', maxsplit=1)[-1]
elif message.text:
Expand All @@ -197,20 +197,23 @@ async def forward_stored(self,
caption = caption.format_map(SafeDict(**u_dict))
file_id = get_file_id_of_media(message)
caption, buttons = parse_buttons(caption)
if message.media and file_id:
msg = await client.send_cached_media(
chat_id=chat_id,
file_id=file_id,
caption=caption,
reply_to_message_id=reply_to_message_id,
reply_markup=buttons if client.is_bot 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=buttons if client.is_bot and buttons else None)
if del_in and msg:
await asyncio.sleep(del_in)
await msg.delete()
try:
if message.media and file_id:
msg = await client.send_cached_media(
chat_id=chat_id,
file_id=file_id,
caption=caption,
reply_to_message_id=reply_to_message_id,
reply_markup=buttons if client.is_bot 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=buttons if client.is_bot and buttons else None)
if del_in and msg:
await asyncio.sleep(del_in)
await msg.delete()
except ChatWriteForbidden:
pass
3 changes: 0 additions & 3 deletions userge/plugins/admin/gadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
allow_channels=False, check_promote_perm=True)
async def promote_usr(message: Message):
""" promote members in tg group """
custom_rank = ""
chat_id = message.chat.id
await message.edit("`Trying to Promote User.. Hang on!! ⏳`")
user_id, custom_rank = message.extract_user_and_text
Expand Down Expand Up @@ -129,7 +128,6 @@ async def demote_usr(message: Message):
async def ban_user(message: Message):
""" ban user from tg group """
await message.edit("`Trying to Ban User.. Hang on!! ⏳`")
reason = ""
user_id, reason = message.extract_user_and_text
if not user_id:
await message.edit(
Expand Down Expand Up @@ -262,7 +260,6 @@ async def kick_usr(message: Message):
allow_channels=False, check_restrict_perm=True)
async def mute_usr(message: Message):
""" mute user from tg group """
reason = ""
chat_id = message.chat.id
flags = message.flags
minutes = flags.get('-m', 0)
Expand Down
4 changes: 2 additions & 2 deletions userge/plugins/misc/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ async def url_download(message: Message, url: str) -> Tuple[str, int]:
progress_str = progress_str.format(
"trying to download",
''.join((Config.FINISHED_PROGRESS_STR
for i in range(math.floor(percentage / 5)))),
for _ in range(math.floor(percentage / 5)))),
''.join((Config.UNFINISHED_PROGRESS_STR
for i in range(20 - math.floor(percentage / 5)))),
for _ in range(20 - math.floor(percentage / 5)))),
round(percentage, 2),
url,
custom_file_name,
Expand Down
12 changes: 6 additions & 6 deletions userge/plugins/misc/gdrive.py
Original file line number Diff line number Diff line change
Expand Up @@ -253,9 +253,9 @@ def _upload_file(self, file_path: str, parent_id: str) -> str:
"**ETA** : `{}`"
self._progress = tmp.format(
"".join((Config.FINISHED_PROGRESS_STR
for i in range(math.floor(percentage / 5)))),
for _ in range(math.floor(percentage / 5)))),
"".join((Config.UNFINISHED_PROGRESS_STR
for i in range(20 - math.floor(percentage / 5)))),
for _ in range(20 - math.floor(percentage / 5)))),
round(percentage, 2),
file_name,
humanbytes(f_size),
Expand Down Expand Up @@ -350,9 +350,9 @@ def _download_file(self, path: str, name: str, **kwargs) -> None:
"**ETA** : `{}`"
self._progress = tmp.format(
"".join((Config.FINISHED_PROGRESS_STR
for i in range(math.floor(percentage / 5)))),
for _ in range(math.floor(percentage / 5)))),
"".join((Config.UNFINISHED_PROGRESS_STR
for i in range(20 - math.floor(percentage / 5)))),
for _ in range(20 - math.floor(percentage / 5)))),
round(percentage, 2),
name,
humanbytes(f_size),
Expand Down Expand Up @@ -441,9 +441,9 @@ def _copy_file(self, file_id: str, parent_id: str) -> str:
"**Completed** : `{}/{}`"
self._progress = tmp.format(
"".join((Config.FINISHED_PROGRESS_STR
for i in range(math.floor(percentage / 5)))),
for _ in range(math.floor(percentage / 5)))),
"".join((Config.UNFINISHED_PROGRESS_STR
for i in range(20 - math.floor(percentage / 5)))),
for _ in range(20 - math.floor(percentage / 5)))),
round(percentage, 2),
self._completed,
self._list)
Expand Down
2 changes: 1 addition & 1 deletion userge/plugins/utils/pmpermit.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ async def uninvitedPmHandler(message: Message):
message.chat.id, query_id=k.query_id,
result_id=k.results[2].id, hide_via=True
)
except BotInlineDisabled:
except (IndexError, BotInlineDisabled):
await message.reply(
noPmMessage.format_map(SafeDict(**user_dict)) + '\n`- Protected by userge`')
else:
Expand Down

0 comments on commit 7f43a13

Please sign in to comment.