API.sendChat(message)

Send a chat message.

Comments

  • Avatar
    Proditor Magnus

    Notice that message can start with / to have command evaluated.

  • Avatar
    Chris Bellew

    Is there any way this could return the chat ID (cid) of the resulting chat that is sent out?

    Perhaps like

    API.sendChat("something", function(cid) { // cid would contain the chat id });

  • Avatar
    Proditor Magnus

    If any, then cid = API.sendChat("sth")
    Currently it returns undefined.

    My view is that there is no need to return this either way. You can catch these messages with chat event.

  • Avatar
    Chris Bellew

    Or that way, sure.

    I do have need of this. True, you can catch it with a chat event but that is a workaround. It would be nice to be able to immediately (or almost immediately, if a callback is needed) get the chat id for later use (i.e. to delete said chat).

    I'm using this for my bot, not for a browser extension.

  • Avatar
    Proditor Magnus

    I do have my bot formatted as browser extension, there is no difference between them.

    I suppose it might be more comfortable for you but I do not support this. Current way works reasonably well.

  • Avatar
    Chris Bellew

    Let me explain why I would like this. At the start of every song, my bot displays two chat lines, the first being the stats for the song that just finished (woots, mehs and grabs), the second being some stats on the newly playing song (stats from last.fm).

    I'm making a change that will have the bot delete previous stat lines when a new song starts (to prevent chat clutter). Right now I have to do regex matching on new chats from the bot, and then save those chat id's so they can be deleted when the next song starts. This is not the ideal way to do this.

    So, while you may have no use for something like this, others do.

  • Avatar
    Proditor Magnus

    With timer based on API.getTimeRemaining() you wouldnt need to save those chat ids.

    For my bot I just have that all messages ending with ¤number are deleted after number seconds. Usually 60.

  • Avatar
    Chris Bellew

    Yeah, that's an interesting way of doing it, although you still have to catch the chat later on, after the bot sees its own chat go out. I still think the proper way to do it would be to immediately get the chat id of the chat it just sent, as soon as it sends it.

  • Avatar
    Proditor Magnus

    Cant disagree anymore, but I dont have any hope to see it either.

Powered by Zendesk