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 logging
|
||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
|
import signal
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
@ -54,6 +55,10 @@ class App:
|
|||||||
|
|
||||||
self.mods = {}
|
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):
|
def authenticate(self):
|
||||||
if os.path.exists("auth.json"):
|
if os.path.exists("auth.json"):
|
||||||
with open("auth.json", "r") as f:
|
with open("auth.json", "r") as f:
|
||||||
@ -92,7 +97,7 @@ class App:
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
self.install("elicense", mods.elicense)
|
self.install("elicense", mods.elicense)
|
||||||
while True:
|
while self.alive:
|
||||||
try:
|
try:
|
||||||
self.cycle()
|
self.cycle()
|
||||||
self.logging.debug("cycle done")
|
self.logging.debug("cycle done")
|
||||||
@ -101,7 +106,10 @@ class App:
|
|||||||
|
|
||||||
for mod in self.mods:
|
for mod in self.mods:
|
||||||
self.mods[mod].cycle()
|
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):
|
def cycle(self):
|
||||||
items = self.M.notifications(
|
items = self.M.notifications(
|
||||||
@ -117,6 +125,10 @@ class App:
|
|||||||
|
|
||||||
# TODO: call mod cycles
|
# TODO: call mod cycles
|
||||||
|
|
||||||
|
def exit(self):
|
||||||
|
self.alive = False
|
||||||
|
self.logging.info("exit requested")
|
||||||
|
|
||||||
def reply(self, st, msg):
|
def reply(self, st, msg):
|
||||||
try:
|
try:
|
||||||
self.logging.debug("reply:", msg)
|
self.logging.debug("reply:", msg)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user