mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
commit
ba2705dc82
@ -26,6 +26,7 @@
|
||||
* [Using web hooks](#using-web-hooks)
|
||||
* [Logging](#logging)
|
||||
* [Proxy](#proxy)
|
||||
* [New in library](#new-in-library)
|
||||
* [F.A.Q.](#faq)
|
||||
* [Bot 2.0](#bot-20)
|
||||
* [How can I distinguish a User and a GroupChat in message.chat?](#how-can-i-distinguish-a-user-and-a-groupchat-in-messagechat)
|
||||
@ -510,6 +511,10 @@ apihelper.proxy = {'https':'socks5://userproxy:password@proxy_address:port'}
|
||||
```
|
||||
|
||||
|
||||
## New in library
|
||||
|
||||
06.06.2019 - Добавленна поддержка опросов (Poll). Добавлены функции send_poll, stop_poll
|
||||
|
||||
## F.A.Q.
|
||||
|
||||
### Bot 2.0
|
||||
|
@ -1,40 +0,0 @@
|
||||
import os
|
||||
from telebot import logger, logging, types, TeleBot
|
||||
|
||||
try:
|
||||
TOKEN = os.environ['TOKEN']
|
||||
except:
|
||||
logger.error('Not variable \'TOKEN\' in environ')
|
||||
exit(1)
|
||||
|
||||
CHAT_ID = -1001405019571
|
||||
logger.setLevel(logging.DEBUG)
|
||||
|
||||
bot = TeleBot(TOKEN)
|
||||
|
||||
|
||||
@bot.message_handler(content_types=['poll'])
|
||||
def po(m):
|
||||
logger.debug('Give poll')
|
||||
bot.send_message(m.chat.id, 'Я тоже так умею!')
|
||||
m = bot.send_poll(m.chat.id, m.poll)
|
||||
print(m.chat.id, m.message_id)
|
||||
|
||||
|
||||
def test_send_poll():
|
||||
poll = types.Poll('Какой ты сегодня?')
|
||||
poll.add('Добрый')
|
||||
poll.add('Веселый')
|
||||
poll.add('Грустный')
|
||||
kb = types.InlineKeyboardMarkup()
|
||||
kb.add(types.InlineKeyboardButton('1', url='t.me/dr_forse'))
|
||||
result = bot.send_poll(CHAT_ID, poll, reply_to_message=60312, reply_markup=kb)
|
||||
assert result['poll']['question'] == 'Какой ты сегодня?'
|
||||
|
||||
|
||||
def test_stop_poll():
|
||||
res = bot.stop_poll(-1001405019571, 60370)
|
||||
|
||||
|
||||
test_stop_poll()
|
||||
bot.polling(none_stop=True, timeout=600)
|
Loading…
Reference in New Issue
Block a user