Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

shift to ptb v20 #79

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
926 changes: 423 additions & 503 deletions poetry.lock

Large diffs are not rendered by default.

9 changes: 5 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,19 @@ authors = ["ksdfg <ksdfg123@gmail.com>"]
license = "GPL-3.0"

[tool.poetry.dependencies]
python = "3.10.8"
python = "^3.11"
dnspython = "^2.2.1"
emoji = "1.6.1"
mongoengine = "^0.24.2"
Pillow = "^9.2.0"
python-decouple = "^3.6"
python-telegram-bot = "^13.14"
python-telegram-bot = "^20.0"
spongemock = "^0.3.4"
zalgo-text = "^0.6"
hentai = "^3.2.10"
telegraph = "^2.1.0"
pydantic = {extras = ["dotenv"], version = "^1.10.2"}
pydantic = { extras = ["dotenv"], version = "^1.10.2" }
emoji = "^2.5.1"
pytz = "^2023.3"

[tool.poetry.group.dev.dependencies]
black = "^22.8.0"
Expand Down
7 changes: 3 additions & 4 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from pydantic import HttpUrl, BaseSettings
from telegram.ext import Updater
from telegram.ext import Application


# class for configuration of a bot
Expand Down Expand Up @@ -29,6 +29,5 @@ class Config:
# create config object
config = Config()

# create updater and dispatcher
updater = Updater(config.TOKEN, use_context=True)
dispatcher = updater.dispatcher
# create updater and application
application = Application.builder().token(config.TOKEN).build()
16 changes: 10 additions & 6 deletions telebot/__main__.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,31 @@
import asyncio

from mongoengine import connect

from telebot import updater, config
from telebot import config, application
from telebot.modules import imported_mods, bot_commands

# log all imported modules
print("Imported modules :", ", ".join(sorted(mod.__mod_name__ for mod in imported_mods.values())))

if __name__ == "__main__":
loop = asyncio.get_event_loop()

# set bot commands to be displayed
print("Commands set :", *(cmd.command for cmd in bot_commands))
updater.bot.set_my_commands(bot_commands)
loop.run_until_complete(application.bot.set_my_commands(bot_commands))

# connect to database
connect(config.DATABASE_NAME, "default", host=config.DATABASE_URL)

# start bot
if config.WEBHOOK_URL:
updater.bot.delete_webhook() # in case there's one up
updater.start_webhook(
loop.run_until_complete(application.bot.delete_webhook()) # in case there's one up
application.run_webhook(
listen="0.0.0.0", port=config.PORT, url_path=config.TOKEN, webhook_url=config.WEBHOOK_URL + config.TOKEN
)
else:
updater.start_polling()
application.run_polling()

print("neko chan go nyan nyan")
updater.idle()
application.idle()
Loading