Add toot plugin
This commit is contained in:
parent
b98293bdef
commit
2653cc4633
|
@ -13,4 +13,5 @@ class DictData(plugin.JSONData):
|
|||
def __contains__(self,k):
|
||||
return k in self.value
|
||||
def get(self,k,default=None):
|
||||
self.load(self.filename)
|
||||
return self.value.get(k,default)
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
import plugin,subprocess,dictdata
|
||||
|
||||
def do_toot(s,json="/usr/local/bin/tildeverse"):
|
||||
return subprocess.run(["/usr/local/bin/toot",s],env=dict(TOOT_JSON_PATH=json,LC_ALL="C.UTF-8",LANG="C.UTF-8")).returncode
|
||||
|
||||
toot_paths = dictdata.DictData("toot_paths.json")
|
||||
|
||||
@plugin.command("toot")
|
||||
def toot(bot,channel,nick,*args):
|
||||
if do_toot(" ".join(args),toot_paths.get(channel,"/usr/local/bin/tildeverse"))!=0:
|
||||
bot.say(channel,"{}: Toot failed!".format(nick))
|
||||
else:
|
||||
bot.say(channel,"{}: Toot sent!".format(nick))
|
Reference in New Issue