This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Next revision Both sides next revision | ||
matrix_tools [2020/05/30 09:00] admin |
matrix_tools [2020/05/30 11:25] admin [Matrix Bot] it's not right Neo |
||
---|---|---|---|
Line 96: | Line 96: | ||
?> | ?> | ||
+ | </code> | ||
+ | |||
+ | You can follow one particular room just using GET requests, by doing something like this: | ||
+ | |||
+ | <code php> | ||
+ | function get_new_events($room) { | ||
+ | $homeserver = "glasgow.social"; | ||
+ | $access_token = "access_token_goes_here" | ||
+ | $url = "https://$homeserver/_matrix/client/r0/rooms/$room/messages?access_token=$access_token&from=$tracking_id"; | ||
+ | $data = json_decode(file_get_contents($url), true); | ||
+ | return $data; | ||
+ | } | ||
</code> | </code> | ||
===== Matrix Bot ===== | ===== Matrix Bot ===== | ||
- | * See [[Matrix Bot]] | + | The basis of my bot's interaction with Matrix is bascially the above code. Replace the echo line with with whatever you want to do (in my case, I look up a list of rules [i.e. pairs of regexes and their response functions] I use in IRC from a database and act accordingly). |