Conversation
JPTIZ
left a comment
There was a problem hiding this comment.
Precisaria de um rebase com o master, pois o commit de user_id pra cor já está no master e está duplicado no PR.
| if msg_type == MsgType.REP_STICKER: | ||
| pack_name = msg.reply_to_message.sticker.set_name | ||
| sticker_id = msg.reply_to_message.sticker.file_id | ||
|
|
||
| if pack_name is None: | ||
| msg.reply_text('Não é possível remover o sticker de um pack inexistente.') | ||
| return |
There was a problem hiding this comment.
Faltou dizer o que acontece quando a mensagem não é um reply para um sticker. Nesse caso, daria para tratar isso antes de tudo:
| if msg_type == MsgType.REP_STICKER: | |
| pack_name = msg.reply_to_message.sticker.set_name | |
| sticker_id = msg.reply_to_message.sticker.file_id | |
| if pack_name is None: | |
| msg.reply_text('Não é possível remover o sticker de um pack inexistente.') | |
| return | |
| if msg_type != MsgType.REP_STICKER: | |
| msg.reply_text(responses.CHANGE_EMOJIS_HELP) | |
| return | |
| pack_name = msg.reply_to_message.sticker.set_name | |
| sticker_id = msg.reply_to_message.sticker.file_id | |
| if pack_name is None: | |
| msg.reply_text(responses.PACK_DOES_NOT_EXIST) | |
| return |
Outra coisa é usar o responses para as mensagens de resposta do bot. Coloquei já na sugestão como seria o uso delas, só faltaria adicionar o CHANGE_EMOJIS_HELP e o PACK_DOES_NOT_EXIST no responses.py.
| msg = update.message | ||
|
|
||
| except Exception as exc: | ||
| msg.reply_text("Changing Emojis: Falhou") |
There was a problem hiding this comment.
| msg.reply_text("Changing Emojis: Falhou") | |
| msg.reply_text(responses.CHANGE_EMOJIS_HELP) |
| if msg_type not in [MsgType.STICKER, MsgType.REP_STICKER]: | ||
| update.message.reply_text("Message is not a reply to a sticker.") | ||
| return |
There was a problem hiding this comment.
Aí, com as mudanças de cima isso já seria feito no início., então o if aqui seria desnecessário. Acho que daria para deixar essa verificação antes do try ainda.
There was a problem hiding this comment.
Concordo.
Outro detalhe, por consistência as mensagens de resposta pros usuários são sempre em português (ou deveriam ser, pelo menos hehe).
|
|
||
| bot.delete_sticker_from_set(sticker_id) | ||
| # add_sticker(bot, update) | ||
| msg = update.message |
There was a problem hiding this comment.
Isso já é feito na primeira linha deste método.
| if len(splittext) > 1: | ||
| emoji = splittext[1] | ||
| else: | ||
| emoji = DEFAULT_EMOJI |
There was a problem hiding this comment.
Eu acho que não faz muito sentido ter um emoji default para este comando. Se o usuário não informar nenhum emoji seria melhor apenas retornar uma mensagem de erro.
O "autocomplete" do Telegram pra comandos de bot faz com que o comando seja enviado imediatamente, sem o usuário poder completar a mensagem com os "argumentos", então o emoji default iria mais atrapalhar do que ajudar neste caso.
| if msg_type not in [MsgType.STICKER, MsgType.REP_STICKER]: | ||
| update.message.reply_text("Message is not a reply to a sticker.") | ||
| return |
There was a problem hiding this comment.
Concordo.
Outro detalhe, por consistência as mensagens de resposta pros usuários são sempre em português (ou deveriam ser, pelo menos hehe).
Adds a command
/change_emojis <emojis>which can be used when replying to a sticker. It deletes the sticker from the pack and readds it with the new set of emojis.