mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
afc31430e7
|
||
|
|
282cf46d58
|
||
|
|
6c53a1429d
|
||
|
|
ca9064a1b7
|
||
|
|
d58fd7cd46
|
||
|
|
9aa7aa1c36
|
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
FROM python:3.12-slim-bullseye
|
FROM python:3.13-slim-bullseye
|
||||||
|
|
||||||
LABEL maintainer="admin@yoursfunny.top"
|
LABEL maintainer="admin@yoursfunny.top"
|
||||||
|
|
||||||
|
|||||||
@@ -237,6 +237,12 @@ async def cmd_user_dict(update: Update, context: CustomContext) -> None:
|
|||||||
await update.effective_message.reply_text(html.escape(str(context.chat_data)), disable_web_page_preview=True)
|
await update.effective_message.reply_text(html.escape(str(context.chat_data)), disable_web_page_preview=True)
|
||||||
|
|
||||||
|
|
||||||
|
@send_action(ChatAction.TYPING)
|
||||||
|
async def cmd_clear_edit_message(update: Update, context: CustomContext) -> None:
|
||||||
|
context.chat_data.edit_message.clear()
|
||||||
|
await update.effective_message.reply_text("Edit message cleared.")
|
||||||
|
|
||||||
|
|
||||||
async def post_init(application: Application) -> None:
|
async def post_init(application: Application) -> None:
|
||||||
# commands = [
|
# commands = [
|
||||||
# BotCommand('start', CMD_START),
|
# BotCommand('start', CMD_START),
|
||||||
@@ -291,6 +297,7 @@ def main():
|
|||||||
CallbackQueryHandler(query_forward_message, pattern="forward"),
|
CallbackQueryHandler(query_forward_message, pattern="forward"),
|
||||||
CallbackQueryHandler(query_template, pattern=r"^template\|"),
|
CallbackQueryHandler(query_template, pattern=r"^template\|"),
|
||||||
CommandHandler("bot_dict", cmd_user_dict),
|
CommandHandler("bot_dict", cmd_user_dict),
|
||||||
|
CommandHandler("clear_edit_message", cmd_clear_edit_message),
|
||||||
]
|
]
|
||||||
|
|
||||||
application.add_handlers(handlers)
|
application.add_handlers(handlers)
|
||||||
|
|||||||
+2
-2
@@ -1,4 +1,4 @@
|
|||||||
python-telegram-bot[webhooks]~=21.6
|
python-telegram-bot[webhooks]~=21.7
|
||||||
httpx[http2]~=0.27
|
httpx[http2]~=0.27
|
||||||
uvloop~=0.19.0; sys_platform != 'win32'
|
uvloop~=0.21; sys_platform != 'win32'
|
||||||
async-pixiv @ git+https://github.com/TheFunny/async-pixiv@main
|
async-pixiv @ git+https://github.com/TheFunny/async-pixiv@main
|
||||||
+10
-2
@@ -11,6 +11,7 @@ if TYPE_CHECKING:
|
|||||||
|
|
||||||
bsky_api_url = 'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread'
|
bsky_api_url = 'https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread'
|
||||||
|
|
||||||
|
SENSITIVE_TAG = {'sexual', 'nudity', 'porn', 'graphic-media'}
|
||||||
|
|
||||||
class BskyMedia:
|
class BskyMedia:
|
||||||
__slots__ = ('_url', '_thumb', '_type', '__dict__')
|
__slots__ = ('_url', '_thumb', '_type', '__dict__')
|
||||||
@@ -101,7 +102,7 @@ class ProcessBsky:
|
|||||||
author_id=self._bsky['author']['handle'],
|
author_id=self._bsky['author']['handle'],
|
||||||
text=self._bsky['record']['text'],
|
text=self._bsky['record']['text'],
|
||||||
media=self._bsky_media,
|
media=self._bsky_media,
|
||||||
sensitive=False # TODO: implement sensitive
|
sensitive=self._sensitive
|
||||||
)
|
)
|
||||||
|
|
||||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||||
@@ -151,4 +152,11 @@ class ProcessBsky:
|
|||||||
)
|
)
|
||||||
]
|
]
|
||||||
case _:
|
case _:
|
||||||
raise NotImplementedError(f"Unknown Bsky embed type: {embed['type']}")
|
raise NotImplementedError(f"Unknown Bsky embed type: {embed['$type']}")
|
||||||
|
|
||||||
|
@property
|
||||||
|
def _sensitive(self) -> bool:
|
||||||
|
return any(
|
||||||
|
tag in self._bsky['labels']
|
||||||
|
for tag in SENSITIVE_TAG
|
||||||
|
)
|
||||||
|
|||||||
+9
-8
@@ -258,14 +258,15 @@ class TelegramBsky:
|
|||||||
# )
|
# )
|
||||||
yield
|
yield
|
||||||
elif bsky_media.type == "external":
|
elif bsky_media.type == "external":
|
||||||
yield InlineQueryResultVideo(
|
# yield InlineQueryResultVideo(
|
||||||
id=str(uuid4()),
|
# id=str(uuid4()),
|
||||||
video_url=bsky_media.url,
|
# video_url=bsky_media.url,
|
||||||
mime_type="image/gif",
|
# mime_type="image/gif",
|
||||||
thumbnail_url=bsky_media.thumb,
|
# thumbnail_url=bsky_media.thumb,
|
||||||
title=bsky.text,
|
# title=bsky.text,
|
||||||
caption=self.message_text
|
# caption=self.message_text
|
||||||
)
|
# )
|
||||||
|
yield
|
||||||
|
|
||||||
def message_media_generator(self) -> Generator[TypeMessageMediaResult, None, None]:
|
def message_media_generator(self) -> Generator[TypeMessageMediaResult, None, None]:
|
||||||
bsky = self._bsky
|
bsky = self._bsky
|
||||||
|
|||||||
+1
-1
@@ -136,7 +136,7 @@ class ProcessTweet:
|
|||||||
@property
|
@property
|
||||||
def _tweet_text(self) -> str:
|
def _tweet_text(self) -> str:
|
||||||
match = x_tco_url.search(self._tweet['text'])
|
match = x_tco_url.search(self._tweet['text'])
|
||||||
return self._tweet['text'][:match.start()].strip(" ") if match else self._tweet['text']
|
return self._tweet['text'][:match.start()].strip() if match else self._tweet['text']
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def _tweet_media(self) -> list[TweetMedia]:
|
def _tweet_media(self) -> list[TweetMedia]:
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ class BskyPost(TypedDict):
|
|||||||
author: BskyAuthor
|
author: BskyAuthor
|
||||||
record: BskyPostRecord
|
record: BskyPostRecord
|
||||||
embed: BskyEmbedImages | BskyEmbedVideo | BskyEmbedExternal
|
embed: BskyEmbedImages | BskyEmbedVideo | BskyEmbedExternal
|
||||||
|
labels: list[BskyLabel]
|
||||||
|
|
||||||
|
|
||||||
class BskyAuthor(TypedDict):
|
class BskyAuthor(TypedDict):
|
||||||
@@ -42,6 +43,10 @@ class BskyPostRecord(TypedDict):
|
|||||||
text: str
|
text: str
|
||||||
|
|
||||||
|
|
||||||
|
class BskyLabel(TypedDict):
|
||||||
|
val: str
|
||||||
|
|
||||||
|
|
||||||
class BskyEmbedImage(TypedDict):
|
class BskyEmbedImage(TypedDict):
|
||||||
thumb: str
|
thumb: str
|
||||||
fullsize: str
|
fullsize: str
|
||||||
|
|||||||
Reference in New Issue
Block a user