Commit 4122b106 authored by Markus Seidl's avatar Markus Seidl

Added display off and on commands.

parent dffe42eb
......@@ -51,10 +51,50 @@ func CCTelegramLoop(handler func(message Message) (timestamp time.Time, err erro
registerUpgradeCommand(b)
registerRebootCommand(b)
registerShutdownCommand(b)
registerDisplayOff(b)
registerDisplayOn(b)
b.Start()
}
func registerDisplayOff(b *tb.Bot) {
b.Handle("/display_off", func(m *tb.Message) {
if !isAllowed(b, m) {
return
}
app := "./scripts/display_off"
cmd := &exec.Cmd{
Path: app,
Args: []string{},
}
log.Printf("Executing: %s", app)
temp, err := cmd.CombinedOutput()
log.Print(err)
log.Print(string(temp))
})
}
func registerDisplayOn(b *tb.Bot) {
b.Handle("/display_on", func(m *tb.Message) {
if !isAllowed(b, m) {
return
}
app := "./scripts/display_on"
cmd := &exec.Cmd{
Path: app,
Args: []string{},
}
log.Printf("Executing: %s", app)
temp, err := cmd.CombinedOutput()
log.Print(err)
log.Print(string(temp))
})
}
func registerShutdownCommand(b *tb.Bot) {
b.Handle("/shutdown", func(m *tb.Message) {
if !isAllowed(b, m) {
......
......@@ -6,6 +6,8 @@ import time
PIN=40
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(PIN, GPIO.OUT)
GPIO.output(PIN, GPIO.HIGH)
......
......@@ -6,6 +6,8 @@ import time
PIN=40
GPIO.setmode(GPIO.BOARD)
GPIO.setwarnings(False)
GPIO.setup(PIN, GPIO.OUT)
GPIO.output(PIN, GPIO.HIGH)
......
......@@ -9,11 +9,13 @@ import (
"path/filepath"
"sort"
"strconv"
"strings"
"time"
)
const MaxFilesPerDirectory = 100
const DefaultCategory = "default"
const PreviewSuffix = "_preview"
type Database struct {
Directory string
......@@ -71,14 +73,17 @@ func (d *Database) createDirectoryFor(category string, id int) string {
return fmt.Sprintf("%s/%s/%02d/", d.Directory, category, id)
}
// all files without preview
func (d *Database) AllFiles() []string {
var files []string
_ = filepath.Walk(d.Directory, func(path string, info os.FileInfo, err error) error {
if info.IsDir() {
return nil
}
if strings.HasSuffix(path, PreviewSuffix) {
return nil
}
files = append(files, path)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment