mirror of
https://github.com/python-telegram-bot/python-telegram-bot.git
synced 2026-06-19 07:35:19 +00:00
Handle Filepaths via the Pathlib Module (#2688)
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user