From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.125.100]) by gnuweeb.org (Postfix) with ESMTPSA id DF83D80D10; Tue, 6 Sep 2022 11:19:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1662463197; bh=KVpovjiMnVUxRRx8/G2wOLMwYm7WWY3ZdH7S5VGgZ0I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=jTt1kcTfOu2qAnCUoaT70IOCq2kBv7Fe2yerJVxQGmn9sXegQdS1+FZY76EIF//ci zZ1jGejZawYIdaBlmCfzW/lJqVKL2F+1DCovoQgBbfch6GYJj5GNzV8uAgLMA8lCYg ahRgzO7L2h46iIdd+l9m/xc4wsjX7dG1tgHLSzWsel0lHMD9GAmpLCSM8zUxhOMAMa B0XGD4HHsBcDeRj2ZouTARCeLiugmsgTORZmVIMLJtb3jCssO8H2zJTVSl1BTIuOZO Nygv33I7/tPRblYT6X+xxo6ybm7voIDDEkTsWHTZ8tBuEefEv4pJrmQYltYwNnbnh9 t8BR2krXT48vg== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , GNU/Weeb Mailing List , Alviro Iskandar Setiawan Subject: [RFC PATCH v1 4/5] [telegram] Remove unecessary files Date: Tue, 6 Sep 2022 18:19:28 +0700 Message-Id: <20220906111929.1657-5-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20220906111929.1657-1-kiizuha@gnuweeb.org> References: <20220906111929.1657-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Just remove unecessary files because it's already moved to the plugins/commands Signed-off-by: Muhammad Rizki --- daemon/telegram/packages/plugins/admin.py | 42 ----------- daemon/telegram/packages/plugins/scrape.py | 86 ---------------------- 2 files changed, 128 deletions(-) delete mode 100644 daemon/telegram/packages/plugins/admin.py delete mode 100644 daemon/telegram/packages/plugins/scrape.py diff --git a/daemon/telegram/packages/plugins/admin.py b/daemon/telegram/packages/plugins/admin.py deleted file mode 100644 index e0f145e..0000000 --- a/daemon/telegram/packages/plugins/admin.py +++ /dev/null @@ -1,42 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# Copyright (C) 2022 Muhammad Rizki -# - -from pyrogram import Client, filters, enums -from pyrogram.types import Message -from textwrap import indent -import io, import_expression, contextlib, traceback - -@Client.on_message( - filters.command(['d','debug']) & - filters.user(["nekoha", "kiizuah"]) -) -async def execute_v2(c: Client, m: Message): - sep = m.text.split('\n') - body = m.text.replace(sep[0] + '\n','') - - env = {"bot": c} - env.update(globals()) - - stdout = io.StringIO() - to_compile = f'async def func(_, m):\n{indent(body, " ")}' - - try: - import_expression.exec(to_compile, env) - except Exception as e: - text = f"```{e.__class__.__name__}: {e}"[0:4096]+"```" - - func = env["func"] - - try: - with contextlib.redirect_stdout(stdout): - await func(c, m) - except Exception: - value = stdout.getvalue() - text = f"```{value}{traceback.format_exc()}"[0:4096]+"```" - else: - value = stdout.getvalue() - text = f"```{value}"[0:4096]+"```" - - await c.send_message(m.chat.id, text, parse_mode=enums.ParseMode.MARKDOWN) diff --git a/daemon/telegram/packages/plugins/scrape.py b/daemon/telegram/packages/plugins/scrape.py deleted file mode 100644 index 1698c6d..0000000 --- a/daemon/telegram/packages/plugins/scrape.py +++ /dev/null @@ -1,86 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# Copyright (C) 2022 Muhammad Rizki -# Copyright (C) 2022 Ammar Faizi -# - -from pyrogram.types import InlineKeyboardMarkup -from pyrogram.types import InlineKeyboardButton -from pyrogram.types import Message -from pyrogram import filters -from pyrogram import Client -from scraper import Scraper -from pyrogram import enums -from scraper import utils -from scraper import Bot -import shutil -import re -import asyncio - - -# -# This allows user to invoke the following commands: -# /lore https://lore.kernel.org/path/message_id/raw -# !lore https://lore.kernel.org/path/message_id/raw -# .lore https://lore.kernel.org/path/message_id/raw -# -LORE_CMD_URL_PATTERN = r"^(?:\/|\.|\!)lore\s+(https?:\/\/lore\.kernel\.org\/\S+)" -@Client.on_message( - filters.regex(LORE_CMD_URL_PATTERN) & - filters.chat(["kiizuah", "nekoha", -1001673279485]) -) -async def scrap_email(_, m: Message): - p = re.search(LORE_CMD_URL_PATTERN, m.text) - if not p: - return - - url = p.group(1) - if not url: - return - - s = Scraper() - mail = await s.get_email_from_url(url) - text, files, is_patch = utils.create_template(mail) - - if is_patch: - m = await __send_patch_msg(m, mail, text, url) - else: - text = "#ml\n" + text - m = await __send_text_msg(m, text, url) - - for d, f in files: - await m.reply_document(f"{d}/{f}", file_name=f) - await asyncio.sleep(1) - - if files: - shutil.rmtree(str(files[0][0])) - - -async def __send_patch_msg(m, mail, text, url): - tmp, fnm, caption, url = Bot.prepare_send_patch(mail, text, url) - ret = await m.reply_document( - fnm, - caption=caption, - parse_mode=enums.ParseMode.HTML, - reply_markup=InlineKeyboardMarkup([ - [InlineKeyboardButton( - "See the full message", - url=url - )] - ]) - ) - Bot.clean_up_after_send_patch(tmp) - return ret - - -async def __send_text_msg(m, text, url): - return await m.reply( - text, - parse_mode=enums.ParseMode.HTML, - reply_markup=InlineKeyboardMarkup([ - [InlineKeyboardButton( - "See the full message", - url=url.replace("/raw","") - )] - ]) - ) -- Muhammad Rizki