Remove tradebyte-attendance
This commit is contained in:
parent
e46759987f
commit
18da750ce1
5 changed files with 0 additions and 125 deletions
|
|
@ -190,7 +190,6 @@ in
|
|||
home.packages = with pkgs; [
|
||||
mycli
|
||||
timetrap
|
||||
tradebyte-attendance
|
||||
tradebyte-vpn
|
||||
|
||||
# common
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ in
|
|||
pretix-banktool = callPackage ./pretix/pretix-banktool.nix { };
|
||||
pretix-static = callPackage ./pretix/pretix-static.nix { };
|
||||
tabbed-box-maker = callPackage ./tabbed-box-maker { };
|
||||
tradebyte-attendance = callPackage ./tradebyte-attendance { };
|
||||
vesc-firmware = callPackage ./vesc-tool/firmware.nix { };
|
||||
vesc-tool = callPackage ./vesc-tool/tool.nix { };
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,14 +0,0 @@
|
|||
{ pkgs, python3Packages }:
|
||||
|
||||
python3Packages.buildPythonApplication rec {
|
||||
pname = "tradebyte-attendance";
|
||||
version = "0.0.1";
|
||||
|
||||
src = ./.;
|
||||
|
||||
propagatedBuildInputs = [
|
||||
python3Packages.slack-sdk
|
||||
pkgs.timetrap
|
||||
pkgs.pass
|
||||
];
|
||||
}
|
||||
|
|
@ -1,15 +0,0 @@
|
|||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="tradebyte_attendance",
|
||||
version="0.0.1",
|
||||
author="jalr",
|
||||
author_email="mail@jalr.de",
|
||||
description="Send attendance messages to slack channel",
|
||||
packages=find_packages(),
|
||||
entry_points={
|
||||
"console_scripts": [
|
||||
"tradebyte-attendance = tradebyte_attendance.__init__:main",
|
||||
],
|
||||
},
|
||||
)
|
||||
|
|
@ -1,94 +0,0 @@
|
|||
import argparse
|
||||
import datetime
|
||||
import random
|
||||
import subprocess
|
||||
|
||||
from slack_sdk import WebClient
|
||||
|
||||
|
||||
class Anwesenheit:
|
||||
_slack_client = None
|
||||
|
||||
@property
|
||||
def slack_client(self):
|
||||
if self._slack_client is None:
|
||||
token = get_pass("slack/token/anwesenheit")[0]
|
||||
self._slack_client = WebClient(
|
||||
token=token,
|
||||
)
|
||||
return self._slack_client
|
||||
|
||||
def timetrap(self, cmd):
|
||||
subprocess.call(["timetrap", cmd])
|
||||
|
||||
def send_anwesenheit_slack(self, channel, message):
|
||||
self.slack_client.chat_postMessage(channel=channel, text=message)
|
||||
|
||||
def morning(self, test):
|
||||
messages = ["Good morning"]
|
||||
self.set_state(messages, "in", test)
|
||||
|
||||
def lunch(self, test):
|
||||
messages = ["Lunch"]
|
||||
self.set_state(messages, "out", test)
|
||||
|
||||
def back(self, test):
|
||||
messages = ["back"]
|
||||
self.set_state(messages, "in", test)
|
||||
|
||||
def bye(self, test):
|
||||
if datetime.datetime.today().weekday() == 4: # Friday!
|
||||
messages = [
|
||||
"Bye, have a nice weekend everyone!",
|
||||
"Bye, enjoy your weekend",
|
||||
"I'm out, have a nice weekend!",
|
||||
"Have a nice weekend everyone!",
|
||||
]
|
||||
else:
|
||||
messages = [
|
||||
"See you tomorrow!",
|
||||
"Bye, have a nice evening!",
|
||||
"I'm out for today",
|
||||
"Bye",
|
||||
"That's it for today, see you tomorrow.",
|
||||
]
|
||||
self.set_state(messages, "out", test)
|
||||
|
||||
def set_state(self, messages, state, test_mode):
|
||||
self.timetrap(state)
|
||||
message = random.choice(messages)
|
||||
channel = "jal-test" if test_mode else "ccs-attendance"
|
||||
self.send_anwesenheit_slack(channel, message)
|
||||
|
||||
|
||||
def get_pass(title):
|
||||
return subprocess.check_output(["pass", "show", title], text=True).splitlines()
|
||||
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
command_subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
command_arguments = {
|
||||
"--test": {
|
||||
"action": "store_true",
|
||||
"help": "publish message to test channel",
|
||||
},
|
||||
}
|
||||
for command, command_help, arguments in (
|
||||
("morning", "Send greeting message in the morning", ("--test",)),
|
||||
("lunch", "Send message at lunch time", ("--test",)),
|
||||
("back", "Send message when returning to work", ("--test",)),
|
||||
("bye", "Send goodbye message", ("--test",)),
|
||||
):
|
||||
command_parser = command_subparsers.add_parser(command, help=command_help)
|
||||
for argument in arguments:
|
||||
command_parser.add_argument(argument, **command_arguments[argument])
|
||||
|
||||
args = vars(parser.parse_args())
|
||||
anwesenheit = Anwesenheit()
|
||||
fn = getattr(anwesenheit, args.pop("command").replace("-", "_"))
|
||||
fn(**args)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Loading…
Add table
Add a link
Reference in a new issue