Skip to content

Commit 3bcd080

Browse files
committed
Automated code formatting
Signed-off-by: apisuserbot <apisuserbot@users.noreply.github.com>
1 parent ce9ba0f commit 3bcd080

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+559
-783
lines changed

userbot/__init__.py

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
)
5757
else:
5858
basicConfig(
59-
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
60-
level=INFO)
59+
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=INFO
60+
)
6161
LOGS = getLogger(__name__)
6262

6363
if version_info[0] < 3 or version_info[1] < 9:
@@ -150,8 +150,7 @@
150150

151151
# Chrome Driver and Headless Google Chrome Binaries
152152
CHROME_DRIVER = os.environ.get("CHROME_DRIVER") or "/usr/bin/chromedriver"
153-
GOOGLE_CHROME_BIN = os.environ.get(
154-
"GOOGLE_CHROME_BIN") or "/usr/bin/google-chrome"
153+
GOOGLE_CHROME_BIN = os.environ.get("GOOGLE_CHROME_BIN") or "/usr/bin/google-chrome"
155154

156155
# set to True if you want to log PMs to your PM_LOGGR_BOT_API_ID
157156
NC_LOG_P_M_S = bool(os.environ.get("NC_LOG_P_M_S", False))
@@ -216,12 +215,14 @@
216215
S_PACK_NAME = os.environ.get("S_PACK_NAME", None)
217216

218217
# Default .alive logo
219-
ALIVE_LOGO = (os.environ.get("ALIVE_LOGO")
220-
or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg")
218+
ALIVE_LOGO = (
219+
os.environ.get("ALIVE_LOGO") or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg"
220+
)
221221

222222
# Default .helpme logo
223-
INLINE_PIC = (os.environ.get("INLINE_PIC")
224-
or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg")
223+
INLINE_PIC = (
224+
os.environ.get("INLINE_PIC") or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg"
225+
)
225226

226227
# Default Emoji Help Inline
227228
EMOJI_HELP = os.environ.get("EMOJI_HELP") or "|"
@@ -254,8 +255,7 @@
254255
G_DRIVE_CLIENT_SECRET = os.environ.get("G_DRIVE_CLIENT_SECRET", None)
255256
G_DRIVE_AUTH_TOKEN_DATA = os.environ.get("G_DRIVE_AUTH_TOKEN_DATA", None)
256257
G_DRIVE_FOLDER_ID = os.environ.get("G_DRIVE_FOLDER_ID", None)
257-
TEMP_DOWNLOAD_DIRECTORY = os.environ.get(
258-
"TMP_DOWNLOAD_DIRECTORY", "./downloads")
258+
TEMP_DOWNLOAD_DIRECTORY = os.environ.get("TMP_DOWNLOAD_DIRECTORY", "./downloads")
259259
# Google Photos
260260
G_PHOTOS_CLIENT_ID = os.environ.get("G_PHOTOS_CLIENT_ID", None)
261261
G_PHOTOS_CLIENT_SECRET = os.environ.get("G_PHOTOS_CLIENT_SECRET", None)
@@ -345,7 +345,8 @@ async def check_botlog_chatid():
345345
if entity.default_banned_rights.send_messages:
346346
LOGS.info(
347347
"Akun Anda Tidak Memiliki Hak Untuk Mengirim Pesan Ke BOTLOG_CHATID "
348-
"Grup Pribadi Periksa Apakah Anda Mengetik ID Obrolan Benar")
348+
"Grup Pribadi Periksa Apakah Anda Mengetik ID Obrolan Benar"
349+
)
349350
quit(1)
350351

351352

@@ -424,7 +425,7 @@ def paginate_help(page_number, loaded_modules, prefix):
424425
modulo_page = page_number % max_num_pages
425426
if len(pairs) > number_of_rows:
426427
pairs = pairs[
427-
modulo_page * number_of_rows: number_of_rows * (modulo_page + 1)
428+
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
428429
] + [
429430
(
430431
custom.Button.inline(
@@ -498,7 +499,8 @@ async def handler(event):
498499
f"**Database :** Mongo db \n"
499500
f"**Bahasa :** Python \n"
500501
f"**Daftar Perintah Bot :** [KLIK DISINI](https://telegra.ph/Perintah-Penggunaan-08-05) \n"
501-
"========================================")
502+
"========================================"
503+
)
502504
await king.tgbot.send_file(
503505
event.chat_id,
504506
file=logo,
@@ -576,7 +578,8 @@ async def handler(event):
576578
f"`Database :` Mongo db \n\n"
577579
"=============================\n"
578580
f" **USERBOT TELEGRAM** \n"
579-
"=============================")
581+
"============================="
582+
)
580583
await king.tgbot.send_file(
581584
event.chat_id,
582585
file=alive,
@@ -604,7 +607,8 @@ async def handler(event):
604607
f"👋🏻 Hai [{get_display_name(u)}](tg://user?id={u.id}) Jika anda\n"
605608
f"Ingin donasi atau menyumbang uang ini ke developer kami\n\n"
606609
f"• **Notes : Donasi Seikhlasnya** \n\n"
607-
f"**Terimakasih** ")
610+
f"**Terimakasih** "
611+
)
608612
await king.tgbot.send_file(
609613
event.chat_id,
610614
file=donate,
@@ -652,8 +656,7 @@ async def inline_handler(event):
652656
builder = event.builder
653657
result = None
654658
query = event.text
655-
if event.query.user_id == uid and query.startswith(
656-
"@KingUserbotSupport"):
659+
if event.query.user_id == uid and query.startswith("@KingUserbotSupport"):
657660
buttons = paginate_help(0, dugmeler, "helpme")
658661
result = builder.photo(
659662
file=logo,
@@ -817,10 +820,8 @@ async def on_plug_in_callback_query_handler(event):
817820
)
818821
async def on_plug_in_callback_query_handler(event):
819822
if event.query.user_id == uid: # pylint:disable=E0602
820-
current_page_number = int(
821-
event.data_match.group(1).decode("UTF-8"))
822-
buttons = paginate_help(
823-
current_page_number + 1, dugmeler, "helpme")
823+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
824+
buttons = paginate_help(current_page_number + 1, dugmeler, "helpme")
824825
# https://t.me/TelethonChat/115200
825826
await event.edit(buttons=buttons)
826827
else:
@@ -863,8 +864,7 @@ async def on_plug_in_callback_query_handler(event):
863864
)
864865
async def on_plug_in_callback_query_handler(event):
865866
if event.query.user_id == uid: # pylint:disable=E0602
866-
current_page_number = int(
867-
event.data_match.group(1).decode("UTF-8"))
867+
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
868868
buttons = paginate_help(
869869
current_page_number - 1, dugmeler, "helpme" # pylint:disable=E0602
870870
)
@@ -973,7 +973,8 @@ async def on_plug_in_callback_query_handler(event):
973973
f"✘ **Set Vars :**\n"
974974
f"`.set var ALIVE_LOGO` <link>\n"
975975
f"`.set var KING_TEKS_KUSTOM` <teks>\n"
976-
f"`.set var ALIVE_LOGO None` <tidak memakai pic/foto>")
976+
f"`.set var ALIVE_LOGO None` <tidak memakai pic/foto>"
977+
)
977978
await event.edit(
978979
text,
979980
file=logo,
@@ -1005,7 +1006,8 @@ async def on_plug_in_callback_query_handler(event):
10051006
f"✘ **Set Vars :**\n"
10061007
f"`.set var PMPERMIT_PIC` <link>\n"
10071008
f"`.set var PMPERMIT_TEXT` <teks>\n"
1008-
f"`.set var PMPERMIT_PIC None` <tidak memakai pic/foto>")
1009+
f"`.set var PMPERMIT_PIC None` <tidak memakai pic/foto>"
1010+
)
10091011
await event.edit(
10101012
text,
10111013
file=logo,

userbot/events.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ async def wrapper(check):
139139
command, stdout=asyncsub.PIPE, stderr=asyncsub.PIPE
140140
)
141141
stdout, stderr = await process.communicate()
142-
result = str(stdout.decode().strip()) + \
143-
str(stderr.decode().strip())
142+
result = str(stdout.decode().strip()) + str(stderr.decode().strip())
144143

145144
ftext += result
146145

userbot/modules/__inlinehelp.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424

2525

2626
logging.basicConfig(
27-
format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s",
28-
level=logging.WARNING)
27+
format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s", level=logging.WARNING
28+
)
2929

3030

3131
@register(outgoing=True, pattern=r"^\.helpme")

userbot/modules/admin.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,8 @@ async def rm_deletedacc(show):
576576
if del_u > 0:
577577
del_status = (
578578
f"`Menemukan` **{del_u}** `Akun Hantu/Terhapus/Zombie Dalam Grup Ini,"
579-
"\nBersihkan Itu Menggunakan Perintah .zombies clean`")
579+
"\nBersihkan Itu Menggunakan Perintah .zombies clean`"
580+
)
580581
return await show.edit(del_status)
581582

582583
# Here laying the sanity check
@@ -799,9 +800,7 @@ async def get_user_from_event(event):
799800
if event.message.entities is not None:
800801
probable_user_mention_entity = event.message.entities[0]
801802

802-
if isinstance(
803-
probable_user_mention_entity,
804-
MessageEntityMentionName):
803+
if isinstance(probable_user_mention_entity, MessageEntityMentionName):
805804
user_id = probable_user_mention_entity.user_id
806805
user_obj = await event.client.get_entity(user_id)
807806
return user_obj
@@ -891,9 +890,7 @@ async def get_userdel_from_event(event):
891890
if event.message.entities is not None:
892891
probable_user_mention_entity = event.message.entities[0]
893892

894-
if isinstance(
895-
probable_user_mention_entity,
896-
MessageEntityMentionName):
893+
if isinstance(probable_user_mention_entity, MessageEntityMentionName):
897894
user_id = probable_user_mention_entity.user_id
898895
user_obj = await event.client.get_entity(user_id)
899896
return user_obj

userbot/modules/afk.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ async def set_not_afk(event):
8989
os.system("rm -rf *.jpg")
9090

9191

92-
@bot.on(events.NewMessage(incoming=True,
93-
func=lambda e: bool(e.mentioned or e.is_private)))
92+
@bot.on(
93+
events.NewMessage(incoming=True, func=lambda e: bool(e.mentioned or e.is_private))
94+
)
9495
async def on_afk(event):
9596
if event.fwd_from:
9697
return
@@ -110,8 +111,9 @@ async def on_afk(event):
110111
msg = None
111112
if reason:
112113
message_to_reply = (
113-
f"**{ALIVE_NAME} Sedang AFK**\n\n**Sejak :** `{total_afk_time}` **Yang Lalu**\n" +
114-
f"**Karena :** `{reason}`")
114+
f"**{ALIVE_NAME} Sedang AFK**\n\n**Sejak :** `{total_afk_time}` **Yang Lalu**\n"
115+
+ f"**Karena :** `{reason}`"
116+
)
115117
else:
116118
message_to_reply = f"**Maaf King {ALIVE_NAME} Sedang AFK**\n\n**Sejak :** `{total_afk_time}` **Yang Lalu**"
117119
try:

userbot/modules/android.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ async def magisk(request):
3333
releases += (
3434
f'{name}: [ZIP v{data["magisk"]["version"]}]({data["magisk"]["link"]}) | '
3535
f'[APK v{data["app"]["version"]}]({data["app"]["link"]}) | '
36-
f'[Uninstaller]({data["uninstaller"]["link"]})\n')
36+
f'[Uninstaller]({data["uninstaller"]["link"]})\n'
37+
)
3738
await request.edit(releases)
3839

3940

@@ -89,8 +90,7 @@ async def codename_info(request):
8990
"certified-android-devices/master/by_brand.json"
9091
).text
9192
)
92-
devices_lower = {k.lower(): v for k, v in data.items()
93-
} # Lower brand names in JSON
93+
devices_lower = {k.lower(): v for k, v in data.items()} # Lower brand names in JSON
9494
devices = devices_lower.get(brand)
9595
results = [
9696
i
@@ -227,11 +227,11 @@ async def devices_specifications(request):
227227
return
228228
all_brands = (
229229
BeautifulSoup(
230-
get("https://www.devicespecifications.com/en/brand-more").content,
231-
"lxml") .find(
232-
"div",
233-
{
234-
"class": "brand-listing-container-news"}) .findAll("a"))
230+
get("https://www.devicespecifications.com/en/brand-more").content, "lxml"
231+
)
232+
.find("div", {"class": "brand-listing-container-news"})
233+
.findAll("a")
234+
)
235235
brand_page_url = None
236236
try:
237237
brand_page_url = [

userbot/modules/anilist.py

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -174,11 +174,7 @@ async def callAPI(search_str):
174174
"""
175175
variables = {"search": search_str}
176176
url = "https://graphql.anilist.co"
177-
response = requests.post(
178-
url,
179-
json={
180-
"query": query,
181-
"variables": variables})
177+
response = requests.post(url, json={"query": query, "variables": variables})
182178
return response.text
183179

184180

@@ -223,13 +219,10 @@ async def anilist(event):
223219
reply_to_id = event.reply_to_msg_id
224220
variables = {"query": search}
225221
json = (
226-
requests.post(
227-
url,
228-
json={
229-
"query": character_query,
230-
"variables": variables}) .json()["data"] .get(
231-
"Character",
232-
None))
222+
requests.post(url, json={"query": character_query, "variables": variables})
223+
.json()["data"]
224+
.get("Character", None)
225+
)
233226
if json:
234227
msg = f"**{json.get('name').get('full')}**\n"
235228
description = f"{json['description']}"
@@ -279,9 +272,9 @@ async def anilist(event):
279272
)
280273
ms_g = ""
281274
if json:
282-
title, title_native = json["title"].get(
283-
"romaji", False), json["title"].get(
284-
"native", False)
275+
title, title_native = json["title"].get("romaji", False), json["title"].get(
276+
"native", False
277+
)
285278
start_date, status, score = (
286279
json["startDate"].get("year", False),
287280
json.get("status", False),

userbot/modules/anime.py

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,9 @@ def getBannerLink(mal, kitsu_search=True):
6868
}
6969
"""
7070
data = {"query": query, "variables": {"idMal": int(mal)}}
71-
image = requests.post("https://graphql.anilist.co",
72-
json=data).json()["data"]["Media"]["bannerImage"]
71+
image = requests.post("https://graphql.anilist.co", json=data).json()["data"][
72+
"Media"
73+
]["bannerImage"]
7374
if image:
7475
return image
7576
return getPosterLink(mal)
@@ -106,8 +107,7 @@ def get_anime_manga(mal_id, search_type, _user_id):
106107
if alternative_names:
107108
alternative_names_string = ", ".join(alternative_names)
108109
caption += f"\n<b>Also known as</b>: <code>{alternative_names_string}</code>"
109-
genre_string = ", ".join(genre_info["name"]
110-
for genre_info in result["genres"])
110+
genre_string = ", ".join(genre_info["name"] for genre_info in result["genres"])
111111
if result["synopsis"] is not None:
112112
synopsis = result["synopsis"].split(" ", 60)
113113
try:
@@ -161,8 +161,7 @@ def get_poster(query):
161161
soup = bs4.BeautifulSoup(page.content, "lxml")
162162
odds = soup.findAll("tr", "odd")
163163
# Fetching the first post from search
164-
page_link = "http://www.imdb.com/" + \
165-
odds[0].findNext("td").findNext("td").a["href"]
164+
page_link = "http://www.imdb.com/" + odds[0].findNext("td").findNext("td").a["href"]
166165
page1 = requests.get(page_link)
167166
soup = bs4.BeautifulSoup(page1.content, "lxml")
168167
# Poster Link
@@ -178,23 +177,13 @@ def post_to_telegraph(anime_title, html_format_content):
178177
bish = "https://t.me/GengKapak"
179178
post_client.create_api_token(auth_name)
180179
post_page = post_client.post(
181-
title=anime_title,
182-
author=auth_name,
183-
author_url=bish,
184-
text=html_format_content)
180+
title=anime_title, author=auth_name, author_url=bish, text=html_format_content
181+
)
185182
return post_page["url"]
186183

187184

188185
def replace_text(text):
189-
return text.replace(
190-
'"',
191-
"").replace(
192-
"\\r",
193-
"").replace(
194-
"\\n",
195-
"").replace(
196-
"\\",
197-
"")
186+
return text.replace('"', "").replace("\\r", "").replace("\\n", "").replace("\\", "")
198187

199188

200189
@register(outgoing=True, pattern=r"^\.anime ?(.*)")
@@ -546,8 +535,7 @@ async def manga(message):
546535
jikan = jikanpy.jikan.Jikan()
547536
search_result = jikan.search("manga", search_query)
548537
first_mal_id = search_result["results"][0]["mal_id"]
549-
caption, image = get_anime_manga(
550-
first_mal_id, "anime_manga", message.chat_id)
538+
caption, image = get_anime_manga(first_mal_id, "anime_manga", message.chat_id)
551539
await message.delete()
552540
await message.client.send_file(
553541
message.chat_id, file=image, caption=caption, parse_mode="HTML"
@@ -562,8 +550,7 @@ async def anime(message):
562550
jikan = jikanpy.jikan.Jikan()
563551
search_result = jikan.search("anime", search_query)
564552
first_mal_id = search_result["results"][0]["mal_id"]
565-
caption, image = get_anime_manga(
566-
first_mal_id, "anime_anime", message.chat_id)
553+
caption, image = get_anime_manga(first_mal_id, "anime_anime", message.chat_id)
567554
try:
568555
await message.delete()
569556
await message.client.send_file(
@@ -657,8 +644,7 @@ def is_gif(file):
657644
# lazy to go to github and make an issue kek
658645
if not is_video(file):
659646
return False
660-
if DocumentAttributeAnimated() not in getattr(
661-
file, "document", file).attributes:
647+
if DocumentAttributeAnimated() not in getattr(file, "document", file).attributes:
662648
return False
663649
return True
664650

0 commit comments

Comments
 (0)