[SVN] release 0.3.3
[UPD] [BREAK] config update; please, see example `media_external_formats` [ADD] possibility to upload media (supported formats — in config) with external links; compliant with XEP-0363 HTTP Upload
This commit is contained in:
@@ -1,3 +1,3 @@
|
||||
from xmpp_tg.xmpp import XMPPTelegram
|
||||
|
||||
__version__ = '0.3.2'
|
||||
__version__ = '0.3.3'
|
||||
|
||||
@@ -10,7 +10,7 @@ import sleekxmpp
|
||||
from sleekxmpp.componentxmpp import ComponentXMPP
|
||||
import xml.etree.ElementTree as ET
|
||||
|
||||
from telethon.tl.functions.messages import GetDialogsRequest, SendMessageRequest, ImportChatInviteRequest, GetFullChatRequest, AddChatUserRequest, DeleteChatUserRequest, CreateChatRequest, DeleteHistoryRequest
|
||||
from telethon.tl.functions.messages import GetDialogsRequest, SendMessageRequest, SendMediaRequest, ImportChatInviteRequest, GetFullChatRequest, AddChatUserRequest, DeleteChatUserRequest, CreateChatRequest, DeleteHistoryRequest
|
||||
from telethon.tl.functions.account import UpdateStatusRequest, GetAuthorizationsRequest, UpdateProfileRequest, UpdateUsernameRequest
|
||||
from telethon.tl.functions.contacts import DeleteContactRequest, BlockRequest, UnblockRequest, ImportContactsRequest
|
||||
from telethon.tl.functions.channels import JoinChannelRequest, LeaveChannelRequest, InviteToChannelRequest, EditBannedRequest, CreateChannelRequest
|
||||
@@ -21,6 +21,7 @@ from telethon.tl.types import PeerChannel, PeerChat, PeerUser, Chat, ChatForbidd
|
||||
from telethon.tl.types import UserStatusOnline, UserStatusRecently, UserStatusOffline
|
||||
from telethon.tl.types import Updates, UpdateShortSentMessage, UpdateMessageID
|
||||
from telethon.tl.types import ChannelBannedRights
|
||||
from telethon.tl.types import InputMediaPhotoExternal
|
||||
from telethon.tl.types.messages import Dialogs, DialogsSlice
|
||||
|
||||
from telethon.helpers import generate_random_long
|
||||
@@ -145,10 +146,16 @@ class XMPPTelegram(ComponentXMPP):
|
||||
tg_peer = InputPeerChannel(tg_id, self.tg_dialogs[jid]['supergroups'][tg_id].access_hash)
|
||||
|
||||
if tg_peer:
|
||||
# Отправляем сообщение и получаем новый апдейт
|
||||
result = self.tg_connections[jid].invoke(
|
||||
SendMessageRequest(tg_peer, msg, generate_random_long(), reply_to_msg_id=reply_mid)
|
||||
)
|
||||
# detect media
|
||||
if msg.startswith('http') and re.match(r'(?:http\:|https\:)?\/\/.*\.(?:' + self.config['media_external_formats'] + ')', msg):
|
||||
urls = re.findall(r'(?:http\:|https\:)?\/\/.*\.(?:' + self.config['media_external_formats'] + ')', msg)
|
||||
message = msg.replace(urls[0], '')
|
||||
media = InputMediaPhotoExternal(urls[0])
|
||||
result = self.tg_connections[jid].invoke(SendMediaRequest(tg_peer, media, message, random_id = generate_random_long(), reply_to_msg_id = reply_mid))
|
||||
# no media — plain message #
|
||||
else:
|
||||
result = self.tg_connections[jid].invoke(SendMessageRequest(tg_peer, msg, generate_random_long(), reply_to_msg_id=reply_mid))
|
||||
|
||||
msg_id = None
|
||||
|
||||
# Ищем ID отправленного сообщения
|
||||
|
||||
Reference in New Issue
Block a user