diff --git a/Calistoga-Regular.ttf b/assets/Calistoga-Regular.ttf
similarity index 100%
rename from Calistoga-Regular.ttf
rename to assets/Calistoga-Regular.ttf
diff --git a/assets/MutantAcademyStyle.ttf b/assets/MutantAcademyStyle.ttf
new file mode 100644
index 00000000..00c56493
Binary files /dev/null and b/assets/MutantAcademyStyle.ttf differ
diff --git a/img/bg.png b/assets/bg.png
similarity index 100%
rename from img/bg.png
rename to assets/bg.png
diff --git a/img/profilepic.png b/assets/profilepic.png
similarity index 100%
rename from img/profilepic.png
rename to assets/profilepic.png
diff --git a/img/thumb.jpg b/assets/thumb.jpg
similarity index 100%
rename from img/thumb.jpg
rename to assets/thumb.jpg
diff --git a/misskaty/plugins/chatbot_ai.py b/misskaty/plugins/chatbot_ai.py
index 6c82de48..4f5bbaf2 100644
--- a/misskaty/plugins/chatbot_ai.py
+++ b/misskaty/plugins/chatbot_ai.py
@@ -1,8 +1,8 @@
from pyrogram import filters
-from pyrogram.errors import MessageNotModified
+from pyrogram.errors import MessageNotModified, MessageTooLong
from misskaty import app
-from misskaty.helper.http import http
+from misskaty.helper import http, post_to_telegraph
from misskaty.core.message_utils import *
from misskaty.core.decorator.ratelimiter import ratelimiter
from misskaty.vars import COMMAND_HANDLER, OPENAI_API
@@ -31,8 +31,14 @@ async def chatbot(c, m):
msg = await kirimPesan(m, "Wait a moment looking for your answer..")
try:
response = (await http.post("https://api.openai.com/v1/chat/completions", headers=headers, json=json_data)).json()
- await editPesan(msg, response["choices"][0]["message"]["content"])
- except MessageNotModified:
+ if err := response["error"]:
+ return await editPesan(msg, err["message"])
+ answer = response["choices"][0]["message"]["content"]
+ await editPesan(msg, answer)
+ except MessageTooLong:
+ answerlink = await post_to_telegraph(False, "MissKaty ChatBot ", answer)
+ await editPesan(msg, f"Question for your answer has exceeded TG text limit, check this link to view.\n\n{answerlink}", disable_web_page_preview=True)
+ except (MessageNotModified, MessageIdInvalid):
pass
except Exception as err:
- await editPesan(msg, f"Oppss. ERROR: {err}")
+ await editPesan(msg, f"Oppss. ERROR: {str(err)}")
diff --git a/misskaty/plugins/dev.py b/misskaty/plugins/dev.py
index 2514c15f..d3eb10fb 100644
--- a/misskaty/plugins/dev.py
+++ b/misskaty/plugins/dev.py
@@ -18,7 +18,7 @@ from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup
from misskaty import app, user, botStartTime, BOT_NAME
from misskaty.helper import http
from misskaty.helper.human_read import get_readable_file_size, get_readable_time
-from misskaty.core.message_utils import editPesan, kirimPesan
+from misskaty.core.message_utils import editPesan, hapusPesan, kirimPesan
from misskaty.vars import COMMAND_HANDLER, SUDO
from utils import LOGGER
@@ -74,7 +74,7 @@ async def donate(_, message):
@app.on_message(filters.command(["balas"], COMMAND_HANDLER) & filters.user(SUDO) & filters.reply)
async def balas(c, m):
pesan = m.text.split(" ", 1)
- await m.delete()
+ await hapusPesan(m)
await m.reply(pesan[1], reply_to_message_id=m.reply_to_message.id)
@@ -183,7 +183,7 @@ async def evaluation_cmd_t(_, m):
document="MissKatyEval.txt",
caption=f"{cmd[1][: 4096 // 4 - 1]}",
disable_notification=True,
- thumb="img/thumb.jpg",
+ thumb="assets/thumb.jpg",
reply_markup=InlineKeyboardMarkup([[InlineKeyboardButton(text="❌ Close", callback_data=f"close#{m.from_user.id}")]]),
)
os.remove("MissKatyEval.txt")
diff --git a/misskaty/plugins/download_upload.py b/misskaty/plugins/download_upload.py
index f2e839f8..f0d01bf4 100644
--- a/misskaty/plugins/download_upload.py
+++ b/misskaty/plugins/download_upload.py
@@ -165,7 +165,7 @@ async def fbdl(client, message):
await message.reply_video(
path,
caption=f"{os.path.basename(path)}\n\nUploaded for {message.from_user.mention} [{message.from_user.id}]",
- thumb="img/thumb.jpg"
+ thumb="assets/thumb.jpg"
)
await msg.delete()
try:
diff --git a/misskaty/plugins/grup_tools.py b/misskaty/plugins/grup_tools.py
index a6cee5cc..28cf12f9 100644
--- a/misskaty/plugins/grup_tools.py
+++ b/misskaty/plugins/grup_tools.py
@@ -48,19 +48,19 @@ def draw_multiple_line_text(image, text, font, text_start_height):
@asyncify
def welcomepic(pic, user, chat, id):
- background = Image.open("img/bg.png") # <- Background Image (Should be PNG)
+ background = Image.open("assets/bg.png") # <- Background Image (Should be PNG)
background = background.resize((1024, 500), Image.ANTIALIAS)
pfp = Image.open(pic).convert("RGBA")
pfp = circle(pfp)
pfp = pfp.resize((265, 265)) # Resizes the Profilepicture so it fits perfectly in the circle
- font = ImageFont.truetype("Calistoga-Regular.ttf", 37) # <- Text Font of the Member Count. Change the text size for your preference
+ font = ImageFont.truetype("assets/Calistoga-Regular.ttf", 37) # <- Text Font of the Member Count. Change the text size for your preference
member_text = f"Selamat Datang {user} [{id}]" # <- Text under the Profilepicture with the Membercount
draw_multiple_line_text(background, member_text, font, 395)
draw_multiple_line_text(background, chat, font, 47)
ImageDraw.Draw(background).text(
(530, 460),
f"Generated by @{BOT_USERNAME}",
- font=ImageFont.truetype("Calistoga-Regular.ttf", 28),
+ font=ImageFont.truetype("assets/Calistoga-Regular.ttf", 28),
size=20,
align="right",
)
@@ -96,7 +96,7 @@ async def member_has_joined(c: app, member: ChatMemberUpdated):
try:
pic = await app.download_media(user.photo.big_file_id, file_name=f"pp{user.id}.png")
except AttributeError:
- pic = "img/profilepic.png"
+ pic = "assets/profilepic.png"
try:
welcomeimg = await welcomepic(pic, user.first_name, member.chat.title, user.id)
temp.MELCOW[f"welcome-{member.chat.id}"] = await c.send_photo(
@@ -177,7 +177,7 @@ async def save_group(bot, message):
try:
pic = await app.download_media(u.photo.big_file_id, file_name=f"pp{u.id}.png")
except AttributeError:
- pic = "img/profilepic.png"
+ pic = "assets/profilepic.png"
if (temp.MELCOW).get(f"welcome-{message.chat.id}") is not None:
try:
await temp.MELCOW[f"welcome-{message.chat.id}"].delete()
diff --git a/misskaty/plugins/imdb_search.py b/misskaty/plugins/imdb_search.py
index ccb80b83..34878826 100644
--- a/misskaty/plugins/imdb_search.py
+++ b/misskaty/plugins/imdb_search.py
@@ -1,6 +1,7 @@
import json
import logging
import re
+import traceback
from bs4 import BeautifulSoup
from urllib.parse import quote_plus
@@ -22,8 +23,8 @@ from misskaty import BOT_USERNAME, app
from misskaty.core.message_utils import *
from misskaty.core.decorator.errors import capture_err
from misskaty.core.decorator.ratelimiter import ratelimiter
-from misskaty.helper import http, get_random_string, search_jw, GENRES_EMOJI
-from misskaty.vars import COMMAND_HANDLER
+from misskaty.helper import http, get_random_string, search_jw, GENRES_EMOJI, post_to_telegraph
+from misskaty.vars import COMMAND_HANDLER, LOG_CHANNEL
LOGGER = logging.getLogger(__name__)
LIST_CARI = {}
@@ -394,10 +395,12 @@ async def imdb_id_callback(_, query):
await query.message.edit_caption(res_str, parse_mode=enums.ParseMode.HTML, reply_markup=markup)
else:
await query.message.edit_caption(res_str, parse_mode=enums.ParseMode.HTML, reply_markup=markup)
- except MessageNotModified:
+ except (MessageNotModified, MessageIdInvalid):
pass
except Exception as exc:
- await query.message.edit_caption(f"ERROR:\n{exc}")
+ err = traceback.format_exc(limit=20)
+ await query.message.edit_caption(f"ERROR:\n{exc}\nFull Error: {err}\n\nSilahkan lapor ke owner detail errornya dengan lengkap, atau laporan error akan diabaikan.")
+ await app.send_message(LOG_CHANNEL, f"ERROR getting IMDb Detail in Indonesia:\n{str(err)}")
@app.on_callback_query(filters.regex("^imdbres_en"))
@@ -510,5 +513,9 @@ async def imdb_en_callback(bot, query):
await query.message.edit_caption(res_str, parse_mode=enums.ParseMode.HTML, reply_markup=markup)
else:
await query.message.edit_caption(res_str, parse_mode=enums.ParseMode.HTML, reply_markup=markup)
+ except (MessageNotModified, MessageIdInvalid):
+ pass
except Exception as exc:
- await query.message.edit_caption(f"ERROR:\n{exc}")
+ err = traceback.format_exc(limit=20)
+ await query.message.edit_caption(f"ERROR:\n{exc}\nFull Error: {err}\n\nPlease report to owner with detail of error, or your report will be ignored.")
+ await app.send_message(LOG_CHANNEL, f"ERROR getting IMDb Detail in Eng:\n{str(err)}")
diff --git a/misskaty/plugins/json.py b/misskaty/plugins/json.py
index f626d4a8..6889d47e 100644
--- a/misskaty/plugins/json.py
+++ b/misskaty/plugins/json.py
@@ -46,6 +46,6 @@ async def jsonify(_, message):
caption=f"{str(e)}",
disable_notification=True,
reply_to_message_id=reply_to_id,
- thumb="img/thumb.jpg",
+ thumb="assets/thumb.jpg",
)
os.remove("json.text")
diff --git a/misskaty/plugins/mediainfo.py b/misskaty/plugins/mediainfo.py
index 4a614374..b752718b 100644
--- a/misskaty/plugins/mediainfo.py
+++ b/misskaty/plugins/mediainfo.py
@@ -66,7 +66,7 @@ DETAILS
await message.reply_document(
out_file,
caption=f"ℹ️ MEDIA INFO\n\n**Request by:** {message.from_user.mention}",
- thumb="img/thumb.jpg",
+ thumb="assets/thumb.jpg",
reply_markup=markup,
)
await process.delete()
@@ -101,7 +101,7 @@ DETAILS
await message.reply_document(
out_file,
caption=f"Hasil mediainfo anda..\n\n**Request by:** {message.from_user.mention}",
- thumb="img/thumb.jpg",
+ thumb="assets/thumb.jpg",
reply_markup=markup,
)
await process.delete()
diff --git a/misskaty/plugins/memify.py b/misskaty/plugins/memify.py
index 02c6002d..29480406 100644
--- a/misskaty/plugins/memify.py
+++ b/misskaty/plugins/memify.py
@@ -1,4 +1,5 @@
import textwrap
+from asyncio import gather
from os import remove as hapus
from PIL import Image, ImageDraw, ImageFont
@@ -14,7 +15,7 @@ async def draw_meme_text(image_path, text):
img = Image.open(image_path)
hapus(image_path)
i_width, i_height = img.size
- m_font = ImageFont.truetype("Calistoga-Regular.ttf", int((70 / 640) * i_width))
+ m_font = ImageFont.truetype("assets/MutantAcademyStyle.ttf", int((70 / 640) * i_width))
if ";" in text:
upper_text, lower_text = text.split(";")
else:
@@ -146,8 +147,7 @@ async def memify(client, message):
try:
file = await message.reply_to_message.download()
webp, png = await draw_meme_text(file, message.text.split(None, 1)[1].strip())
- await message.reply_sticker(webp)
- await message.reply_document(png)
+ await gather(*[message.reply_document(png), message.reply_sticker(webp)])
try:
hapus(webp)
hapus(png)
diff --git a/misskaty/plugins/sangmata.py b/misskaty/plugins/sangmata.py
index 907f9422..16857b1d 100644
--- a/misskaty/plugins/sangmata.py
+++ b/misskaty/plugins/sangmata.py
@@ -20,7 +20,7 @@ This feature inspired from SangMata Bot. I'm created simple detection to check u
group=3,
)
async def cek_mataa(_, m):
- if not await is_sangmata_on(m.chat.id):
+ if m.sender_chat or not await is_sangmata_on(m.chat.id):
return
if not await cek_userdata(m.from_user.id):
return await add_userdata(m.from_user.id, m.from_user.username, m.from_user.first_name, m.from_user.last_name)
diff --git a/misskaty/plugins/sub_extractor.py b/misskaty/plugins/sub_extractor.py
index 6234c9c5..1801b811 100644
--- a/misskaty/plugins/sub_extractor.py
+++ b/misskaty/plugins/sub_extractor.py
@@ -123,7 +123,7 @@ async def convertsrt(c, m):
await m.reply_document(
f"{filename}.srt",
caption=f"{filename}.srt\n\nConverted by @{c.me.username}",
- thumb="img/thumb.jpg",
+ thumb="assets/thumb.jpg",
progress=progress_for_pyrogram,
progress_args=("Uploading files..", msg, c_time),
)
@@ -168,7 +168,7 @@ async def stream_extract(bot, update):
namafile,
caption=f"Filename: {namafile}\n\nExtracted by @{bot.me.username} in {timelog}",
reply_to_message_id=usr.id,
- thumb="img/thumb.jpg",
+ thumb="assets/thumb.jpg",
progress=progress_for_pyrogram,
progress_args=("Uploading files..", update.message, c_time),
)