Compare commits
No commits in common. "master" and "matrix" have entirely different histories.
|
|
@ -1,5 +1,3 @@
|
|||
settings.json
|
||||
__pycache__/
|
||||
*.pyc
|
||||
*.png
|
||||
.venv/
|
||||
|
|
|
|||
|
|
@ -1,11 +1,8 @@
|
|||
FROM python:3.6-alpine3.7
|
||||
|
||||
ADD ["src", "requirements.txt", "/app/"]
|
||||
ADD [".", "/app"]
|
||||
WORKDIR /app
|
||||
RUN apk add --update g++ gfortran openblas-dev libpng-dev musl-dev freetype-dev libpng openblas libstdc++ && \
|
||||
pip install -r requirements.txt --no-cache-dir && \
|
||||
apk del g++ gfortran openblas-dev libpng-dev musl-dev freetype-dev && \
|
||||
useradd -D bot
|
||||
USER bot
|
||||
RUN apk add --update g++ gfortran openblas-dev libpng-dev musl-dev freetype-dev
|
||||
RUN pip install -r requirements.txt --no-cache-dir
|
||||
|
||||
CMD ["python", "bot.py"]
|
||||
|
|
@ -3,6 +3,6 @@ version: "2"
|
|||
services:
|
||||
doorbot:
|
||||
build: .
|
||||
image: fswiai/doorbot:0.4
|
||||
image: fswiai/doorbot:0.2
|
||||
volumes:
|
||||
- ./settings.json:/app/settings.json
|
||||
|
|
@ -1,19 +1,16 @@
|
|||
import datetime
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from collections import namedtuple
|
||||
|
||||
import requests
|
||||
|
||||
from collections import namedtuple
|
||||
|
||||
Status = namedtuple("Status", ['doorstate', 'timestamp', 'text'])
|
||||
|
||||
class Source(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
class Source:
|
||||
def get_status(self):
|
||||
pass
|
||||
raise NotImplementedError()
|
||||
|
||||
def is_recent(self, status, **kwargs):
|
||||
return status.timestamp + datetime.timedelta(days=1) < datetime.datetime.today()
|
||||
raise NotImplementedError()
|
||||
|
||||
class IsFsWIAIopen(Source):
|
||||
url = "https://isfswiaiopen.wiai.de?json"
|
||||
|
|
@ -32,4 +29,7 @@ class IsFsWIAIopen(Source):
|
|||
return Status(
|
||||
doorstate=str(status['doorstate']),
|
||||
timestamp=self._parse_time(status['timestamp']),
|
||||
text=self._get_text(str(status['doorstate'])))
|
||||
text=self._get_text(str(status['doorstate'])))
|
||||
|
||||
def is_recent(self, status, **kwargs):
|
||||
return status.timestamp + datetime.timedelta(days=1) < datetime.datetime.today()
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
import logging
|
||||
from abc import ABCMeta, abstractmethod
|
||||
|
||||
import requests
|
||||
|
||||
|
|
@ -7,21 +6,18 @@ from matrix_client.client import MatrixClient as MatrixApiClient
|
|||
from matrix_client.errors import MatrixError
|
||||
|
||||
|
||||
class Client(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
class Client:
|
||||
def post_image(self, file, name, content_type="image/png", targets=None):
|
||||
"""Push to all targets"""
|
||||
self.post_image(file, name, content_type, targets)
|
||||
#raise NotImplementedError()
|
||||
|
||||
def send_image(self, target, file, name, content_type="image/png"):
|
||||
"""Send an image to a room
|
||||
|
||||
Args:
|
||||
target (str): The internal room id to post into
|
||||
file (file): The image file object
|
||||
path (file): The image file object
|
||||
name (str): The name for the file in the room
|
||||
content_type (str): Content-type of the image
|
||||
"""
|
||||
|
|
@ -30,6 +26,7 @@ class Client(metaclass=ABCMeta):
|
|||
def post_text(self, text, targets=None):
|
||||
"""Push to all targets"""
|
||||
self.post_text(text, targets)
|
||||
#raise NotImplementedError()
|
||||
|
||||
def send_text(self, target, text):
|
||||
"""Send a text to a room
|
||||
Loading…
Reference in New Issue