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
52 changes: 27 additions & 25 deletions userbot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@
)
else:
basicConfig(
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s",
level=INFO)
format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=INFO
)
LOGS = getLogger(__name__)

if version_info[0] < 3 or version_info[1] < 9:
Expand Down Expand Up @@ -150,8 +150,7 @@

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

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

# Default .alive logo
ALIVE_LOGO = (os.environ.get("ALIVE_LOGO")
or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg")
ALIVE_LOGO = (
os.environ.get("ALIVE_LOGO") or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg"
)

# Default .helpme logo
INLINE_PIC = (os.environ.get("INLINE_PIC")
or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg")
INLINE_PIC = (
os.environ.get("INLINE_PIC") or "https://telegra.ph/file/8eb368517a8d3933c05d9.jpg"
)

# Default Emoji Help Inline
EMOJI_HELP = os.environ.get("EMOJI_HELP") or "|"
Expand Down Expand Up @@ -254,8 +255,7 @@
G_DRIVE_CLIENT_SECRET = os.environ.get("G_DRIVE_CLIENT_SECRET", None)
G_DRIVE_AUTH_TOKEN_DATA = os.environ.get("G_DRIVE_AUTH_TOKEN_DATA", None)
G_DRIVE_FOLDER_ID = os.environ.get("G_DRIVE_FOLDER_ID", None)
TEMP_DOWNLOAD_DIRECTORY = os.environ.get(
"TMP_DOWNLOAD_DIRECTORY", "./downloads")
TEMP_DOWNLOAD_DIRECTORY = os.environ.get("TMP_DOWNLOAD_DIRECTORY", "./downloads")
# Google Photos
G_PHOTOS_CLIENT_ID = os.environ.get("G_PHOTOS_CLIENT_ID", None)
G_PHOTOS_CLIENT_SECRET = os.environ.get("G_PHOTOS_CLIENT_SECRET", None)
Expand Down Expand Up @@ -345,7 +345,8 @@ async def check_botlog_chatid():
if entity.default_banned_rights.send_messages:
LOGS.info(
"Akun Anda Tidak Memiliki Hak Untuk Mengirim Pesan Ke BOTLOG_CHATID "
"Grup Pribadi Periksa Apakah Anda Mengetik ID Obrolan Benar")
"Grup Pribadi Periksa Apakah Anda Mengetik ID Obrolan Benar"
)
quit(1)


Expand Down Expand Up @@ -424,7 +425,7 @@ def paginate_help(page_number, loaded_modules, prefix):
modulo_page = page_number % max_num_pages
if len(pairs) > number_of_rows:
pairs = pairs[
modulo_page * number_of_rows: number_of_rows * (modulo_page + 1)
modulo_page * number_of_rows : number_of_rows * (modulo_page + 1)
] + [
(
custom.Button.inline(
Expand Down Expand Up @@ -498,7 +499,8 @@ async def handler(event):
f"**Database :** Mongo db \n"
f"**Bahasa :** Python \n"
f"**Daftar Perintah Bot :** [KLIK DISINI](https://telegra.ph/Perintah-Penggunaan-08-05) \n"
"========================================")
"========================================"
)
await king.tgbot.send_file(
event.chat_id,
file=logo,
Expand Down Expand Up @@ -576,7 +578,8 @@ async def handler(event):
f"`Database :` Mongo db \n\n"
"=============================\n"
f" **USERBOT TELEGRAM** \n"
"=============================")
"============================="
)
await king.tgbot.send_file(
event.chat_id,
file=alive,
Expand Down Expand Up @@ -604,7 +607,8 @@ async def handler(event):
f"👋🏻 Hai [{get_display_name(u)}](tg://user?id={u.id}) Jika anda\n"
f"Ingin donasi atau menyumbang uang ini ke developer kami\n\n"
f"• **Notes : Donasi Seikhlasnya** \n\n"
f"**Terimakasih** ")
f"**Terimakasih** "
)
await king.tgbot.send_file(
event.chat_id,
file=donate,
Expand Down Expand Up @@ -652,8 +656,7 @@ async def inline_handler(event):
builder = event.builder
result = None
query = event.text
if event.query.user_id == uid and query.startswith(
"@KingUserbotSupport"):
if event.query.user_id == uid and query.startswith("@KingUserbotSupport"):
buttons = paginate_help(0, dugmeler, "helpme")
result = builder.photo(
file=logo,
Expand Down Expand Up @@ -817,10 +820,8 @@ async def on_plug_in_callback_query_handler(event):
)
async def on_plug_in_callback_query_handler(event):
if event.query.user_id == uid: # pylint:disable=E0602
current_page_number = int(
event.data_match.group(1).decode("UTF-8"))
buttons = paginate_help(
current_page_number + 1, dugmeler, "helpme")
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = paginate_help(current_page_number + 1, dugmeler, "helpme")
# https://t.me/TelethonChat/115200
await event.edit(buttons=buttons)
else:
Expand Down Expand Up @@ -863,8 +864,7 @@ async def on_plug_in_callback_query_handler(event):
)
async def on_plug_in_callback_query_handler(event):
if event.query.user_id == uid: # pylint:disable=E0602
current_page_number = int(
event.data_match.group(1).decode("UTF-8"))
current_page_number = int(event.data_match.group(1).decode("UTF-8"))
buttons = paginate_help(
current_page_number - 1, dugmeler, "helpme" # pylint:disable=E0602
)
Expand Down Expand Up @@ -973,7 +973,8 @@ async def on_plug_in_callback_query_handler(event):
f"✘ **Set Vars :**\n"
f"`.set var ALIVE_LOGO` <link>\n"
f"`.set var KING_TEKS_KUSTOM` <teks>\n"
f"`.set var ALIVE_LOGO None` <tidak memakai pic/foto>")
f"`.set var ALIVE_LOGO None` <tidak memakai pic/foto>"
)
await event.edit(
text,
file=logo,
Expand Down Expand Up @@ -1005,7 +1006,8 @@ async def on_plug_in_callback_query_handler(event):
f"✘ **Set Vars :**\n"
f"`.set var PMPERMIT_PIC` <link>\n"
f"`.set var PMPERMIT_TEXT` <teks>\n"
f"`.set var PMPERMIT_PIC None` <tidak memakai pic/foto>")
f"`.set var PMPERMIT_PIC None` <tidak memakai pic/foto>"
)
await event.edit(
text,
file=logo,
Expand Down
3 changes: 1 addition & 2 deletions userbot/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,7 @@ async def wrapper(check):
command, stdout=asyncsub.PIPE, stderr=asyncsub.PIPE
)
stdout, stderr = await process.communicate()
result = str(stdout.decode().strip()) + \
str(stderr.decode().strip())
result = str(stdout.decode().strip()) + str(stderr.decode().strip())

ftext += result

Expand Down
4 changes: 2 additions & 2 deletions userbot/modules/__inlinehelp.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@


logging.basicConfig(
format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s",
level=logging.WARNING)
format="[%(levelname) 5s/%(asctime)s] %(name)s: %(message)s", level=logging.WARNING
)


@register(outgoing=True, pattern=r"^\.helpme")
Expand Down
11 changes: 4 additions & 7 deletions userbot/modules/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,8 @@ async def rm_deletedacc(show):
if del_u > 0:
del_status = (
f"`Menemukan` **{del_u}** `Akun Hantu/Terhapus/Zombie Dalam Grup Ini,"
"\nBersihkan Itu Menggunakan Perintah .zombies clean`")
"\nBersihkan Itu Menggunakan Perintah .zombies clean`"
)
return await show.edit(del_status)

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

if isinstance(
probable_user_mention_entity,
MessageEntityMentionName):
if isinstance(probable_user_mention_entity, MessageEntityMentionName):
user_id = probable_user_mention_entity.user_id
user_obj = await event.client.get_entity(user_id)
return user_obj
Expand Down Expand Up @@ -891,9 +890,7 @@ async def get_userdel_from_event(event):
if event.message.entities is not None:
probable_user_mention_entity = event.message.entities[0]

if isinstance(
probable_user_mention_entity,
MessageEntityMentionName):
if isinstance(probable_user_mention_entity, MessageEntityMentionName):
user_id = probable_user_mention_entity.user_id
user_obj = await event.client.get_entity(user_id)
return user_obj
Expand Down
10 changes: 6 additions & 4 deletions userbot/modules/afk.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ async def set_not_afk(event):
os.system("rm -rf *.jpg")


@bot.on(events.NewMessage(incoming=True,
func=lambda e: bool(e.mentioned or e.is_private)))
@bot.on(
events.NewMessage(incoming=True, func=lambda e: bool(e.mentioned or e.is_private))
)
async def on_afk(event):
if event.fwd_from:
return
Expand All @@ -110,8 +111,9 @@ async def on_afk(event):
msg = None
if reason:
message_to_reply = (
f"**{ALIVE_NAME} Sedang AFK**\n\n**Sejak :** `{total_afk_time}` **Yang Lalu**\n" +
f"**Karena :** `{reason}`")
f"**{ALIVE_NAME} Sedang AFK**\n\n**Sejak :** `{total_afk_time}` **Yang Lalu**\n"
+ f"**Karena :** `{reason}`"
)
else:
message_to_reply = f"**Maaf King {ALIVE_NAME} Sedang AFK**\n\n**Sejak :** `{total_afk_time}` **Yang Lalu**"
try:
Expand Down
16 changes: 8 additions & 8 deletions userbot/modules/android.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ async def magisk(request):
releases += (
f'{name}: [ZIP v{data["magisk"]["version"]}]({data["magisk"]["link"]}) | '
f'[APK v{data["app"]["version"]}]({data["app"]["link"]}) | '
f'[Uninstaller]({data["uninstaller"]["link"]})\n')
f'[Uninstaller]({data["uninstaller"]["link"]})\n'
)
await request.edit(releases)


Expand Down Expand Up @@ -89,8 +90,7 @@ async def codename_info(request):
"certified-android-devices/master/by_brand.json"
).text
)
devices_lower = {k.lower(): v for k, v in data.items()
} # Lower brand names in JSON
devices_lower = {k.lower(): v for k, v in data.items()} # Lower brand names in JSON
devices = devices_lower.get(brand)
results = [
i
Expand Down Expand Up @@ -227,11 +227,11 @@ async def devices_specifications(request):
return
all_brands = (
BeautifulSoup(
get("https://www.devicespecifications.com/en/brand-more").content,
"lxml") .find(
"div",
{
"class": "brand-listing-container-news"}) .findAll("a"))
get("https://www.devicespecifications.com/en/brand-more").content, "lxml"
)
.find("div", {"class": "brand-listing-container-news"})
.findAll("a")
)
brand_page_url = None
try:
brand_page_url = [
Expand Down
23 changes: 8 additions & 15 deletions userbot/modules/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,7 @@ async def callAPI(search_str):
"""
variables = {"search": search_str}
url = "https://graphql.anilist.co"
response = requests.post(
url,
json={
"query": query,
"variables": variables})
response = requests.post(url, json={"query": query, "variables": variables})
return response.text


Expand Down Expand Up @@ -223,13 +219,10 @@ async def anilist(event):
reply_to_id = event.reply_to_msg_id
variables = {"query": search}
json = (
requests.post(
url,
json={
"query": character_query,
"variables": variables}) .json()["data"] .get(
"Character",
None))
requests.post(url, json={"query": character_query, "variables": variables})
.json()["data"]
.get("Character", None)
)
if json:
msg = f"**{json.get('name').get('full')}**\n"
description = f"{json['description']}"
Expand Down Expand Up @@ -279,9 +272,9 @@ async def anilist(event):
)
ms_g = ""
if json:
title, title_native = json["title"].get(
"romaji", False), json["title"].get(
"native", False)
title, title_native = json["title"].get("romaji", False), json["title"].get(
"native", False
)
start_date, status, score = (
json["startDate"].get("year", False),
json.get("status", False),
Expand Down
36 changes: 11 additions & 25 deletions userbot/modules/anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,9 @@ def getBannerLink(mal, kitsu_search=True):
}
"""
data = {"query": query, "variables": {"idMal": int(mal)}}
image = requests.post("https://graphql.anilist.co",
json=data).json()["data"]["Media"]["bannerImage"]
image = requests.post("https://graphql.anilist.co", json=data).json()["data"][
"Media"
]["bannerImage"]
if image:
return image
return getPosterLink(mal)
Expand Down Expand Up @@ -106,8 +107,7 @@ def get_anime_manga(mal_id, search_type, _user_id):
if alternative_names:
alternative_names_string = ", ".join(alternative_names)
caption += f"\n<b>Also known as</b>: <code>{alternative_names_string}</code>"
genre_string = ", ".join(genre_info["name"]
for genre_info in result["genres"])
genre_string = ", ".join(genre_info["name"] for genre_info in result["genres"])
if result["synopsis"] is not None:
synopsis = result["synopsis"].split(" ", 60)
try:
Expand Down Expand Up @@ -161,8 +161,7 @@ def get_poster(query):
soup = bs4.BeautifulSoup(page.content, "lxml")
odds = soup.findAll("tr", "odd")
# Fetching the first post from search
page_link = "http://www.imdb.com/" + \
odds[0].findNext("td").findNext("td").a["href"]
page_link = "http://www.imdb.com/" + odds[0].findNext("td").findNext("td").a["href"]
page1 = requests.get(page_link)
soup = bs4.BeautifulSoup(page1.content, "lxml")
# Poster Link
Expand All @@ -178,23 +177,13 @@ def post_to_telegraph(anime_title, html_format_content):
bish = "https://t.me/GengKapak"
post_client.create_api_token(auth_name)
post_page = post_client.post(
title=anime_title,
author=auth_name,
author_url=bish,
text=html_format_content)
title=anime_title, author=auth_name, author_url=bish, text=html_format_content
)
return post_page["url"]


def replace_text(text):
return text.replace(
'"',
"").replace(
"\\r",
"").replace(
"\\n",
"").replace(
"\\",
"")
return text.replace('"', "").replace("\\r", "").replace("\\n", "").replace("\\", "")


@register(outgoing=True, pattern=r"^\.anime ?(.*)")
Expand Down Expand Up @@ -546,8 +535,7 @@ async def manga(message):
jikan = jikanpy.jikan.Jikan()
search_result = jikan.search("manga", search_query)
first_mal_id = search_result["results"][0]["mal_id"]
caption, image = get_anime_manga(
first_mal_id, "anime_manga", message.chat_id)
caption, image = get_anime_manga(first_mal_id, "anime_manga", message.chat_id)
await message.delete()
await message.client.send_file(
message.chat_id, file=image, caption=caption, parse_mode="HTML"
Expand All @@ -562,8 +550,7 @@ async def anime(message):
jikan = jikanpy.jikan.Jikan()
search_result = jikan.search("anime", search_query)
first_mal_id = search_result["results"][0]["mal_id"]
caption, image = get_anime_manga(
first_mal_id, "anime_anime", message.chat_id)
caption, image = get_anime_manga(first_mal_id, "anime_anime", message.chat_id)
try:
await message.delete()
await message.client.send_file(
Expand Down Expand Up @@ -657,8 +644,7 @@ def is_gif(file):
# lazy to go to github and make an issue kek
if not is_video(file):
return False
if DocumentAttributeAnimated() not in getattr(
file, "document", file).attributes:
if DocumentAttributeAnimated() not in getattr(file, "document", file).attributes:
return False
return True

Expand Down
Loading