Compare commits
2 Commits
c41810994a
...
d61c1d0f1b
Author | SHA1 | Date | |
---|---|---|---|
d61c1d0f1b | |||
29cba6e079 |
7
Dockerfile
Normal file
7
Dockerfile
Normal file
@ -0,0 +1,7 @@
|
||||
FROM python:3-alpine
|
||||
|
||||
WORKDIR /repo
|
||||
ADD requirements.txt /repo
|
||||
RUN pip3 install -r requirements.txt
|
||||
|
||||
CMD ["python3", "main.py"]
|
8
docker-compose.yml
Normal file
8
docker-compose.yml
Normal file
@ -0,0 +1,8 @@
|
||||
version: '3'
|
||||
|
||||
services:
|
||||
maidbot:
|
||||
build:
|
||||
context: .
|
||||
volumes:
|
||||
- ./:/repo
|
16
main.py
16
main.py
@ -1,6 +1,7 @@
|
||||
import logging
|
||||
import json
|
||||
import os
|
||||
import signal
|
||||
import time
|
||||
|
||||
from datetime import datetime, timezone
|
||||
@ -54,6 +55,10 @@ class App:
|
||||
|
||||
self.mods = {}
|
||||
|
||||
self.alive = True
|
||||
signal.signal(signal.SIGTERM, lambda a,b: self.exit())
|
||||
signal.signal(signal.SIGINT, lambda a,b: self.exit())
|
||||
|
||||
def authenticate(self):
|
||||
if os.path.exists("auth.json"):
|
||||
with open("auth.json", "r") as f:
|
||||
@ -92,7 +97,7 @@ class App:
|
||||
|
||||
def run(self):
|
||||
self.install("elicense", mods.elicense)
|
||||
while True:
|
||||
while self.alive:
|
||||
try:
|
||||
self.cycle()
|
||||
self.logging.debug("cycle done")
|
||||
@ -101,7 +106,10 @@ class App:
|
||||
|
||||
for mod in self.mods:
|
||||
self.mods[mod].cycle()
|
||||
time.sleep(self.CONFIG["interval"])
|
||||
|
||||
for i in range(self.CONFIG["interval"]):
|
||||
if not self.alive: break
|
||||
time.sleep(1)
|
||||
|
||||
def cycle(self):
|
||||
items = self.M.notifications(
|
||||
@ -117,6 +125,10 @@ class App:
|
||||
|
||||
# TODO: call mod cycles
|
||||
|
||||
def exit(self):
|
||||
self.alive = False
|
||||
self.logging.info("exit requested")
|
||||
|
||||
def reply(self, st, msg):
|
||||
try:
|
||||
self.logging.debug("reply:", msg)
|
||||
|
Loading…
x
Reference in New Issue
Block a user