X Tutup
Skip to content

Commit fd17077

Browse files
committed
Merge pull request python-telegram-bot#198 from rahiel/master
lazily load Updater & move extended classes to submodule
2 parents 45a4689 + d1516f6 commit fd17077

File tree

8 files changed

+49
-18
lines changed

8 files changed

+49
-18
lines changed

telegram/__init__.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,24 @@
4949
InlineQueryResultMpeg4Gif, InlineQueryResultPhoto, InlineQueryResultVideo
5050
from .update import Update
5151
from .bot import Bot
52-
from .dispatcher import Dispatcher
53-
from .jobqueue import JobQueue
54-
from .updatequeue import UpdateQueue
55-
from .updater import Updater
52+
53+
54+
def Updater(*args, **kwargs):
55+
"""Load the updater module on invocation and return an Updater instance."""
56+
import warnings
57+
warnings.warn("telegram.Updater is being deprecated, please use "
58+
"telegram.ext.Updater from now on.")
59+
from .ext.updater import Updater as Up
60+
return Up(*args, **kwargs)
5661

5762

5863
__author__ = 'devs@python-telegram-bot.org'
5964
__version__ = '3.3'
60-
__all__ = ('Bot', 'Updater', 'Dispatcher', 'Emoji', 'TelegramError',
61-
'InputFile', 'ReplyMarkup', 'ForceReply', 'ReplyKeyboardHide',
62-
'ReplyKeyboardMarkup', 'UserProfilePhotos', 'ChatAction',
63-
'Location', 'Contact', 'Video', 'Sticker', 'Document', 'File',
64-
'Audio', 'PhotoSize', 'Chat', 'Update', 'ParseMode', 'Message',
65-
'User', 'TelegramObject', 'NullHandler', 'Voice', 'JobQueue',
66-
'InlineQuery', 'ChosenInlineResult', 'InlineQueryResultArticle',
65+
__all__ = ('Audio', 'Bot', 'Chat', 'Emoji', 'TelegramError', 'InputFile',
66+
'Contact', 'ForceReply', 'ReplyKeyboardHide', 'ReplyKeyboardMarkup',
67+
'UserProfilePhotos', 'ChatAction', 'Location', 'Video', 'Document',
68+
'Sticker', 'File', 'PhotoSize', 'Update', 'ParseMode', 'Message',
69+
'User', 'TelegramObject', 'NullHandler', 'Voice', 'InlineQuery',
70+
'ReplyMarkup', 'ChosenInlineResult', 'InlineQueryResultArticle',
6771
'InlineQueryResultGif', 'InlineQueryResultPhoto',
68-
'InlineQueryResultMpeg4Gif', 'InlineQueryResultVideo',
69-
'UpdateQueue')
72+
'InlineQueryResultMpeg4Gif', 'InlineQueryResultVideo')

telegram/ext/__init__.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/usr/bin/env python
2+
#
3+
# A library that provides a Python interface to the Telegram Bot API
4+
# Copyright (C) 2015-2016
5+
# Leandro Toledo de Souza <devs@python-telegram-bot.org>
6+
#
7+
# This program is free software: you can redistribute it and/or modify
8+
# it under the terms of the GNU Lesser Public License as published by
9+
# the Free Software Foundation, either version 3 of the License, or
10+
# (at your option) any later version.
11+
#
12+
# This program is distributed in the hope that it will be useful,
13+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15+
# GNU Lesser Public License for more details.
16+
#
17+
# You should have received a copy of the GNU Lesser Public License
18+
# along with this program. If not, see [http://www.gnu.org/licenses/].
19+
20+
"""Extensions over the Telegram Bot API to facilitate bot making"""
21+
22+
from .dispatcher import Dispatcher
23+
from .jobqueue import JobQueue
24+
from .updatequeue import UpdateQueue
25+
from .updater import Updater
26+
27+
28+
__all__ = ('Dispatcher', 'JobQueue', 'UpdateQueue', 'Updater')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from time import sleep
2828

2929
from telegram import (TelegramError, Update, NullHandler)
30-
from telegram.updatequeue import Empty
30+
from telegram.ext.updatequeue import Empty
3131

3232
H = NullHandler()
3333
logging.getLogger(__name__).addHandler(H)
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
from time import sleep
2929
import subprocess
3030
from signal import signal, SIGINT, SIGTERM, SIGABRT
31-
from telegram import (Bot, TelegramError, dispatcher, Dispatcher,
32-
NullHandler, JobQueue, UpdateQueue)
31+
from telegram import Bot, TelegramError, NullHandler
32+
from telegram.ext import dispatcher, Dispatcher, JobQueue, UpdateQueue
3333
from telegram.utils.webhookhandler import (WebhookServer, WebhookHandler)
3434

3535
H = NullHandler()

tests/test_jobqueue.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@
3737

3838
sys.path.append('.')
3939

40-
from telegram import JobQueue, Updater
40+
from telegram.ext import JobQueue, Updater
4141
from tests.base import BaseTest
4242

4343
# Enable logging

tests/test_updater.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
sys.path.append('.')
4949

5050
from telegram import Update, Message, TelegramError, User, Chat, Updater, Bot
51-
from telegram.dispatcher import run_async
51+
from telegram.ext.dispatcher import run_async
5252
from tests.base import BaseTest
5353
from threading import Lock, Thread
5454

0 commit comments

Comments
 (0)
X Tutup