LINE icon indicating copy to clipboard operation
LINE copied to clipboard

Implement sendChatChecked (mark as read)

Open ssut opened this issue 9 years ago • 6 comments

I found a way to implement sendChatChecked method with LINE thrift while making a bot. (It's not python, https://github.com/ssut/llama) Since you may know, there is a method which marks a message as read.

Here are the details as follows:

In thrift file: (I think you've removed this shortcode from the origin or not. for what it's worth, you have to update the curve package for implementing.)

...
    void sendChatChecked(
        1: i32 seq,
        2: string consumer,
        3: string lastMessageId) throws(1: TalkException e);
...

In a python code:

def _sendChatChecked(self, target, msgid, seq=0):
    return self._client.sendChatChecked(seq, target, msgid)

Just as the above code shown, it requires 2 parameters:

  • The target to send it's read confirmation.
  • The msgid as we can suggest by its name, message.id.

The target becomes a reference to the interlocutor, which can be a "room", a "group" or a "user", for instance, If the chat room's ToType is a GROUP or a ROOM then it becomes a message.to.

Good luck to implement that support for developers who use this library! :+1: BTW, can I write any issues in Korean next time? :p (just, All issues written in English.)

ssut avatar Jul 02 '15 11:07 ssut

Thanks for sharing a useful information. I'll update the curve and the library soon. In my view point, most of the users of this library is Japanese, Taiwanese or Chinese not Korean. So I think you might be better to post any issues in english to communicate with not only with me but also with others.

carpedm20 avatar Jul 02 '15 21:07 carpedm20

I confirmed this sendChatChecked are useable. But unfortunately, my project cannot merge to your repository cuz private project and code are more complicated.

shinznatkid avatar Jul 10 '15 12:07 shinznatkid

It's really necessary to have this method otherwise It can't immediately send messages back to client even the bot is online.

neosign avatar Mar 20 '16 07:03 neosign

I need help about this .-.

ii64 avatar Apr 14 '17 15:04 ii64

The curve client has no "sendChatChecked" method

So I tried making one, based on "acceptGroupInvitation" method and classes. At first it gave me TalkException : 'invalid mid', but that was just because I forgot to change the field id for lastMessageId (it overwrote consumer, the mid). Now I'm getting no error but my chats are still not being read.

The fields are just like in the OP :

    1: i32 seq,
    2: string consumer,
    3: string lastMessageId

The args class writes fields according to it, and the result class also reads fields according to it.

And I passed : seq = 0, just like the other methods consumer = room/group mid for room/group, sender mid for private chats lastMessageId = operation.message.id

I'm calling the method from my main client (not the group/room object nor the sender object). Passing their mids as consumer. I didn't create the methods that starts with 'process', also didnt add it to the dictionary thing. Do I need to do so?

Btw I don't see any thrift file or curve package in this repo. What were you refering to? Did you mean this thrift file? http://altrepo.eu/sleepingpig/line-protocol/blob/561fea469014cd8c02cc506cf9cb094a0af16b60/line.thrift This repo doesnt have it (but it works. because of curve, I guess)

Thanks

R-N avatar Jun 01 '17 22:06 R-N

Nvm. Turns out it read but it was still not immediate (had to send another message to refresh).

You can use the _client_out to make it immediate. In fact, the _client_out only works for this in my case. Sending messages using _client_out doesn't work. So I send message normally and THEN sendChatChecked using _client_out. The message will be sent/received after the last chat is read.

You can find about _client_out somewhere here in other issue. Forgot which.

R-N avatar Jun 01 '17 23:06 R-N