-
Notifications
You must be signed in to change notification settings - Fork 47
fix: update contributions for PTB v20 #155
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
Open
xuu33030
wants to merge
2
commits into
python-telegram-bot:main
Choose a base branch
from
xuu33030:ptb-v20-compatibility
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| python-telegram-bot>=12.0 | ||
| python-telegram-bot~=20.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,56 +4,61 @@ Provides a `LongBotCommand` class that allows you to store a second, longer desc | |
| Example: | ||
|
|
||
| ```python | ||
| from typing import List | ||
|
|
||
| from telegram import Update | ||
| from telegram.ext import Updater, CommandHandler, CallbackContext | ||
| from ptbcontrib.longbotcommand import LongBotCommand | ||
| from telegram.ext import Application, CommandHandler, ContextTypes | ||
|
|
||
| updater = Updater("TOKEN", use_context=True) | ||
| dp = updater.dispatcher | ||
| from ptbcontrib.longbotcommand import LongBotCommand | ||
|
|
||
| lorem_text = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " | ||
| "incididunt ut labore et dolore magna aliqua." | ||
| lorem_text = ( | ||
| "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor " | ||
| "incididunt ut labore et dolore magna aliqua." | ||
| ) | ||
|
|
||
| lorem_desc = "Lorem Ipsum is simply dummy text of the printing and typesetting industry. " | ||
| "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an " | ||
| "unknown printer took a galley of type and scrambled it to make a type specimen book. " | ||
| "It has survived not only five centuries, but also the leap into electronic typesetting, " | ||
| "remaining essentially unchanged." | ||
| lorem_desc = ( | ||
| "Lorem Ipsum is simply dummy text of the printing and typesetting industry. " | ||
| "Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an " | ||
| "unknown printer took a galley of type and scrambled it to make a type specimen book. " | ||
| "It has survived not only five centuries, but also the leap into electronic typesetting, " | ||
| "remaining essentially unchanged." | ||
|
Comment on lines
+18
to
+22
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This needs to be updated from https://www.lipsum.com/ :) |
||
| ) | ||
|
|
||
| BOT_COMMANDS: List[LongBotCommand] = [ | ||
| BOT_COMMANDS = [ | ||
| LongBotCommand("help", "Prints out a list of available commands"), | ||
| LongBotCommand( | ||
| "lorem", | ||
| "Prints Lorem Ipsum", | ||
| long_description = lorem_desc, | ||
| long_description=lorem_desc, | ||
| ), | ||
| ] | ||
|
|
||
| def help(update: Update, context: CallbackContext) -> None: | ||
| for command in context.bot.commands: | ||
| # This will only work if you already used set_my_commands! | ||
| update.message.reply_text(f"/{command.command}\n\n{command.long_description}") | ||
|
|
||
| def lorem(update: Update, context: CallbackContext) -> None: | ||
| update.message.reply_text(lorem_text) | ||
| async def help_command(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
| commands = await context.bot.get_my_commands() | ||
| descriptions = {command.command: command.long_description for command in BOT_COMMANDS} | ||
| await update.effective_message.reply_text( | ||
| "\n\n".join(f"/{command.command}\n\n{descriptions[command.command]}" for command in commands) | ||
| ) | ||
|
|
||
|
|
||
| async def lorem(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None: | ||
| await update.effective_message.reply_text(lorem_text) | ||
|
|
||
|
|
||
| dp.add_handler(CommandHandler("help", help)) | ||
| dp.add_handler(CommandHandler("lorem", lorem)) | ||
| async def post_init(application: Application) -> None: | ||
| await application.bot.set_my_commands(BOT_COMMANDS) | ||
|
|
||
| dp.bot.set_my_commands(BOT_COMMANDS) | ||
|
|
||
| updater.start_polling() | ||
| application = Application.builder().token("TOKEN").post_init(post_init).build() | ||
| application.add_handler(CommandHandler("help", help_command)) | ||
| application.add_handler(CommandHandler("lorem", lorem)) | ||
|
|
||
| updater.idle() | ||
| application.run_polling() | ||
|
|
||
| ``` | ||
|
|
||
| ## Requirements | ||
|
|
||
| * `20>python-telegram-bot>=13.0` | ||
| * `python-telegram-bot~=20.0` | ||
|
|
||
| ## Authors | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| python-telegram-bot>=13.0,<20 | ||
| python-telegram-bot~=20.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mind also changing the
Listtolistin the extracturls.py file? If I saw correctly that should make it compatible with py3.10+