mirror of
https://github.com/eternnoir/pyTelegramBotAPI.git
synced 2023-08-10 21:12:57 +03:00
Merge pull request #815 from bedilbek/remove-type-hinting
Remove type hinting for python 3.5 compatibility
This commit is contained in:
commit
c2590ab5ed
@ -205,7 +205,6 @@ class TeleBot:
|
|||||||
:param filename: Filename of the file where handlers was saved
|
:param filename: Filename of the file where handlers was saved
|
||||||
:param del_file_after_loading: Is passed True, after loading save file will be deleted
|
:param del_file_after_loading: Is passed True, after loading save file will be deleted
|
||||||
"""
|
"""
|
||||||
self.next_step_backend: FileHandlerBackend
|
|
||||||
self.next_step_backend.load_handlers(filename, del_file_after_loading)
|
self.next_step_backend.load_handlers(filename, del_file_after_loading)
|
||||||
|
|
||||||
def load_reply_handlers(self, filename="./.handler-saves/reply.save", del_file_after_loading=True):
|
def load_reply_handlers(self, filename="./.handler-saves/reply.save", del_file_after_loading=True):
|
||||||
@ -221,7 +220,6 @@ class TeleBot:
|
|||||||
:param filename: Filename of the file where handlers was saved
|
:param filename: Filename of the file where handlers was saved
|
||||||
:param del_file_after_loading: Is passed True, after loading save file will be deleted
|
:param del_file_after_loading: Is passed True, after loading save file will be deleted
|
||||||
"""
|
"""
|
||||||
self.reply_backend: FileHandlerBackend
|
|
||||||
self.reply_backend.load_handlers(filename, del_file_after_loading)
|
self.reply_backend.load_handlers(filename, del_file_after_loading)
|
||||||
|
|
||||||
def set_webhook(self, url=None, certificate=None, max_connections=None, allowed_updates=None):
|
def set_webhook(self, url=None, certificate=None, max_connections=None, allowed_updates=None):
|
||||||
|
@ -5,7 +5,7 @@ import threading
|
|||||||
from telebot import apihelper
|
from telebot import apihelper
|
||||||
|
|
||||||
|
|
||||||
class HandlerBackend:
|
class HandlerBackend(object):
|
||||||
"""
|
"""
|
||||||
Class for saving (next step|reply) handlers
|
Class for saving (next step|reply) handlers
|
||||||
"""
|
"""
|
||||||
@ -40,7 +40,7 @@ class MemoryHandlerBackend(HandlerBackend):
|
|||||||
|
|
||||||
class FileHandlerBackend(HandlerBackend):
|
class FileHandlerBackend(HandlerBackend):
|
||||||
def __init__(self, handlers=None, filename='./.handler-saves/handlers.save', delay=120):
|
def __init__(self, handlers=None, filename='./.handler-saves/handlers.save', delay=120):
|
||||||
super().__init__(handlers)
|
super(FileHandlerBackend, self).__init__(handlers)
|
||||||
self.filename = filename
|
self.filename = filename
|
||||||
self.delay = delay
|
self.delay = delay
|
||||||
self.timer = threading.Timer(delay, self.save_handlers)
|
self.timer = threading.Timer(delay, self.save_handlers)
|
||||||
@ -116,7 +116,7 @@ class FileHandlerBackend(HandlerBackend):
|
|||||||
|
|
||||||
class RedisHandlerBackend(HandlerBackend):
|
class RedisHandlerBackend(HandlerBackend):
|
||||||
def __init__(self, handlers=None, host='localhost', port=6379, db=0, prefix='telebot'):
|
def __init__(self, handlers=None, host='localhost', port=6379, db=0, prefix='telebot'):
|
||||||
super().__init__(handlers)
|
super(RedisHandlerBackend, self).__init__(handlers)
|
||||||
from redis import Redis
|
from redis import Redis
|
||||||
self.prefix = prefix
|
self.prefix = prefix
|
||||||
self.redis = Redis(host, port, db)
|
self.redis = Redis(host, port, db)
|
||||||
|
@ -10,7 +10,8 @@ import time
|
|||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
import telebot
|
import telebot
|
||||||
from telebot import types, MemoryHandlerBackend, FileHandlerBackend
|
from telebot import types
|
||||||
|
from telebot.handler_backends import MemoryHandlerBackend, FileHandlerBackend
|
||||||
|
|
||||||
if REDIS_TESTS:
|
if REDIS_TESTS:
|
||||||
from telebot.handler_backends import RedisHandlerBackend
|
from telebot.handler_backends import RedisHandlerBackend
|
||||||
@ -230,8 +231,8 @@ def test_file_handler_backend_clear_next_step_handler(telegram_bot, private_chat
|
|||||||
|
|
||||||
|
|
||||||
def test_redis_handler_backend_register_next_step_handler(telegram_bot, private_chat, update_type):
|
def test_redis_handler_backend_register_next_step_handler(telegram_bot, private_chat, update_type):
|
||||||
if not(REDIS_TESTS):
|
if not REDIS_TESTS:
|
||||||
return
|
pytest.skip('please install redis and configure redis server, then enable REDIS_TESTS')
|
||||||
|
|
||||||
telegram_bot.next_step_backend = RedisHandlerBackend(prefix='pyTelegramBotApi:step_backend1')
|
telegram_bot.next_step_backend = RedisHandlerBackend(prefix='pyTelegramBotApi:step_backend1')
|
||||||
|
|
||||||
@ -248,8 +249,8 @@ def test_redis_handler_backend_register_next_step_handler(telegram_bot, private_
|
|||||||
|
|
||||||
|
|
||||||
def test_redis_handler_backend_clear_next_step_handler(telegram_bot, private_chat, update_type):
|
def test_redis_handler_backend_clear_next_step_handler(telegram_bot, private_chat, update_type):
|
||||||
if not(REDIS_TESTS):
|
if not REDIS_TESTS:
|
||||||
return
|
pytest.skip('please install redis and configure redis server, then enable REDIS_TESTS')
|
||||||
|
|
||||||
telegram_bot.next_step_backend = RedisHandlerBackend(prefix='pyTelegramBotApi:step_backend2')
|
telegram_bot.next_step_backend = RedisHandlerBackend(prefix='pyTelegramBotApi:step_backend2')
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user