mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2025-01-03 09:49:21 +01:00
* drop Python 2.6 support (closes #245) * fix NullHandler import * README: explicitly mention Py3 and PyPy compatibility
This commit is contained in:
parent
e9c5ee7ad6
commit
00bba73673
47 changed files with 51 additions and 238 deletions
|
@ -1,6 +1,5 @@
|
|||
language: python
|
||||
python:
|
||||
- "2.6"
|
||||
- "2.7"
|
||||
- "3.3"
|
||||
- "3.4"
|
||||
|
@ -13,6 +12,6 @@ install:
|
|||
- pip install -r requirements-dev.txt
|
||||
script:
|
||||
- nosetests -v --with-flaky --no-flaky-report --with-coverage --cover-package=telegram/
|
||||
- 'if [ $TRAVIS_PYTHON_VERSION != 2.6 ] && [ $TRAVIS_PYTHON_VERSION != 3.3 ] && [ $TRAVIS_PYTHON_VERSION != pypy3 ]; then pre-commit run --all-files; fi'
|
||||
- 'if [ $TRAVIS_PYTHON_VERSION != 3.3 ] && [ $TRAVIS_PYTHON_VERSION != pypy3 ]; then pre-commit run --all-files; fi'
|
||||
after_success:
|
||||
coveralls
|
||||
|
|
|
@ -73,8 +73,7 @@ Introduction
|
|||
|
||||
This library provides a pure Python interface for the
|
||||
`Telegram Bot API <https://core.telegram.org/bots/api>`_.
|
||||
It works with Python versions from 2.6+ (**Note:** Support for 2.6 will be dropped at some point
|
||||
this year. 2.7 will still be supported).
|
||||
It's compatible with Python versions 2.7, 3.3+ and `PyPy <http://pypy.org/>`_.
|
||||
It also works with `Google App Engine <https://cloud.google.com/appengine>`_.
|
||||
|
||||
In addition to the pure API implementation, this library features a number of high-level classes to
|
||||
|
|
|
@ -2,7 +2,6 @@ flake8
|
|||
nose
|
||||
pep257
|
||||
pylint
|
||||
unittest2
|
||||
flaky
|
||||
yapf
|
||||
pre-commit
|
||||
|
|
1
setup.py
1
setup.py
|
@ -45,7 +45,6 @@ with codecs.open('README.rst', 'r', 'utf-8') as fd:
|
|||
'Topic :: Internet',
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 2',
|
||||
'Programming Language :: Python :: 2.6',
|
||||
'Programming Language :: Python :: 2.7',
|
||||
'Programming Language :: Python :: 3',
|
||||
'Programming Language :: Python :: 3.3',
|
||||
|
|
|
@ -43,7 +43,6 @@ from .forcereply import ForceReply
|
|||
from .error import TelegramError
|
||||
from .inputfile import InputFile
|
||||
from .file import File
|
||||
from .nullhandler import NullHandler
|
||||
from .emoji import Emoji
|
||||
from .parsemode import ParseMode
|
||||
from .messageentity import MessageEntity
|
||||
|
@ -101,14 +100,9 @@ __all__ = ['Audio', 'Bot', 'Chat', 'ChatMember', 'ChatAction', 'ChosenInlineResu
|
|||
'InlineQueryResultVenue', 'InlineQueryResultVideo', 'InlineQueryResultVoice',
|
||||
'InputContactMessageContent', 'InputFile', 'InputLocationMessageContent',
|
||||
'InputMessageContent', 'InputTextMessageContent', 'InputVenueMessageContent',
|
||||
'KeyboardButton', 'Location', 'Message', 'MessageEntity', 'NullHandler', 'ParseMode',
|
||||
'PhotoSize', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup', 'ReplyMarkup', 'Sticker',
|
||||
'TelegramError', 'TelegramObject', 'Update', 'User', 'UserProfilePhotos', 'Venue',
|
||||
'Video', 'Voice', 'MAX_MESSAGE_LENGTH', 'MAX_CAPTION_LENGTH', 'SUPPORTED_WEBHOOK_PORTS',
|
||||
'KeyboardButton', 'Location', 'Message', 'MessageEntity', 'ParseMode', 'PhotoSize',
|
||||
'ReplyKeyboardHide', 'ReplyKeyboardMarkup', 'ReplyMarkup', 'Sticker', 'TelegramError',
|
||||
'TelegramObject', 'Update', 'User', 'UserProfilePhotos', 'Venue', 'Video', 'Voice',
|
||||
'MAX_MESSAGE_LENGTH', 'MAX_CAPTION_LENGTH', 'SUPPORTED_WEBHOOK_PORTS',
|
||||
'MAX_FILESIZE_DOWNLOAD', 'MAX_FILESIZE_UPLOAD', 'MAX_MESSAGES_PER_SECOND_PER_CHAT',
|
||||
'MAX_MESSAGES_PER_SECOND', 'MAX_MESSAGES_PER_MINUTE_PER_GROUP']
|
||||
|
||||
if version_info < (2, 7):
|
||||
from warnings import warn
|
||||
warn("python-telegram-bot will stop supporting Python 2.6 in a future release. "
|
||||
"Please upgrade your Python version to at least Python 2.7!")
|
||||
|
|
|
@ -23,11 +23,11 @@ import functools
|
|||
import logging
|
||||
|
||||
from telegram import (User, Message, Update, Chat, ChatMember, UserProfilePhotos, File,
|
||||
ReplyMarkup, TelegramObject, NullHandler)
|
||||
ReplyMarkup, TelegramObject)
|
||||
from telegram.error import InvalidToken
|
||||
from telegram.utils import request
|
||||
|
||||
logging.getLogger(__name__).addHandler(NullHandler())
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
||||
|
||||
class Bot(TelegramObject):
|
||||
|
|
|
@ -1,11 +1,10 @@
|
|||
import logging
|
||||
from telegram import NullHandler
|
||||
|
||||
from future.moves.urllib.parse import quote
|
||||
from future.moves.urllib.error import HTTPError, URLError
|
||||
from future.moves.urllib.request import urlopen, Request
|
||||
|
||||
logging.getLogger(__name__).addHandler(NullHandler())
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
||||
|
||||
class Botan(object):
|
||||
|
|
|
@ -26,13 +26,13 @@ from queue import Queue, Empty
|
|||
|
||||
from future.builtins import range
|
||||
|
||||
from telegram import (TelegramError, NullHandler)
|
||||
from telegram import TelegramError
|
||||
from telegram.utils import request
|
||||
from telegram.ext.handler import Handler
|
||||
from telegram.utils.deprecate import deprecate
|
||||
from telegram.utils.promise import Promise
|
||||
|
||||
logging.getLogger(__name__).addHandler(NullHandler())
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
||||
ASYNC_QUEUE = Queue()
|
||||
ASYNC_THREADS = set()
|
||||
|
|
|
@ -28,12 +28,12 @@ import subprocess
|
|||
from signal import signal, SIGINT, SIGTERM, SIGABRT
|
||||
from queue import Queue
|
||||
|
||||
from telegram import Bot, TelegramError, NullHandler
|
||||
from telegram import Bot, TelegramError
|
||||
from telegram.ext import dispatcher, Dispatcher, JobQueue
|
||||
from telegram.error import Unauthorized, InvalidToken
|
||||
from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler)
|
||||
|
||||
logging.getLogger(__name__).addHandler(NullHandler())
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
||||
|
||||
class Updater(object):
|
||||
|
|
|
@ -1,32 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
#
|
||||
# A library that provides a Python interface to the Telegram Bot API
|
||||
# Copyright (C) 2015-2016
|
||||
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU Lesser Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU Lesser Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU Lesser Public License
|
||||
# along with this program. If not, see [http://www.gnu.org/licenses/].
|
||||
"""This module contains a object that represents a logging NullHandler."""
|
||||
|
||||
import logging
|
||||
|
||||
|
||||
class NullHandler(logging.Handler):
|
||||
"""This object represents a logging NullHandler."""
|
||||
|
||||
def emit(self, record):
|
||||
"""
|
||||
Args:
|
||||
record (str):
|
||||
"""
|
||||
pass
|
|
@ -1,6 +1,6 @@
|
|||
import logging
|
||||
|
||||
from telegram import Update, NullHandler
|
||||
from telegram import Update
|
||||
from future.utils import bytes_to_native_str
|
||||
from threading import Lock
|
||||
import json
|
||||
|
@ -9,7 +9,7 @@ try:
|
|||
except ImportError:
|
||||
import http.server as BaseHTTPServer
|
||||
|
||||
logging.getLogger(__name__).addHandler(NullHandler())
|
||||
logging.getLogger(__name__).addHandler(logging.NullHandler())
|
||||
|
||||
|
||||
class _InvalidPost(Exception):
|
||||
|
|
|
@ -23,14 +23,10 @@ import io
|
|||
import re
|
||||
from datetime import datetime
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from flaky import flaky
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
ChosenInlineResult"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
"""Test the Telegram constants."""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
|
||||
from flaky import flaky
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
import telegram
|
||||
|
|
|
@ -22,13 +22,9 @@ This module contains a object that represents Tests for ConversationHandler
|
|||
"""
|
||||
import logging
|
||||
import sys
|
||||
import unittest
|
||||
from time import sleep
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
|
||||
try:
|
||||
# python2
|
||||
from urllib2 import urlopen, Request, HTTPError
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
"""This module contains a object that represents Tests for Telegram InlineKeyboardButton"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQuery"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultArticle"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultAudio"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedAudio"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedDocument"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedGif"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedMpeg4Gif"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedPhoto"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedSticker"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedVideo"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultCachedVoice"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultContact"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultDocument"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultGif"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultLocation"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultMpeg4Gif"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultPhoto"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultVenue"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultVideo"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InlineQueryResultVoice"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InputContactMessageContent"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InputLocationMessageContent"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InputMessageContent"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InputTextMessageContent"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
InputVenueMessageContent"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -22,13 +22,9 @@ This module contains a object that represents Tests for JobQueue
|
|||
"""
|
||||
import logging
|
||||
import sys
|
||||
import unittest
|
||||
from time import sleep
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
from telegram.utils.request import stop_con_pool
|
||||
|
|
|
@ -21,11 +21,7 @@
|
|||
KeyboardButton"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
MessageEntity"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -20,11 +20,7 @@
|
|||
ReplyMarkup"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
|
@ -26,17 +26,13 @@ import signal
|
|||
import sys
|
||||
import os
|
||||
import re
|
||||
import unittest
|
||||
from datetime import datetime
|
||||
from time import sleep
|
||||
from random import randrange
|
||||
|
||||
from future.builtins import bytes
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
|
||||
try:
|
||||
# python2
|
||||
from urllib2 import urlopen, Request, HTTPError
|
||||
|
|
|
@ -19,11 +19,7 @@
|
|||
"""This module contains a object that represents Tests for Telegram Venue"""
|
||||
|
||||
import sys
|
||||
|
||||
if sys.version_info[0:2] == (2, 6):
|
||||
import unittest2 as unittest
|
||||
else:
|
||||
import unittest
|
||||
import unittest
|
||||
|
||||
sys.path.append('.')
|
||||
|
||||
|
|
Loading…
Reference in a new issue