Re-implement commands in the plugin system
This commit is contained in:
parent
37bf2fb1e4
commit
1e42493910
|
@ -0,0 +1,19 @@
|
|||
import plugin
|
||||
|
||||
@plugin.group("admin")
|
||||
def admin(self,channel,nick,subcmd,*args):
|
||||
if not self.is_admin: return True
|
||||
if subcmd not in "down check".split(): return True
|
||||
return False
|
||||
|
||||
@admin.command("down")
|
||||
def admin_down(self,channel,nick,subcmd,*args):
|
||||
self.tasks.stop()
|
||||
self.tasks.save_state(0)
|
||||
self._bot.die("Stopping...")
|
||||
sys.exit(0)
|
||||
|
||||
@admin.command("check")
|
||||
def admin_check(self,channel,nick,subcmd,*args):
|
||||
self.say(channel,"This would check the RSS feed but I don't wanna spam")
|
||||
# self.tasks.states[0] = self.check_rss(self.tasks.states[0],self.tasks.base_state)
|
|
@ -0,0 +1,5 @@
|
|||
import plugin
|
||||
|
||||
@plugin.command("botlist")
|
||||
def on_botlist(self,channel,nick,*args):
|
||||
self.say(channel,nick+": Maintainer: khuxkm@cosmic.voyage | Utility bot")
|
|
@ -0,0 +1,8 @@
|
|||
import plugin, subprocess
|
||||
|
||||
@plugin.command("fortune")
|
||||
def on_fortune(self,channel,nick,*args):
|
||||
output = subprocess.check_output(["/usr/games/fortune"]).decode("ascii").split("\n")
|
||||
output = filter(None,output)
|
||||
for line in output:
|
||||
self.say(channel,"{}".format(line))
|
|
@ -0,0 +1,21 @@
|
|||
import plugin, re
|
||||
|
||||
@plugin.command("latest","<count/filter>")
|
||||
def on_latest(self,channel,nick,count="5"):
|
||||
if re.match(r"\d+",count):
|
||||
count = int(count)
|
||||
if count < 1:
|
||||
count = 1 # ...nice try, smartass
|
||||
if count > 5:
|
||||
count = 5 # don't spam the channel
|
||||
self.say(channel, "{}: Latest {} {}. (See cosmic.voyage for more!)".format(nick, count, (count == 1 and "entry" or "entries")))
|
||||
else:
|
||||
self.say(channel, "{}: Latest entries matching '{}'. (See cosmic.voyage for more!)".format(nick, count))
|
||||
# output = subprocess.check_output(["/usr/local/bin/latest",str(count)]).decode("ascii").split("\n")
|
||||
if type(count)==int:
|
||||
output = ["Excelsior - The one khuxkm has to write {!s}".format(x+1) for x in range(count)]
|
||||
else:
|
||||
output = ["Your filter was {!s}".format(count)]
|
||||
output = filter(None,output)
|
||||
for line in output:
|
||||
self.say(channel,"{}: {}".format(nick,line))
|
|
@ -0,0 +1,5 @@
|
|||
import plugin
|
||||
|
||||
@plugin.command("reload","")
|
||||
def reloadPlugins(bot,channel,nick,*args):
|
||||
if bot.is_admin: bot.load_modules()
|
|
@ -0,0 +1,12 @@
|
|||
import plugin, re
|
||||
|
||||
unhighlight_nick = lambda nick: "_{!s}_".format(nick)
|
||||
|
||||
@plugin.command("roster","<count/filter>")
|
||||
def on_roster(self,channel,nick,*namecnt):
|
||||
# output = subprocess.check_output(["/usr/local/bin/roster",' '.join(namecnt)]).decode("ascii").split("\n")
|
||||
output = ["khuxkm\tExcelsior","","alexis\tVoortrekker"]
|
||||
output = filter(None,output)
|
||||
for line in output:
|
||||
line = re.sub("\s+"," ",line).split(" ",1)
|
||||
self.say(channel,"{}: {} (by {})".format(nick,line[1],unhighlight_nick(line[0])))
|
Loading…
Reference in New Issue