mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
566c17a855
|
||
|
|
87f0d16028
|
||
|
|
197993e522
|
||
|
|
02abcd899e
|
||
|
|
ebb48d2bb5
|
@@ -17,7 +17,7 @@ from utils.pixiv import ProcessPixiv
|
|||||||
from utils.telegram import Telegram
|
from utils.telegram import Telegram
|
||||||
|
|
||||||
if TYPE_CHECKING:
|
if TYPE_CHECKING:
|
||||||
from telegram import Chat, Message, Update
|
from telegram import Message, Update
|
||||||
from telegram.ext import Application, ContextTypes
|
from telegram.ext import Application, ContextTypes
|
||||||
|
|
||||||
logger = get_logger(__name__)
|
logger = get_logger(__name__)
|
||||||
@@ -141,7 +141,7 @@ async def cmd_set_forward_channel(update: Update, context: ContextTypes.DEFAULT_
|
|||||||
return
|
return
|
||||||
channel = context.args[0]
|
channel = context.args[0]
|
||||||
try:
|
try:
|
||||||
channel: Chat = await context.bot.get_chat(channel)
|
channel = await context.bot.get_chat(channel)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await update.effective_message.reply_text(str(e))
|
await update.effective_message.reply_text(str(e))
|
||||||
return
|
return
|
||||||
@@ -153,6 +153,11 @@ async def cmd_set_forward_channel(update: Update, context: ContextTypes.DEFAULT_
|
|||||||
except Exception as e:
|
except Exception as e:
|
||||||
await update.effective_message.reply_text(str(e) + "\nPlease add the bot to the channel and set as admin")
|
await update.effective_message.reply_text(str(e) + "\nPlease add the bot to the channel and set as admin")
|
||||||
return
|
return
|
||||||
|
user = filter(lambda x: x.user.id == update.effective_user.id, channel_admin)
|
||||||
|
user = next(user, None)
|
||||||
|
if not user:
|
||||||
|
await update.effective_message.reply_text("You are not an admin of the channel.")
|
||||||
|
return
|
||||||
user_bot = filter(lambda x: x.user.id == context.bot.id, channel_admin)
|
user_bot = filter(lambda x: x.user.id == context.bot.id, channel_admin)
|
||||||
user_bot = next(user_bot, None)
|
user_bot = next(user_bot, None)
|
||||||
if user_bot.can_post_messages:
|
if user_bot.can_post_messages:
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
python-telegram-bot[webhooks]~=21.3
|
python-telegram-bot[webhooks]~=21.4
|
||||||
httpx[http2]~=0.27
|
httpx[http2]~=0.27
|
||||||
uvloop~=0.19.0; sys_platform != 'win32'
|
uvloop~=0.19.0; sys_platform != 'win32'
|
||||||
async-pixiv @ git+https://github.com/TheFunny/async-pixiv@main
|
async-pixiv @ git+https://github.com/TheFunny/async-pixiv@main
|
||||||
+2
-1
@@ -165,8 +165,9 @@ class TelegramPixiv:
|
|||||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
@property
|
||||||
def url(self) -> str:
|
def url(self) -> str:
|
||||||
return self._url
|
return self._pixiv.url
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def message_text(self) -> str:
|
def message_text(self) -> str:
|
||||||
|
|||||||
+3
-3
@@ -1,8 +1,8 @@
|
|||||||
import re
|
import re
|
||||||
|
|
||||||
x_url = re.compile(r"^(?:https?://)?(?:www\.|mobile\.)?(?:x|twitter|fixvx|vxtwitter)\.com/(.+)/status/(\d+)")
|
x_url = re.compile(r"^(?:https?://)?(?:www\.|mobile\.)?(?:x|twitter|fixvx|vxtwitter)\.com/(.+)/status/(\d+)")
|
||||||
x_media_url = re.compile(r"^(?:https?://)(pbs|video)\.twimg\.com/(.*)")
|
x_media_url = re.compile(r"^(?:https?://)?(pbs|video)\.twimg\.com/(.*)")
|
||||||
x_tco_url = re.compile(r"(?:https?://)t\.co/.+$", re.M)
|
x_tco_url = re.compile(r"(?:https?://)?t\.co/.+$", re.M)
|
||||||
message_url = re.compile(r"\[.+]", re.S)
|
message_url = re.compile(r"\[.+]", re.S)
|
||||||
|
|
||||||
pixiv_url = re.compile(r"^(?:https?://)?(?:www\.)?pixiv\.net/(?:en/)?artworks/(\d+)")
|
pixiv_url = re.compile(r"^(?:https?://)?(?:www\.)?pixiv\.net/(?:en/)?(?:artworks/|i/)(\d+)")
|
||||||
|
|||||||
+1
-1
@@ -18,7 +18,7 @@ class Telegram:
|
|||||||
async with TelegramPixiv(self._url) as pixiv:
|
async with TelegramPixiv(self._url) as pixiv:
|
||||||
return pixiv
|
return pixiv
|
||||||
else:
|
else:
|
||||||
return None
|
return None # TODO add raise and catch
|
||||||
|
|
||||||
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
async def __aexit__(self, exc_type, exc_val, exc_tb):
|
||||||
pass
|
pass
|
||||||
|
|||||||
Reference in New Issue
Block a user