Changeset - 53e747f585b6
[Not reviewed]
default
0 1 0
Dennis Fink - 3 years ago 2022-07-19 19:31:13
dennis.fink@c3l.lu
Add more message with time
1 file changed with 8 insertions and 2 deletions:
0 comments (0 inline, 0 general)
spaceapi/utils.py
Show inline comments
 
@@ -2,14 +2,14 @@ import email
 
import email.policy
 
import json
 
import os.path
 
import random
 
import smtplib
 
import ssl
 
from datetime import datetime
 
from functools import partial
 
from time import time
 

	
 
import mastodon
 
import tweepy
 
from flask import current_app, request
 

	
 
default_json_file_v14 = os.path.abspath("default_v14.json")
 
@@ -29,22 +29,27 @@ possible_open_messages = (
 
    "Yes, we're open! Come in and create something!",
 
    "Come by and hack something! We've just opened!",
 
    "The ChaosStuff is now open for everyone!",
 
    "Let the Chaos begin! We're open!",
 
    "What do we hack now? Come and see, we've just opened!",
 
    "TUWAT! Come and hack. We are open!",
 
    "It's {time:%H:%M} and we are open! Come and hack!",
 
    "We just opened our doors at {time:%H:%M}!",
 
    "Bootup process finished at {time:%H:%M}! Doors opened!",
 
)
 

	
 
possible_closed_messages = (
 
    standard_close_message,
 
    "We're closed now! See you soon.",
 
    "Sorry, we are closed now!",
 
    "The ChaosStuff is now closed! Come back another time!",
 
    "Poweroff process finished! We're closed!",
 
    "Singularity reached! The space is closed!",
 
    "Dream of electric sheeps! We are closed!",
 
    "We closed our doors at {time:%H:%M}. See you soon.",
 
    "Poweroff process finished at {time:%H:%M}. We're closed!",
 
)
 

	
 

	
 
RADIATON_SUBKEYS = frozenset(("alpha", "beta", "gamma", "beta_gamma"))
 

	
 

	
 
@@ -141,12 +146,13 @@ class ActiveStatusv14(Singleton, dict):
 
    def notify(self):
 
        message = (
 
            random.choice(possible_open_messages)
 
            if self["state"]["open"]
 
            else random.choice(possible_closed_messages)
 
        )
 
        message = message.format(time=datetime.now())
 
        self.send_tweet(message)
 
        self.send_toot(message)
 

	
 
        subject = (
 
            standard_open_message if self["state"]["open"] else standard_close_message
 
        )
 
@@ -221,13 +227,13 @@ class ActiveStatusv14(Singleton, dict):
 
            if trigger_person is None:
 
                if "trigger_person" in self["state"]:
 
                    del self["state"]["trigger_person"]
 
            else:
 
                self["state"]["trigger_person"] = trigger_person
 

	
 
            self["state"]["lastchange"] = int(time())
 
            self["state"]["lastchange"] = int(datetime.now().timestamp())
 

	
 
        if message is not None and message:
 
            self["state"]["message"] = message
 

	
 
    def set_sensor_value(self, data, key):
 
        try:
0 comments (0 inline, 0 general)