1
0
mirror of https://github.com/eternnoir/pyTelegramBotAPI.git synced 2023-08-10 21:12:57 +03:00

Code base cleanup

This commit is contained in:
Badiboy
2022-01-24 22:38:35 +03:00
parent 2e9947277a
commit 4166fb229e
16 changed files with 52 additions and 97 deletions

View File

@@ -9,7 +9,7 @@ import telebot
from telebot import types
# Initialize bot with your token
bot = telebot.TeleBot(TOKEN)
bot = telebot.TeleBot('TOKEN')
# The `users` variable is needed to contain chat ids that are either in the search or in the active dialog, like {chat_id, chat_id}
users = {}
@@ -47,7 +47,7 @@ def find(message: types.Message):
if message.chat.id not in users:
bot.send_message(message.chat.id, 'Finding...')
if freeid == None:
if freeid is None:
freeid = message.chat.id
else:
# Question:

View File

@@ -1,9 +1,8 @@
import telebot
from telebot import asyncio_filters
from telebot.async_telebot import AsyncTeleBot
# list of storages, you can use any storage
from telebot.asyncio_storage import StateRedisStorage,StateMemoryStorage,StatePickleStorage
from telebot.asyncio_storage import StateMemoryStorage
# new feature for states.
from telebot.asyncio_handler_backends import State, StatesGroup

View File

@@ -1,6 +1,5 @@
# Just a little example of middleware handlers
import telebot
from telebot.asyncio_handler_backends import BaseMiddleware
from telebot.async_telebot import AsyncTeleBot
from telebot.async_telebot import CancelUpdate

View File

@@ -4,7 +4,7 @@ from telebot import custom_filters
from telebot.handler_backends import State, StatesGroup #States
# States storage
from telebot.storage import StateRedisStorage, StatePickleStorage, StateMemoryStorage
from telebot.storage import StateMemoryStorage
# Beginning from version 4.4.0+, we support storages.

View File

@@ -18,7 +18,6 @@ def send_welcome(message):
def beep(chat_id) -> None:
"""Send the beep message."""
bot.send_message(chat_id, text='Beep!')
return schedule.CancelJob # Run a job once
@bot.message_handler(commands=['set'])

View File

@@ -5,6 +5,7 @@
# Documenation to Tornado: http://tornadoweb.org
import signal
from typing import Optional, Awaitable
import tornado.httpserver
import tornado.ioloop
@@ -33,12 +34,18 @@ bot = telebot.TeleBot(API_TOKEN)
class Root(tornado.web.RequestHandler):
def data_received(self, chunk: bytes) -> Optional[Awaitable[None]]:
pass
def get(self):
self.write("Hi! This is webhook example!")
self.finish()
class webhook_serv(tornado.web.RequestHandler):
class WebhookServ(tornado.web.RequestHandler):
def data_received(self, chunk: bytes) -> Optional[Awaitable[None]]:
pass
def get(self):
self.write("What are you doing here?")
self.finish()
@@ -93,7 +100,7 @@ tornado.options.parse_command_line()
signal.signal(signal.SIGINT, signal_handler)
application = tornado.web.Application([
(r"/", Root),
(r"/" + WEBHOOK_SECRET, webhook_serv)
(r"/" + WEBHOOK_SECRET, WebhookServ)
])
http_server = tornado.httpserver.HTTPServer(application, ssl_options={