matrix-eno-bot icon indicating copy to clipboard operation
matrix-eno-bot copied to clipboard

Feature request: External trigger

Open Heidistein opened this issue 4 years ago • 4 comments

For some idea I am working on (API interaction) it is possible to issue a call and the response will eventually be POST'ed to a webserver. Have a system that not only responds to commands in channels, but also on an external trigger. This could be as simple as a file appearing in a directory or a full-blown HTTP server.

Low priority, now solved by just POST'ing to the matrix server

Heidistein avatar Mar 05 '21 23:03 Heidistein

Thanks @Heidistein I think this is a valuable idea, something that really adds functionality.

Do you envision something along the lines of periodically executing a provided script? Something like a repeat command that executes periodically?

Or how do you envision that? Ideas? Further details?

8go avatar Mar 09 '21 17:03 8go

Hmmm, yes. This is a question with a million answers I am afraid. You could implement an entire HTTP server. My opinion on this, is that this will prove a lot of work, will have a lot of challenges. However, it is the most 'trendy' think to say you have you a rest-full API. Personally my opinion is that this is a too difficult approach.

My current idea is a thread which subscribes to an 'inotify' event on a directory (perhaps implement polling for NFS volumes). Every time a file appears in that specific directory, the corresponding script will be executed, with the full filename as argument (or first line on stdin, whichever is easier). This way the scriptbuilder has absolute control over the data he needs to pass along, in which format.

It is entirely possible this idea has holes in it, or can be done even simpler/handier.

Heidistein avatar Mar 09 '21 18:03 Heidistein

Thanks @Heidistein for the additional details. Your input is food for thoughts.

As an alternative, available now, is to use matrix-commander from repo https://github.com/8go/matrix-commander.

One can build about anything witht his CLI tool. matrix-commander can be used to send messages to rooms. It cculd be called from from cron (crontab), from a script that polls NFS volumes, etc.

8go avatar Mar 14 '21 17:03 8go

Yes (diverting from the topic now a bit, sorry), that is a good one. I have looked at it. However I ended up just sending a HTTP PUT to the matrix server itself: curl -X PUT "https://${SERVER_HOST}/_matrix/client/r0/rooms/${ROOM_ID}/send/m.room.message/${RANDOM}" -H "Authorization: Bearer ${ACCESS_TOKEN}" -d "${CONTENT}"

Heidistein avatar Mar 14 '21 22:03 Heidistein