mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
send_poll revised to standart signature
This commit is contained in:
parent
ef81868ebc
commit
6e1cf24946
@ -2,7 +2,8 @@
|
||||
|
||||
<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.
|
||||
|
||||
[![Download Month](https://img.shields.io/pypi/v/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
||||
[![PyPi Package Version](https://img.shields.io/pypi/v/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
||||
[![Supported Python versions](https://img.shields.io/pypi/pyversions/pyTelegramBotAPI.svg)](https://pypi.python.org/pypi/pyTelegramBotAPI)
|
||||
[![Build Status](https://travis-ci.org/eternnoir/pyTelegramBotAPI.svg?branch=master)](https://travis-ci.org/eternnoir/pyTelegramBotAPI)
|
||||
|
||||
* [Getting started.](#getting-started)
|
||||
|
@ -1207,17 +1207,42 @@ class TeleBot:
|
||||
disable_notification, reply_to_message_id, reply_markup, provider_data)
|
||||
return types.Message.de_json(result)
|
||||
|
||||
def send_poll(self, chat_id, poll, explanation_parse_mode=None, disable_notifications=False, reply_to_message=None, reply_markup=None):
|
||||
def send_poll(
|
||||
self, chat_id,
|
||||
question, options,
|
||||
is_anonymous=None, type=None, allows_multiple_answers=None, correct_option_id=None,
|
||||
explanation=None, explanation_parse_mode=None, open_period=None, close_date=None, is_closed=None,
|
||||
disable_notifications=False, reply_to_message_id=None, reply_markup=None):
|
||||
"""
|
||||
Sends poll
|
||||
Send polls
|
||||
:param chat_id:
|
||||
:param poll:
|
||||
:param question:
|
||||
:param options:
|
||||
:param is_anonymous:
|
||||
:param type:
|
||||
:param allows_multiple_answers:
|
||||
:param correct_option_id:
|
||||
:param explanation:
|
||||
:param explanation_parse_mode:
|
||||
:param open_period:
|
||||
:param close_date:
|
||||
:param is_closed:
|
||||
:param disable_notifications:
|
||||
:param reply_to_message:
|
||||
:param reply_to_message_id:
|
||||
:param reply_markup:
|
||||
:return:
|
||||
"""
|
||||
return types.Message.de_json(apihelper.send_poll(self.token, chat_id, poll, explanation_parse_mode, disable_notifications, reply_to_message, reply_markup))
|
||||
|
||||
if isinstance(question, types.Poll):
|
||||
raise Exception("The send_poll signature was changed, please see send_poll function details.")
|
||||
|
||||
return types.Message.de_json(
|
||||
apihelper.send_poll(
|
||||
self.token, chat_id,
|
||||
question, options,
|
||||
is_anonymous, type, allows_multiple_answers, correct_option_id,
|
||||
explanation, explanation_parse_mode, open_period, close_date, is_closed,
|
||||
disable_notifications, reply_to_message_id, reply_markup))
|
||||
|
||||
def stop_poll(self, chat_id, message_id):
|
||||
"""
|
||||
|
@ -998,31 +998,36 @@ def delete_sticker_from_set(token, sticker):
|
||||
return _make_request(token, method_url, params=payload, method='post')
|
||||
|
||||
|
||||
def send_poll(token, chat_id, poll, explanation_parse_mode=None, disable_notifications=False, reply_to_message_id=None, reply_markup=None):
|
||||
def send_poll(
|
||||
token, chat_id,
|
||||
question, options,
|
||||
is_anonymous = None, type = None, allows_multiple_answers = None, correct_option_id = None,
|
||||
explanation = None, explanation_parse_mode=None, open_period = None, close_date = None, is_closed = None,
|
||||
disable_notifications=False, reply_to_message_id=None, reply_markup=None):
|
||||
method_url = r'sendPoll'
|
||||
payload = {
|
||||
'chat_id': str(chat_id),
|
||||
'question': poll.question,
|
||||
'options': _convert_list_json_serializable(poll.options)}
|
||||
'question': question,
|
||||
'options': _convert_list_json_serializable(options)}
|
||||
|
||||
if poll.is_anonymous is not None:
|
||||
payload['is_anonymous'] = poll.is_anonymous
|
||||
if poll.type is not None:
|
||||
payload['type'] = poll.type
|
||||
if poll.allows_multiple_answers is not None:
|
||||
payload['allows_multiple_answers'] = poll.allows_multiple_answers
|
||||
if poll.correct_option_id is not None:
|
||||
payload['correct_option_id'] = poll.correct_option_id
|
||||
if poll.explanation is not None:
|
||||
payload['explanation'] = poll.explanation
|
||||
if is_anonymous is not None:
|
||||
payload['is_anonymous'] = is_anonymous
|
||||
if type is not None:
|
||||
payload['type'] = type
|
||||
if allows_multiple_answers is not None:
|
||||
payload['allows_multiple_answers'] = allows_multiple_answers
|
||||
if correct_option_id is not None:
|
||||
payload['correct_option_id'] = correct_option_id
|
||||
if explanation is not None:
|
||||
payload['explanation'] = explanation
|
||||
if explanation_parse_mode is not None:
|
||||
payload['explanation_parse_mode'] = explanation_parse_mode
|
||||
if poll.open_period is not None:
|
||||
payload['open_period'] = poll.open_period
|
||||
if poll.close_date is not None:
|
||||
payload['close_date'] = poll.close_date
|
||||
if poll.is_closed is not None:
|
||||
payload['is_closed'] = poll.is_closed
|
||||
if open_period is not None:
|
||||
payload['open_period'] = open_period
|
||||
if close_date is not None:
|
||||
payload['close_date'] = close_date
|
||||
if is_closed is not None:
|
||||
payload['is_closed'] = is_closed
|
||||
|
||||
if disable_notifications:
|
||||
payload['disable_notification'] = disable_notifications
|
||||
|
@ -5,6 +5,8 @@ import string
|
||||
import sys
|
||||
import threading
|
||||
import traceback
|
||||
import warnings
|
||||
import functools
|
||||
|
||||
import six
|
||||
from six import string_types
|
||||
@ -259,3 +261,19 @@ def per_thread(key, construct_value, reset=False):
|
||||
|
||||
def generate_random_token():
|
||||
return ''.join(random.sample(string.ascii_letters, 16))
|
||||
|
||||
|
||||
def deprecated(func):
|
||||
"""This is a decorator which can be used to mark functions
|
||||
as deprecated. It will result in a warning being emitted
|
||||
when the function is used."""
|
||||
# https://stackoverflow.com/a/30253848/441814
|
||||
@functools.wraps(func)
|
||||
def new_func(*args, **kwargs):
|
||||
warnings.simplefilter('always', DeprecationWarning) # turn off filter
|
||||
warnings.warn("Call to deprecated function {}.".format(func.__name__),
|
||||
category=DeprecationWarning,
|
||||
stacklevel=2)
|
||||
warnings.simplefilter('default', DeprecationWarning) # reset filter
|
||||
return func(*args, **kwargs)
|
||||
return new_func
|
||||
|
Loading…
Reference in New Issue
Block a user