Added full* markdown support and updated README

* Although the markdown parser works perfectly,
the official Telegram client does not fully reflect it.
However, if you still think that this is a lie, go check
the markdown parser and test it yourself!
This commit is contained in:
Lonami
2016-09-07 19:32:18 +02:00
parent 81e8ae5bea
commit 7abe53e063
6 changed files with 187 additions and 21 deletions
+10 -5
View File
@@ -1,9 +1,14 @@
import os
# Only import most stuff if the TLObjects were generated
# Only import most stuff if the TLObjects were generated and there were no errors
if os.path.isfile('tl/all_tlobjects.py'):
from .all_tlobjects import tlobjects
from .session import Session
from .mtproto_request import MTProtoRequest
from .telegram_client import TelegramClient
try:
from .all_tlobjects import tlobjects
from .session import Session
from .mtproto_request import MTProtoRequest
from .telegram_client import TelegramClient
except Exception:
print('Please fix `tl_generator.py` and run it again')
else:
print('Please run `python3 tl_generator.py` first')
del os
from .tlobject import TLObject, TLArg
+12 -3
View File
@@ -1,7 +1,7 @@
# This file is based on TLSharp
# https://github.com/sochix/TLSharp/blob/master/TLSharp.Core/TelegramClient.cs
import platform
import datetime
from parser.markdown_parser import parse_message_entities
import utils
import network.authenticator
@@ -149,9 +149,18 @@ class TelegramClient:
TelegramClient.find_input_peer_name(dialog.peer, result.users, result.chats))
for dialog in result.dialogs]
def send_message(self, input_peer, message):
def send_message(self, input_peer, message, markdown=False, no_web_page=False):
"""Sends a message to the given input peer"""
request = SendMessageRequest(input_peer, message, utils.generate_random_long())
if markdown:
msg, entities = parse_message_entities(message)
else:
msg, entities = message, []
request = SendMessageRequest(peer=input_peer,
message=msg,
random_id=utils.generate_random_long(),
entities=entities,
no_webpage=no_web_page)
self.sender.send(request)
self.sender.receive(request)