User Tools

Site Tools


matrix_tools

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Next revision Both sides next revision
matrix_tools [2020/05/30 08:59]
admin
matrix_tools [2020/06/01 11:40]
admin
Line 1: Line 1:
 ====== Matrix ​ ====== ====== Matrix ​ ======
 +===== Documentation =====
 +  * https://​matrix.org/​docs/​api/​client-server/#/​
 ===== Getting your access token ===== ===== Getting your access token =====
   * Using Riot (that'​s whats running on https://​matrix.glasgow.social) - Click on your profile name at the top left corner and select ''​Settings''​   * Using Riot (that'​s whats running on https://​matrix.glasgow.social) - Click on your profile name at the top left corner and select ''​Settings''​
Line 53: Line 55:
  
 ===== Listening to channels ===== ===== Listening to channels =====
-This is pretty straightforward. ​ This is just how to see messages that are posted, but if you explore what is returned then you can see all sorts of things too (like joins, images, likes, invites etc).  Very cool.+This is pretty straightforward. ​ This is just how to see messages that are posted, but if you explore what is returned then you can see all sorts of things too (like joins, images, likes, invites etc).  I run something like this on a terminal so I can see what's going on in all my channels at a glance.  Very cool.
  
 <code php ListenToMatrix.php>​ <code php ListenToMatrix.php>​
Line 96: Line 98:
  
 ?> ?>
 +</​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 functionsI use in IRC from a database and act accordingly). ​
matrix_tools.txt ยท Last modified: 2023/12/27 13:45 by admin