rename project into Matrix Webhook
This commit is contained in:
		
					parent
					
						
							
								6d05f6bb94
							
						
					
				
			
			
				commit
				
					
						01a083c693
					
				
			
		
					 3 changed files with 11 additions and 13 deletions
				
			
		| 
						 | 
				
			
			@ -1,6 +1,6 @@
 | 
			
		|||
# wifi-with-matrix
 | 
			
		||||
# Matrix Webhook
 | 
			
		||||
 | 
			
		||||
Bridge between https://code.ffdn.org/FFDN/wifi-with-me & a matrix room
 | 
			
		||||
Post a message to a matrix room with a simple HTTP POST
 | 
			
		||||
 | 
			
		||||
## Configuration
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -30,6 +30,6 @@ docker-compose up -d
 | 
			
		|||
## Test
 | 
			
		||||
 | 
			
		||||
```
 | 
			
		||||
curl -d '{"text":"new contrib from toto: http://radio.localhost/map/#44", "key": "secret"}' wwm.localhost
 | 
			
		||||
curl -d '{"text":"new contrib from toto: http://radio.localhost/map/#44", "key": "secret"}' mwh.localhost
 | 
			
		||||
```
 | 
			
		||||
(or wwm.localhost:4785 without docker)
 | 
			
		||||
(or mwh.localhost:4785 without docker)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -14,5 +14,4 @@ services:
 | 
			
		|||
      - web
 | 
			
		||||
    labels:
 | 
			
		||||
      traefik.enable: "true"
 | 
			
		||||
      traefik.frontend.rule: "Host: ${CHATONS_SERVICE:-wwm}.${CHATONS_DOMAIN:-localhost}, www.${CHATONS_SERVICE:-wwm}.${CHATONS_DOMAIN:-localhost}"
 | 
			
		||||
 | 
			
		||||
      traefik.frontend.rule: "Host: ${CHATONS_SERVICE:-mwh}.${CHATONS_DOMAIN:-localhost}, www.${CHATONS_SERVICE:-mwh}.${CHATONS_DOMAIN:-localhost}"
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
							
								
								
									
										13
									
								
								main.py
									
										
									
									
									
								
							
							
						
						
									
										13
									
								
								main.py
									
										
									
									
									
								
							| 
						 | 
				
			
			@ -1,7 +1,7 @@
 | 
			
		|||
#!/usr/bin/env python3
 | 
			
		||||
"""
 | 
			
		||||
wifi-with-matrix script.
 | 
			
		||||
Bridge between https://code.ffdn.org/FFDN/wifi-with-me & a matrix room
 | 
			
		||||
Matrix Webhook
 | 
			
		||||
Post a message to a matrix room with a simple HTTP POST
 | 
			
		||||
"""
 | 
			
		||||
 | 
			
		||||
import json
 | 
			
		||||
| 
						 | 
				
			
			@ -17,9 +17,9 @@ MATRIX_PW = os.environ['MATRIX_PW']
 | 
			
		|||
API_KEY = os.environ['API_KEY']
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class WWMBotServer(HTTPServer):
 | 
			
		||||
class MatrixWebhookServer(HTTPServer):
 | 
			
		||||
    """
 | 
			
		||||
    an HTTPServer that also contain a matrix client
 | 
			
		||||
    an HTTPServer that embeds a matrix client
 | 
			
		||||
    """
 | 
			
		||||
 | 
			
		||||
    def __init__(self, *args, **kwargs):
 | 
			
		||||
| 
						 | 
				
			
			@ -29,7 +29,7 @@ class WWMBotServer(HTTPServer):
 | 
			
		|||
        self.rooms = self.client.get_rooms()
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
class WWMBotForwarder(BaseHTTPRequestHandler):
 | 
			
		||||
class MatrixWebhookHandler(BaseHTTPRequestHandler):
 | 
			
		||||
    """
 | 
			
		||||
    Class given to the server, st. it knows what to do with a request.
 | 
			
		||||
    This one handles the HTTP request, and forwards it to the matrix room.
 | 
			
		||||
| 
						 | 
				
			
			@ -60,5 +60,4 @@ class WWMBotForwarder(BaseHTTPRequestHandler):
 | 
			
		|||
 | 
			
		||||
 | 
			
		||||
if __name__ == '__main__':
 | 
			
		||||
    print('Wifi-With-Matrix bridge starting…')
 | 
			
		||||
    WWMBotServer(SERVER_ADDRESS, WWMBotForwarder).serve_forever()
 | 
			
		||||
    MatrixWebhookServer(SERVER_ADDRESS, MatrixWebhookHandler).serve_forever()
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue