- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.9k
Closed
Description
Issue I am facing
I'm trying to set commands from within a dictionary.
This fails with a string index out of range error and I cannot quite understand how.
Simply printing it returns the commands.
Traceback to the issue
Traceback (most recent call last):
  File "main.py", line 207, in <module>
    main()
  File "main.py", line 163, in main
    bot.set_my_commands(command.name, command.description)
  File "/home/user/.local/lib/python3.6/site-packages/telegram/bot.py", line 130, in decorator
    result = func(*args, **kwargs)
  File "/home/user/.local/lib/python3.6/site-packages/telegram/bot.py", line 5328, in set_my_commands
    cmds = [c if isinstance(c, BotCommand) else BotCommand(c[0], c[1]) for c in commands]
  File "/home/user/.local/lib/python3.6/site-packages/telegram/bot.py", line 5328, in <listcomp>
    cmds = [c if isinstance(c, BotCommand) else BotCommand(c[0], c[1]) for c in commands]
IndexError: string index out of rangeRelated part of your code
from telegram import Update, ForceReply, ChatPermissions, Bot, BotCommand
class Command(object):
    def __init__(self, name, description):
        self.name = name
        self.description = description
Commands = {
    1: Command("start", "start command"),
    2: Command("stop", "stop command")
}
def main() -> None:
    
    updater = Updater(config.TOKEN)
    bot = Bot(config.TOKEN)
    for command in Commands.values():
        bot.set_my_commands(command.name, command.description)Operating System
Windows 10
Version of Python, python-telegram-bot & dependencies
python-telegram-bot 13.9
Bot API 5.5
certifi 2021.10.08
Python 3.6.9 (default, Nov  7 2019, 10:44:02)  [GCC 8.3.0]Metadata
Metadata
Assignees
Labels
No labels