Shell: Datum und Zeit für screen und überflüssige Variablen entfernt

This commit is contained in:
Andreas Bielawski 2016-08-22 22:16:56 +02:00
parent 1b438f0142
commit 382e0aa579

View File

@ -12,14 +12,21 @@ function shell:init(config)
end
function shell:transeng(ger)
ger = string.gsub(ger, 'week,', 'Woche,')
ger = string.gsub(ger, 'weeks,', 'Wochen,')
ger = string.gsub(ger, 'day,', 'Tag,')
ger = string.gsub(ger, 'days,', 'Tage,')
ger = string.gsub(ger, 'hour,', 'Stunde und')
ger = string.gsub(ger, 'hours,', 'Stunden und')
ger = string.gsub(ger, 'minute$', 'Minute.')
ger = string.gsub(ger, 'minutes', 'Minuten.')
local ger = string.gsub(ger, 'week,', 'Woche,')
local ger = string.gsub(ger, 'weeks,', 'Wochen,')
local ger = string.gsub(ger, 'day,', 'Tag,')
local ger = string.gsub(ger, 'days,', 'Tage,')
local ger = string.gsub(ger, 'hour,', 'Stunde und')
local ger = string.gsub(ger, 'hours,', 'Stunden und')
local ger = string.gsub(ger, 'minute$', 'Minute.')
local ger = string.gsub(ger, 'minutes', 'Minuten.')
local ger = string.gsub(ger, "Monday", "Montag")
local ger = string.gsub(ger, "Tuesday", "Dienstag")
local ger = string.gsub(ger, "Wednesday", "Mittwoch")
local ger = string.gsub(ger, "Thursday", "Donnerstag")
local ger = string.gsub(ger, "Friday", "Freitag")
local ger = string.gsub(ger, "Saturday", "Samstag")
local ger = string.gsub(ger, "Sunday", "Sonntag")
return ger
end
@ -47,14 +54,16 @@ function shell:action(msg, config, matches)
-- Requires scrot (sudo apt-get install scrot)
if msg.text:match('^/[Ss][Cc][Rr][Ee][Ee][Nn]$') then
local text = run_command("scrot 'scrot.png' -e 'mv $f /tmp/'")
utilities.send_photo(self, msg.chat.id, '/tmp/scrot.png', nil, msg.message_id)
local taken_time = os.date("%A, %d. %B %Y um %H:%M:%S Uhr")
run_command("scrot 'scrot.png' -e 'mv $f /tmp/'")
local text = '#Screenshot vom '..shell:transeng(taken_time)
utilities.send_photo(self, msg.chat.id, '/tmp/scrot.png', text, msg.message_id)
return
end
-- Requires fswebcam (sudo apt-get install fswebcam)
if msg.text:match('^/[Ww][Ee][Bb][Cc][Aa][Mm]$') then
local text = run_command("fswebcam -r 640x480 --png 9 -D 1 /tmp/webcam.png")
run_command("fswebcam -r 640x480 --png 9 -D 1 /tmp/webcam.png")
utilities.send_photo(self, msg.chat.id, '/tmp/webcam.png', nil, msg.message_id)
return
end
@ -68,7 +77,7 @@ function shell:action(msg, config, matches)
-- Requires vnstat & vnstati (sudo apt-get install vnstat vnstati)
if msg.text:match('^/[Tt][Rr][Aa][Ff][Ff][Ii][Cc]$') then
local text = run_command("vnstati -m -vs -i enp2s0 -o /tmp/vnstat.png")
run_command("vnstati -m -vs -i enp2s0 -o /tmp/vnstat.png")
utilities.send_photo(self, msg.chat.id, '/tmp/vnstat.png', nil, msg.message_id)
return
end