Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions bin/cmrudl.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,9 +227,7 @@ def handle_data(self, data):
self.jsobj = m.group(1)

def result(self):
if not self.jsobj:
return None
return self.jsobj
return None if not self.jsobj else self.jsobj
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Main.parse_storage.TheHTMLParser.result refactored with the following changes:


parser = TheHTMLParser()
parser.feed(html)
Expand Down Expand Up @@ -336,8 +334,7 @@ def create_file_name_temp(self, storage):
return ".%s.%s" % (__prog__, urllib_quote(storage["hash"]))

def create_file_name(self, storage):
opt_file = self.options.file
if opt_file:
if opt_file := self.options.file:
Comment on lines -339 to +337
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function Main.create_file_name refactored with the following changes:

return opt_file
return storage["name"] if storage else None

Expand Down
2 changes: 1 addition & 1 deletion sample_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class Config(object):
"THUMB_IMAGE", "https://telegra.ph/file/6086da8c041f5de3227ed.jpg"
)
# Specify NO_LOAD with plugin names for not loading in userbot
NO_LOAD = [x for x in os.environ.get("NO_LOAD", "").split()]
NO_LOAD = list(os.environ.get("NO_LOAD", "").split())
# Specify command handler that should be used for the plugins
# This should be a valid "regex" pattern
CMDSET = os.environ.get("CMDSET", r".")
Expand Down
4 changes: 2 additions & 2 deletions userbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
__version__ = "1.0"
__license__ = "GNU Affero General Public License v3.0"
__author__ = "DogeUserBot < https://github.com/DOG-E/DogeUserBot >"
__copyright__ = "©️ Copyright 2021, " + __author__
__copyright__ = f"©️ Copyright 2021, {__author__}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 21-62 refactored with the following changes:


doge.version = __version__
if gvar("BOT_TOKEN"):
Expand Down Expand Up @@ -59,7 +59,7 @@
else:
Config.PM_LOGGER_GROUP_ID = int(gvar("PM_LOGGER_GROUP_ID"))
elif str(Config.PM_LOGGER_GROUP_ID)[0] != "-":
Config.PM_LOGGER_GROUP_ID = int("-" + str(Config.PM_LOGGER_GROUP_ID))
Config.PM_LOGGER_GROUP_ID = int(f"-{str(Config.PM_LOGGER_GROUP_ID)}")


try:
Expand Down
6 changes: 3 additions & 3 deletions userbot/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@


try:
LOGS.info(f"⏳ STARTING DOGE USERBOT 🐾")
LOGS.info("⏳ STARTING DOGE USERBOT 🐾")
doge.loop.run_until_complete(setup_bot())
LOGS.info(f"✅ STARTUP COMPLETED 🐾")
LOGS.info("✅ STARTUP COMPLETED 🐾")
Comment on lines -33 to +35
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lines 33-35 refactored with the following changes:

except Exception as e:
LOGS.error(f"🚨 {e}")
exit()
Expand Down Expand Up @@ -71,7 +71,7 @@ async def startup_process():
await load_plugins("plugins")
await load_plugins("assistant")
LOGS.info(userbot.__copyright__)
LOGS.info("🔐 Licensed under the terms of the " + userbot.__license__)
LOGS.info(f"🔐 Licensed under the terms of the {userbot.__license__}")
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function startup_process refactored with the following changes:

LOGS.info(
f"\
\n➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖➖\
Expand Down
49 changes: 23 additions & 26 deletions userbot/assistant/bot_pms.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ async def bot_start(event):
mention = f"[{chat.first_name}](tg://user?id={chat.id})"
my_mention = f"[{user.first_name}](tg://user?id={user.id})"
first = chat.first_name
last = chat.last_name if chat.last_name else ""
last = chat.last_name or ""
fullname = f"{first} {last}" if last else first
username = f"@{chat.username}" if chat.username else mention
userid = chat.id
my_first = user.first_name
my_last = user.last_name if user.last_name else ""
my_last = user.last_name or ""
Comment on lines -98 to +103
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function bot_start refactored with the following changes:

my_fullname = f"{my_first} {my_last}" if my_last else my_first
my_username = f"@{user.username}" if user.username else my_mention
if chat.id != OWNER_ID:
Expand Down Expand Up @@ -129,21 +129,20 @@ async def bot_start(event):
)
)
buttons = [
(Button.url(f"📣 Kᴀɴᴀʟ ", "https://t.me/DogeUserBot"),),
(Button.url("📣 Kᴀɴᴀʟ ", "https://t.me/DogeUserBot"),),
(
Button.url(f"💬 Sᴜᴘᴘᴏʀᴛ ", "https://t.me/DogeSup"),
Button.url(f"🧩 Pʟᴜɢɪɴ ", "https://t.me/DogePlugin"),
Button.url("💬 Sᴜᴘᴘᴏʀᴛ ", "https://t.me/DogeSup"),
Button.url("🧩 Pʟᴜɢɪɴ ", "https://t.me/DogePlugin"),
),
]

else:
start_msg = "**🐶 Wow!\
\n🐾 Merhaba {}!\n\
\n💬 Sana nasıl yardımcı olabilirim?**".format(
my_mention
)
buttons = [
(Button.inline(f"🐕‍🦺 ʏᴀʀᴅɪᴍ", data="mainmenu"),),
]
buttons = [(Button.inline("🐕\u200d🦺 ʏᴀʀᴅɪᴍ", data="mainmenu"),)]
try:
await event.client.send_message(
chat.id,
Expand Down Expand Up @@ -239,12 +238,10 @@ async def bot_pms_edit(event): # sourcery no-metrics
users = get_user_reply(event.id)
if users is None:
return
reply_msg = None
for user in users:
if user.chat_id == str(chat.id):
reply_msg = user.message_id
break
if reply_msg:
if reply_msg := next(
(user.message_id for user in users if user.chat_id == str(chat.id)),
None,
):
await event.client.send_message(
OWNER_ID,
"**⬆️ Bu mesaj şu kullanıcı tarafından düzenlendi.** {} :\n".format(
Expand Down Expand Up @@ -303,11 +300,11 @@ async def handler(event):
except Exception as e:
LOGS.error(str(e))
if users_1 is not None:
reply_msg = None
for user in users_1:
if user.chat_id != OWNER_ID:
reply_msg = user.message_id
break
reply_msg = next(
(user.message_id for user in users_1 if user.chat_id != OWNER_ID),
None,
)

try:
if reply_msg:
users = get_user_id(reply_msg)
Expand Down Expand Up @@ -343,16 +340,18 @@ async def bot_start(event):
users = get_user_id(reply_to)
if users is None:
return await info_msg.edit(
f"**🚨 Hᴀᴛᴀ:**\n🙁 'Üzgünüm! Bu kullanıcıyı veritabanımda bulamadım.`"
"**🚨 Hᴀᴛᴀ:**\\n🙁 'Üzgünüm! Bu kullanıcıyı veritabanımda bulamadım.`"
)

for usr in users:
user_id = int(usr.chat_id)
user_name = usr.first_name
break
if user_id is None:
return await info_msg.edit(
f"**🚨 Hᴀᴛᴀ:**\n🙁 'Üzgünüm! Bu kullanıcıyı veritabanımda bulamadım.`"
"**🚨 Hᴀᴛᴀ:**\\n🙁 'Üzgünüm! Bu kullanıcıyı veritabanımda bulamadım.`"
)

Comment on lines -346 to +354
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function bot_start refactored with the following changes:

uinfo = f"**👤 Bu mesaj şu kişi tarafından gönderildi:** {_format.mentionuser(user_name, user_id)}\
\n**ℹ️ Kullanıcı İsmi:** {user_name}\
\n**🆔 Kullanıcı ID'si:** `{user_id}`"
Expand All @@ -363,13 +362,11 @@ async def send_flood_alert(user_) -> None:
# sourcery no-metrics
buttons = [
(
Button.inline(f"🚫 Bᴀɴ", data=f"bot_pm_ban_{user_.id}"),
Button.inline(
f"➖ Boᴛ AɴᴛɪFʟooᴅ'ᴜ Kᴀᴘᴀᴛ",
data="toggle_bot-antiflood_off",
),
Button.inline("🚫 Bᴀɴ", data=f"bot_pm_ban_{user_.id}"),
Button.inline("➖ Boᴛ AɴᴛɪFʟooᴅ'ᴜ Kᴀᴘᴀᴛ", data="toggle_bot-antiflood_off"),
)
]

found = False
if FloodConfig.ALERT and (user_.id in FloodConfig.ALERT.keys()):
found = True
Expand Down
19 changes: 10 additions & 9 deletions userbot/assistant/botcontrols.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,22 +111,24 @@ async def bot_broadcast(event):
if count % 5 == 0:
try:
prog_ = (
f"**🔊 Yayın Yapılıyor...**\n\n"
+ progress_str(
total=bot_users_count,
current=count + len(blocked_users),
(
"**🔊 Yayın Yapılıyor...**\\n\\n"
+ progress_str(
total=bot_users_count,
current=count + len(blocked_users),
)
)
+ f"\n\n• **✅ Başarılı:** `{count}`\n"
+ f"• **❌ Hatalı** `{len(blocked_users)}`"
)
) + f"• **❌ Hatalı** `{len(blocked_users)}`"

Comment on lines -114 to +123
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function bot_broadcast refactored with the following changes:

await br_cast.edit(prog_)
except FloodWaitError as e:
await sleep(e.seconds)
end_ = datetime.now()
b_info = "🔊 ➡️ <b> {} tane kullanıcı </b> için mesajı başarıyla yayınladı.".format(
count
)
if len(blocked_users) != 0:
if blocked_users:
b_info += f"\n🚫 <b>{len(blocked_users)} tane kullanıcı</b> {BOT_USERNAME} botunu engellemiş ya da botla olan mesajları silmiş. Bu yüzden bot kullanıcıları listesinden silindi."
b_info += "⏱ Tamamlanma Süresi:<code> {}</code>.".format(
time_formatter((end_ - start_).seconds)
Expand Down Expand Up @@ -187,8 +189,7 @@ async def ban_botpms(event):
if user_id == OWNER_ID:
return await event.reply("**🚨 Seni yasaklayamam.**")

check = check_is_black_list(user.id)
if check:
if check := check_is_black_list(user.id):
Comment on lines -190 to +192
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ban_botpms refactored with the following changes:

return await event.client.send_message(
event.chat_id,
f"🛑 #ZATEN_BANLI\
Expand Down
8 changes: 4 additions & 4 deletions userbot/assistant/botmanagers.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ def progress_str(total: int, current: int) -> str:
return prog_arg.format(
"Progress",
percentage,
"".join((Config.FINISHED_PROGRESS_STR for i in range(floor(percentage / 5)))),
"".join(Config.FINISHED_PROGRESS_STR for _ in range(floor(percentage / 5))),
"".join(
(Config.UNFINISHED_PROGRESS_STR for i in range(20 - floor(percentage / 5)))
Config.UNFINISHED_PROGRESS_STR for _ in range(20 - floor(percentage / 5))
),
)

Expand Down Expand Up @@ -81,8 +81,8 @@ async def unban_user_from_bot(user, reason, reply_to=None):
rem_user_from_bl(user.id)
except Exception as e:
LOGS.error(str(e))
banned_msg = f"**👀 Bu bottan yasaklanmıştınız.\
/nℹ️ Şimdi sahibime mesaj göndermeye devam edebeilirsin!**"
banned_msg = "**👀 Bu bottan yasaklanmıştınız.\\\x1f /nℹ️ Şimdi sahibime mesaj göndermeye devam edebeilirsin!**"

Comment on lines -84 to +85
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function unban_user_from_bot refactored with the following changes:

if reason is not None:
banned_msg += f"\n**⛓ Sebep:** `{reason}`"
await doge.tgbot.send_message(user.id, banned_msg)
Expand Down
2 changes: 1 addition & 1 deletion userbot/assistant/buttonmaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ async def button(event):
if not markdown_note:
return await edl(event, "`🔲 Butonda hangi metni kullanmalıyım?`")

doginput = "Inline buttons " + markdown_note
doginput = f"Inline buttons {markdown_note}"
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function button refactored with the following changes:

results = await event.client.inline_query(BOT_USERNAME, doginput)
await results[0].click(event.chat_id, reply_to=reply_to_id, hide_via=True)
await event.delete()
4 changes: 2 additions & 2 deletions userbot/assistant/hide.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ async def on_plug_in_callback_query_handler(event):
try:
reply_pop_up_alert = jsondata[f"{timestamp}"]["text"]
except KeyError:
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok."
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok."
else:
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok."
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok."
Comment on lines -26 to +28
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function on_plug_in_callback_query_handler refactored with the following changes:

await event.answer(reply_pop_up_alert, cache_time=0, alert=True)
23 changes: 7 additions & 16 deletions userbot/assistant/iyoutube.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ async def yt_inline(event):
input_url = (reply.text).strip()
if not input_url:
return await edl(
event, f"**📺 Geçerli bir YouTube URL'sine girin veya cevap verin!**"
event, "**📺 Geçerli bir YouTube URL'sine girin veya cevap verin!**"
)

Comment on lines -78 to 80
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function yt_inline refactored with the following changes:

dogevent = await eor(
Expand All @@ -97,7 +97,7 @@ async def yt_inline(event):
await dogevent.delete()
await results[0].click(event.chat_id, reply_to=reply_to_id, hide_via=True)
else:
await dogevent.edit(f"**🚨 Üzgünüm! Hiçbir sonuç bulamadım.**")
await dogevent.edit("**🚨 Üzgünüm! Hiçbir sonuç bulamadım.**")


@doge.tgbot.on(
Expand Down Expand Up @@ -270,7 +270,7 @@ async def ytdl_callback(c_q: CallbackQuery):
parse_mode="html",
)
elif choosen_btn == "listall":
await c_q.answer(f"➡️ Görünüm olarak şu değiştirildi: 📜 Liste", alert=False)
await c_q.answer("➡️ Görünüm olarak şu değiştirildi: 📜 Liste", alert=False)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function ytdl_callback refactored with the following changes:

list_res = "".join(
search_data.get(vid_s).get("list_view") for vid_s in search_data
)
Expand All @@ -284,23 +284,14 @@ async def ytdl_callback(c_q: CallbackQuery):
await c_q.edit(
file=await get_ytthumb(search_data.get("1").get("video_id")),
buttons=[
(
Button.url(
f"↗️ Açᴍᴀᴋ Içɪɴ Tıᴋʟᴀʏıɴ",
url=telegraph,
)
),
(
Button.inline(
f"📊 Dᴇᴛᴀʏʟᴀʀı Göʀ",
data=f"ytdl_detail_{data_key}_{page}",
)
),
Button.url("↗️ Açᴍᴀᴋ Içɪɴ Tıᴋʟᴀʏıɴ", url=telegraph),
Button.inline("📊 Dᴇᴛᴀʏʟᴀʀı Göʀ", data=f"ytdl_detail_{data_key}_{page}"),
],
)

else: # Detailed
index = 1
await c_q.answer(f"➡️ Görünüm şu olarak değiştirildi: 📊 Detaylı", alert=False)
await c_q.answer("➡️ Görünüm şu olarak değiştirildi: 📊 Detaylı", alert=False)
first = search_data.get(str(index))
await c_q.edit(
text=first.get("message"),
Expand Down
4 changes: 2 additions & 2 deletions userbot/assistant/secret.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def on_plug_in_callback_query_handler(event):
\n👀 Bu senin için değil!\
\n🤡 Git ve kendi işini yap."
except KeyError:
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok."
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok."
else:
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok."
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok."
Comment on lines -36 to +38
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function on_plug_in_callback_query_handler refactored with the following changes:

await event.answer(reply_pop_up_alert, cache_time=0, alert=True)
17 changes: 8 additions & 9 deletions userbot/assistant/sendbot.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,18 @@ async def botmsg(event):
reply_message = await event.get_reply_message()
reply_to_id = await reply_id(event)
if not text:
if reply_message.media:
media = await reply_message.download_media()
if reply_message.text:
await doge.tgbot.send_file(chat, media, caption=reply_message.text)
else:
await doge.tgbot.send_file(chat, media)
return await event.delete()

else:
if not reply_message.media:
return await edl(
event,
"__Bot üzerinden ne göndermeliyim? Bana bir metin verin ya da mesajı yanıtlayın.__",
)

media = await reply_message.download_media()
if reply_message.text:
await doge.tgbot.send_file(chat, media, caption=reply_message.text)
else:
await doge.tgbot.send_file(chat, media)
return await event.delete()

Comment on lines -30 to +42
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function botmsg refactored with the following changes:

await doge.tgbot.send_message(chat, text, reply_to=reply_to_id)
await event.delete()
4 changes: 2 additions & 2 deletions userbot/assistant/troll.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async def on_plug_in_callback_query_handler(event):
encrypted_tcxt = message["text"]
reply_pop_up_alert = encrypted_tcxt
except KeyError:
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok."
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok."
else:
reply_pop_up_alert = f"🚨 Bu mesaj artık Doge sunucusunda yok."
reply_pop_up_alert = "🚨 Bu mesaj artık Doge sunucusunda yok."
Comment on lines -36 to +38
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function on_plug_in_callback_query_handler refactored with the following changes:

await event.answer(reply_pop_up_alert, cache_time=0, alert=True)
10 changes: 4 additions & 6 deletions userbot/core/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,10 @@ async def wrapper(check):
markdown=False,
title="🐶 Doɢᴇ UsᴇʀBoᴛ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾",
)
text = "**🐶 Doɢᴇ UsᴇʀBoᴛ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**"
text += "\n\n"
text = "**🐶 Doɢᴇ UsᴇʀBoᴛ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" + "\n\n"
text += f"**🚨 Hata Raporu:** [{new['error']}]({pastelink})"
text += "\n\n"
link = f"[BURAYA](https://t.me/DogeSup)"
link = "[BURAYA](https://t.me/DogeSup)"
Comment on lines -212 to +215
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DogeUserBotClient.bot_cmd.decorator.wrapper refactored with the following changes:

text += "__💬 Eğer isterseniz buraya bildirebilirisiniz.__"
text += "\n\n"
text += "🐾 Bu mesajı {} ilet.".format(link)
Expand Down Expand Up @@ -349,11 +348,10 @@ async def wrapper(check):
markdown=False,
title="🐶 Doɢᴇ Asɪsᴛᴀɴ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾",
)
text = "**🐶 Doɢᴇ Asɪsᴛᴀɴ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**"
text += "\n\n"
text = "**🐶 Doɢᴇ Asɪsᴛᴀɴ Hᴀᴛᴀ Rᴀᴘᴏʀᴜ 🐾**" + "\n\n"
text += f"**🚨 Hata Raporu:** [{new['error']}]({pastelink})"
text += "\n\n"
link = f"[BURAYA](https://t.me/DogeSup)"
link = "[BURAYA](https://t.me/DogeSup)"
Comment on lines -352 to +354
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function DogeUserBotClient.shiba_cmd.decorator.wrapper refactored with the following changes:

text += "__💬 Eğer isterseniz buraya bildirebilirisiniz.__"
text += "\n\n"
text += "🐾 Bu mesajı {} ilet.".format(link)
Expand Down
Loading