some new plugins (thx to _20h_)
This commit is contained in:
parent
63fc042027
commit
0ba2001b62
5 changed files with 346 additions and 0 deletions
13
disabled_stuff/freddy.py
Normal file
13
disabled_stuff/freddy.py
Normal file
|
@ -0,0 +1,13 @@
|
|||
from util import hook, http, web
|
||||
from subprocess import check_output, CalledProcessError
|
||||
|
||||
@hook.command
|
||||
def freddycode(inp):
|
||||
"""freddycode <code> - Check if the Freddy Fresh code is correct."""
|
||||
|
||||
try:
|
||||
return "Freddy: '%s' ist %s" % (inp, \
|
||||
check_output(["/bin/freddycheck", inp]))
|
||||
except CalledProcessError as err:
|
||||
return "Freddy: Skript returned %s" % (str(err))
|
||||
|
53
disabled_stuff/status.py
Normal file
53
disabled_stuff/status.py
Normal file
|
@ -0,0 +1,53 @@
|
|||
from util import hook
|
||||
import re
|
||||
import time
|
||||
from subprocess import check_output
|
||||
|
||||
def getstatus():
|
||||
try:
|
||||
return check_output("sudo /bin/chch-status", shell=True).strip("\n").decode("utf-8")
|
||||
except:
|
||||
return "unbekannt"
|
||||
|
||||
@hook.command("status", autohelp=False)
|
||||
def cmd_status(inp, reply=None):
|
||||
"""status - Return the door status"""
|
||||
reply("Chaostreff Status: %s" % (getstatus()))
|
||||
|
||||
@hook.event("TOPIC")
|
||||
def topic_update(info, conn=None, chan=None):
|
||||
"""topic_update -- Update the topic on TOPIC command"""
|
||||
status = getstatus()
|
||||
|
||||
topic = info[-1]
|
||||
|
||||
sstr = "Status: %s" % (status)
|
||||
if sstr in topic:
|
||||
return
|
||||
|
||||
if 'Status: ' in topic:
|
||||
new_topic = re.sub("Status: [^ ]*", sstr, topic)
|
||||
else:
|
||||
new_topic = "%s | %s" % (topic.rstrip(' |'), sstr)
|
||||
|
||||
if new_topic != topic:
|
||||
conn.send("TOPIC %s :%s" % (chan, new_topic))
|
||||
|
||||
@hook.event("332")
|
||||
def e332_update(info, conn=None, chan=None):
|
||||
"""e332_update -- run after current topic was requested"""
|
||||
chan = info[1]
|
||||
topic_update(info, conn=conn, chan=chan)
|
||||
|
||||
@hook.singlethread
|
||||
@hook.event("353")
|
||||
def e353_update(info, conn=None, chan=None):
|
||||
"""e353_update -- runs after a channel was joined"""
|
||||
chan = info[2]
|
||||
if chan.lower() == "#chaoschemnitz":
|
||||
conn.send("PRIVMSG Chanserv :op #chaoschemnitz")
|
||||
|
||||
while True:
|
||||
conn.send("TOPIC %s" % (chan))
|
||||
time.sleep(60)
|
||||
|
Reference in a new issue