1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Refactor requests para change to dict.

This commit is contained in:
eternnoir 2015-06-26 15:19:05 +08:00
parent 518fed5bc1
commit b4691a2a3a

View File

@ -8,13 +8,12 @@ def send_message(token, chat_id, text, disable_web_page_preview=None, reply_to_m
api_url = telebot.API_URL
method_url = r'sendMessage'
request_url = api_url + 'bot' + token + '/' + method_url
paras = 'chat_id=' + str(chat_id) + '&text=' + text
payload = {'chat_id': str(chat_id), 'text': text}
if disable_web_page_preview:
paras = paras + '&disable_web_page_preview=' + disable_web_page_preview
payload['disable_web_page_preview'] = disable_web_page_preview
if reply_to_message_id:
paras = paras + '&reply_to_message_id=' + reply_to_message_id
payload['reply_to_message_id'] = reply_to_message_id
if reply_markup:
paras = paras + '&reply_markup=' + reply_markup
request_url = request_url + '?' + paras
req = requests.get(request_url)
payload['reply_markup'] = reply_markup
req = requests.get(request_url, params=payload)
return req.json()