Terrance/SkPy

is it possible to delete a message without get all the messages first?

un-hongly opened this issue · 2 comments

Currently when I want to delete a message I need to get all message and then loop through all message to find and delete.

@app.post("/delete-message")
def delete_message(body: DeleteMessageBodyDto):
    chat: SkypeGroupChat = bot.chats[body.chat_id]
    messages: SkypeMsg = chat.getMsgs()
    for msg in messages:
        if msg.id == body.message_id:
            msg.delete()
    return 'success'
Question: Is it possible to delete a message without get all the message first?

Reading the docs for SkypeMsg.delete():

Equivalent to calling edit() with an empty content string.

SkypeMsg.edit():

Arguments are passed to SkypeChat.sendMsg().

SkypeChat.sendMsg():

Parameters:

  • content (str) – main message body
    ...
  • edit (int) – client identifier of an existing message to edit

So assuming you know the ID of the message, you should be able to call chat.sendMsg(content="", edit=message_id).

Reading the docs for SkypeMsg.delete():

Equivalent to calling edit() with an empty content string.

SkypeMsg.edit():

Arguments are passed to SkypeChat.sendMsg().

SkypeChat.sendMsg():

Parameters:

  • content (str) – main message body
    ...
  • edit (int) – client identifier of an existing message to edit

So assuming you know the ID of the message, you should be able to call chat.sendMsg(content="", edit=message_id).

oh, thank you so much!