mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Add editMessageText.
This commit is contained in:
parent
4dc7af71a0
commit
13327c371a
@ -460,6 +460,11 @@ class TeleBot:
|
||||
def answer_callback_query(self, callback_query_id, text=None, show_alert=None):
|
||||
return apihelper.answer_callback_query(self.token, callback_query_id, text, show_alert)
|
||||
|
||||
def edit_message_text(self, chat_id, text, message_id=None, inline_message_id=None, parse_mode=None,
|
||||
disable_web_page_preview=None, reply_markup=None):
|
||||
return types.Message.de_json(apihelper.edit_message_text(self.token, chat_id, text, message_id, inline_message_id, parse_mode,
|
||||
disable_web_page_preview, reply_markup))
|
||||
|
||||
def reply_to(self, message, text, **kwargs):
|
||||
"""
|
||||
Convenience function for `send_message(message.chat.id, text, reply_to_message_id=message.message_id, **kwargs)`
|
||||
|
@ -311,6 +311,27 @@ def unban_chat_member(token, chat_id, user_id):
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
|
||||
# Updating messages
|
||||
|
||||
def edit_message_text(token, chat_id, text, message_id=None, inline_message_id=None, parse_mode=None,
|
||||
disable_web_page_preview=None, reply_markup=None):
|
||||
method_url = r'editMessageText'
|
||||
payload = {'chat_id': chat_id, 'text': text}
|
||||
if message_id:
|
||||
payload['message_id'] = message_id
|
||||
if inline_message_id:
|
||||
payload['inline_message_id'] = inline_message_id
|
||||
if parse_mode:
|
||||
payload['parse_mode'] = parse_mode
|
||||
if disable_web_page_preview:
|
||||
payload['disable_web_page_preview'] = disable_web_page_preview
|
||||
if reply_markup:
|
||||
payload['reply_markup'] = _convert_markup(reply_markup)
|
||||
return _make_request(token, method_url, params=payload)
|
||||
|
||||
|
||||
# InlineQuery
|
||||
|
||||
def answer_callback_query(token, callback_query_id, text=None, show_alert=None):
|
||||
method_url = 'answerCallbackQuery'
|
||||
payload = {'callback_query_id': callback_query_id}
|
||||
|
@ -315,7 +315,7 @@ class TestTeleBot:
|
||||
tb = telebot.TeleBot(TOKEN)
|
||||
lat = 26.3875591
|
||||
lon = -161.2901042
|
||||
ret_msg = tb.send_venue(CHAT_ID, lat, lon, "Test Venue", "1123 Test Venue address",disable_notification=True)
|
||||
ret_msg = tb.send_venue(CHAT_ID, lat, lon, "Test Venue", "1123 Test Venue address", disable_notification=True)
|
||||
assert ret_msg.venue.title == "Test Venue"
|
||||
|
||||
def test_Chat(self):
|
||||
@ -325,6 +325,12 @@ class TestTeleBot:
|
||||
assert me.id == msg.from_user.id
|
||||
assert msg.chat.id == int(CHAT_ID)
|
||||
|
||||
def test_edit_message_text(self):
|
||||
tb = telebot.TeleBot(TOKEN)
|
||||
msg = tb.send_message(CHAT_ID, 'Test')
|
||||
new_msg = tb.edit_message_text(CHAT_ID, 'Edit test', message_id=msg.message_id)
|
||||
assert new_msg.text == 'Edit test'
|
||||
|
||||
def create_text_message(self, text):
|
||||
params = {'text': text}
|
||||
chat = types.User(11, 'test')
|
||||
|
Loading…
Reference in New Issue
Block a user