ElektraInitiative / opensesame

3 stars 5 forks source link

Nextcloud commands self interference and the @username prefix #129

Closed horenso closed 10 months ago

horenso commented 10 months ago

Hi,

I have some question regarding the logic of the @username prefix for our Nextcloud commands and how the command chat should handle multiple instances.

I listen to commands in the configured commands chat by polling all unread messages in a regular interval.

GET <nextcloud_host>/ocs/v2.php/apps/spreed/api/v1/chat/<chat_id>
{ "lookIntoFuture": "1", "limit", "100", "lastKnownMessageId", <last_known_message_id> }

API documentation

The issue is that after responding to a command, I receive my own response message with the next get request and (without additional logic) I try to interpret it as a command, I get into an infinit loop.

1) @markus2330 Could you please create two test users on your Nextcloud instance (like opensesame_dev1 and opensesame_dev2 or similar) for me to test the commands more comfortably, since right now I use my own user for Opensesame. I can filter the messages to ignore Opensesame's own messages then.

2) I don't quite know what to do if multiple Opensesame instances listen to the same commands chat, because they will pick up each others responses. I would need a list of user_names or a pattern, maybe something like ignore all usernames containering "*opensesame*". If it's not possible to have multiple Opensesame instances listen to the same commands chat, the @username prefix doesn't make sense in my opinion.

horenso commented 10 months ago

@markus2330 thanks for created the two test accounts, that works better now. Regarding 2) I will do what I suggested and just ignore messages coming from users that have "opensesame" in their name to move forward.

markus2330 commented 10 months ago

I don't quite know what to do if multiple Opensesame instances listen to the same commands chat, because they will pick up each others responses. I would need a list of user_names or a pattern, maybe something like ignore all usernames containering "opensesame". If it's not possible to have multiple Opensesame instances listen to the same commands chat, the @username prefix doesn't make sense in my opinion.

It is possible and even common that several Opensesame instances are in the same chat, e.g. a garage and house door. Without @mention you could not say which door you want to open, so @mention is a quite essential part of the nextcloud talk usecase.

But we can merge an intermediate step (without @mention) or at least review a PR, so I am looking forward to your PR as soon as possible, regardless of if @mention is implemented (or works).

You can simply append some special UTF-8 character to messages, so that you know the message is to be ignored. Maybe ACK or XON (if Nextcloud does not bother about these characters being send).

In some cases, e.g. alarm! all instances however should interpret the message and also go into the alarm mode. If you are already in alarm, you simply don't do anything. See also #117.

markus2330 commented 10 months ago

Alternatively, you could simply mention back the person who wrote a command, then all instances know (because they are not addressed in the mention) that they are not meant.

horenso commented 10 months ago

The invisible unicode is a greate idea, I didn't think of that! For now I'm just all usernames with "opensesame" in their name since that's what I have now.