Handle Filepaths via the Pathlib Module (#2688)

This commit is contained in:
eldbud
2021-10-05 20:50:11 +03:00
committed by Hinrich Mahler
parent 267d4e8191
commit 1edfa1504c
27 changed files with 328 additions and 306 deletions
+1 -1
View File
@@ -84,7 +84,7 @@ def handle_invalid_button(update: Update, context: CallbackContext) -> None:
def main() -> None:
"""Run the bot."""
# We use persistence to demonstrate how buttons can still work after the bot was restarted
persistence = PicklePersistence(filename='arbitrarycallbackdatabot.pickle')
persistence = PicklePersistence(filepath='arbitrarycallbackdatabot')
# Create the Updater and pass it your bot's token.
updater = Updater("TOKEN", persistence=persistence, arbitrary_callback_data=True)
+2 -2
View File
@@ -11,6 +11,7 @@ See https://git.io/fAvYd for how to use Telegram Passport properly with python-t
"""
import logging
from pathlib import Path
from telegram import Update
from telegram.ext import Updater, MessageHandler, Filters, CallbackContext
@@ -101,8 +102,7 @@ def msg(update: Update, context: CallbackContext) -> None:
def main() -> None:
"""Start the bot."""
# Create the Updater and pass it your token and private key
with open('private.key', 'rb') as private_key:
updater = Updater("TOKEN", private_key=private_key.read())
updater = Updater("TOKEN", private_key=Path('private.key').read_bytes())
# Get the dispatcher to register handlers
dispatcher = updater.dispatcher
+1 -1
View File
@@ -132,7 +132,7 @@ def done(update: Update, context: CallbackContext) -> int:
def main() -> None:
"""Run the bot."""
# Create the Updater and pass it your bot's token.
persistence = PicklePersistence(filename='conversationbot')
persistence = PicklePersistence(filepath='conversationbot')
updater = Updater("TOKEN", persistence=persistence)
# Get the dispatcher to register handlers