mirror of
https://github.com/Xtao-Labs/iShotaBot.git
synced 2024-11-25 18:03:36 +00:00
📝 解析 lofter 已被收录时进行提示
This commit is contained in:
parent
2d7016c34e
commit
7c8ebe76a4
@ -22,3 +22,4 @@ access_token_secret = ABCD
|
||||
[post]
|
||||
admin = 0
|
||||
lofter_channel = 0
|
||||
lofter_channel_username = username
|
||||
|
@ -15,6 +15,7 @@ access_token_secret: str = ""
|
||||
# [post]
|
||||
admin: int = 0
|
||||
lofter_channel: int = 0
|
||||
lofter_channel_username: str = ""
|
||||
|
||||
config = RawConfigParser()
|
||||
config.read("config.ini")
|
||||
@ -27,6 +28,7 @@ access_token_key = config.get("twitter", "access_token_key", fallback=access_tok
|
||||
access_token_secret = config.get("twitter", "access_token_secret", fallback=access_token_secret)
|
||||
admin = config.getint("post", "admin", fallback=admin)
|
||||
lofter_channel = config.getint("post", "lofter_channel", fallback=lofter_channel)
|
||||
lofter_channel_username = config.get("post", "lofter_channel_username", fallback=lofter_channel_username)
|
||||
try:
|
||||
ipv6 = strtobool(ipv6)
|
||||
except ValueError:
|
||||
|
@ -10,6 +10,8 @@ from bs4 import BeautifulSoup
|
||||
from pyrogram.types import InputMediaPhoto, InlineKeyboardMarkup, InlineKeyboardButton, InputMediaDocument, \
|
||||
InputMediaAnimation, Message
|
||||
|
||||
from defs.glover import lofter_channel_username
|
||||
from models.lofter import LofterPost as LofterPostModel
|
||||
from init import request
|
||||
|
||||
|
||||
@ -20,6 +22,7 @@ class LofterItem:
|
||||
self.only_text = url is None
|
||||
self.file = None
|
||||
self.origin_url = origin_url
|
||||
self.post_id = origin_url.split("/post/")[1].split("?")[0]
|
||||
self.username = username
|
||||
self.text = f"<b>Lofter Status Info</b>\n\n" \
|
||||
f"<code>{title.strip()}</code>\n\n" \
|
||||
@ -27,7 +30,12 @@ class LofterItem:
|
||||
f"{tags}\n" \
|
||||
f"{comment}"
|
||||
|
||||
async def check_exists(self):
|
||||
if await LofterPostModel.get_by_post_id(self.post_id):
|
||||
self.text += f"\n📄 此图集已被<a href=\"https://t.me/{lofter_channel_username}\">此频道</a>收录"
|
||||
|
||||
async def init(self):
|
||||
await self.check_exists()
|
||||
if self.only_text:
|
||||
return
|
||||
file = await request.get(self.url, timeout=30)
|
||||
|
@ -23,6 +23,10 @@ class LofterPost:
|
||||
else:
|
||||
return None
|
||||
|
||||
@staticmethod
|
||||
async def get_by_post_id(post_id: str) -> Optional[Lofter]:
|
||||
return await LofterPost.get_by_post_and_user_id("0", post_id)
|
||||
|
||||
@staticmethod
|
||||
async def add_post(post: Lofter):
|
||||
async with sqlite.Session() as session:
|
||||
|
Loading…
Reference in New Issue
Block a user