GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>
Subject: [RFC PATCH v1 4/5] [telegram] Remove unecessary files
Date: Tue,  6 Sep 2022 18:19:28 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Just remove unecessary files because it's already moved to the
plugins/commands

Signed-off-by: Muhammad Rizki <[email protected]>
---
 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 <[email protected]>
-#
-
-from pyrogram import Client, filters, enums
-from pyrogram.types import Message
-from textwrap import indent
-import io, import_expression, contextlib, traceback
-
[email protected]_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 <[email protected]>
-# Copyright (C) 2022  Ammar Faizi <[email protected]>
-#
-
-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+)"
[email protected]_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


  parent reply	other threads:[~2022-09-06 11:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-06 11:19 [RFC PATCH v1 0/5] Refactor some Telegram bot source code Muhammad Rizki
2022-09-06 11:19 ` [RFC PATCH v1 1/5] [telegram] Move the " Muhammad Rizki
2022-09-06 11:19 ` [RFC PATCH v1 2/5] [telegram] Refactor Telegram bot database method Muhammad Rizki
2022-09-06 11:19 ` [RFC PATCH v1 3/5] [telegram] Renaming some functions in scraper/bot.py Muhammad Rizki
2022-09-06 16:11   ` Ammar Faizi
2022-09-06 11:19 ` Muhammad Rizki [this message]
2022-09-06 16:02   ` [RFC PATCH v1 4/5] [telegram] Remove unecessary files Ammar Faizi
2022-09-06 16:46     ` Muhammad Rizki
2022-09-06 16:53       ` Ammar Faizi
2022-09-06 11:19 ` [RFC PATCH v1 5/5] Refactor many files Muhammad Rizki
2022-09-06 16:04   ` Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox