diff --git a/misskaty/helper/kuso_utils.py b/misskaty/helper/kuso_utils.py index 67c840ff..42f1d6fd 100644 --- a/misskaty/helper/kuso_utils.py +++ b/misskaty/helper/kuso_utils.py @@ -3,7 +3,7 @@ import subprocess import sys import chevron -from .media_helper import post_to_telegraph +import telegraph import logging from aiohttp import ClientSession from misskaty import BOT_USERNAME @@ -11,6 +11,11 @@ from bs4 import BeautifulSoup as bs4 LOGGER = logging.getLogger(__name__) +telegraph = telegraph.Telegraph() +if telegraph.get_access_token() == None: + token_ph = telegraph.create_account(short_name=BOT_USERNAME) + LOGGER.info(f"kuso_utils: Create TGH Account ..") + headers = {"Accept": "*/*", "User-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.102 Safari/537.36 Edge/18.19582"} @@ -79,7 +84,7 @@ async def byPassPh(url: str, msg_id: int): """.strip() if not kusonime["error"]: html = chevron.render(template, kusonime) - page = await post_to_telegraph(False, f"{kusonime.get('title')}-{msg_id}", html) + page = telegraph.create_page(f"{kusonime.get('title')}-{msg_id}", html_content=html) results.update({"error": False, "url": "https://telegra.ph/{}".format(page["path"])}) del results["error_message"] return results diff --git a/misskaty/plugins/grup_tools.py b/misskaty/plugins/grup_tools.py index d85b945f..ba1266f2 100644 --- a/misskaty/plugins/grup_tools.py +++ b/misskaty/plugins/grup_tools.py @@ -102,12 +102,15 @@ async def member_has_joined(c: app, member: ChatMemberUpdated): pic = await app.download_media(user.photo.big_file_id, file_name=f"pp{user.id}.png") except AttributeError: pic = "img/profilepic.png" - welcomeimg = await welcomepic(pic, user.first_name, member.chat.title, count, user.id) - temp.MELCOW[f"welcome-{member.chat.id}"] = await c.send_photo( - member.chat.id, - photo=welcomeimg, - caption=f"Hai {mention}, Selamat datang digrup {member.chat.title} harap baca rules di pinned message terlebih dahulu.\n\nNama : {first_name}\nID : {id}\nDC ID : {dc}\nTanggal Join : {joined_date}", - ) + try: + welcomeimg = await welcomepic(pic, user.first_name, member.chat.title, count, user.id) + temp.MELCOW[f"welcome-{member.chat.id}"] = await c.send_photo( + member.chat.id, + photo=welcomeimg, + caption=f"Hai {mention}, Selamat datang digrup {member.chat.title} harap baca rules di pinned message terlebih dahulu.\n\nNama : {first_name}\nID : {id}\nDC ID : {dc}\nTanggal Join : {joined_date}", + ) + except: + pass userspammer = "" # Spamwatch Detection try: @@ -181,13 +184,13 @@ async def save_group(bot, message): pic = await app.download_media(u.photo.big_file_id, file_name=f"pp{u.id}.png") except AttributeError: pic = "img/profilepic.png" - welcomeimg = await welcomepic(pic, u.first_name, message.chat.title, count, u.id) if (temp.MELCOW).get(f"welcome-{message.chat.id}") is not None: try: await (temp.MELCOW[f"welcome-{message.chat.id}"]).delete() except: pass try: + welcomeimg = await welcomepic(pic, u.first_name, message.chat.title, count, u.id) temp.MELCOW[f"welcome-{message.chat.id}"] = await app.send_photo( message.chat.id, photo=welcomeimg, diff --git a/misskaty/plugins/paste.py b/misskaty/plugins/paste.py index 8cef08b1..b628231a 100644 --- a/misskaty/plugins/paste.py +++ b/misskaty/plugins/paste.py @@ -92,7 +92,7 @@ async def telegraph_paste(_, message): pasted = f"**Successfully upload your media to Telegraph.\n\nUpload by {uname}**" remove(file) - return await editPesan(msg, pasted, reply_markup=InlineKeyboardMarkup(button)) + return await editPesan(msg, pasted, disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(button)) data = "" limit = 1024 * 1024 if reply and reply.document: @@ -181,7 +181,6 @@ async def wastepaste(_, message): "ephemeral": False, "expire_at": 0, "expire_in": 0, - "date_created": 0, } response = await http.post('https://yasirbin.deta.dev/api/new', json=json_data) url = f"https://yasirbin.deta.dev/{response.json()['id']}"