summaryrefslogtreecommitdiff
path: root/plugins/figlet.py
diff options
context:
space:
mode:
authorMadhur Garg <madhurgarg96@gmail.com>2019-06-18 01:59:59 +0530
committerMadhur Garg <madhurgarg96@gmail.com>2019-06-18 01:59:59 +0530
commitb881bfad964c69b0a2fdea560d7b59fd5c825709 (patch)
tree121ef7def819dcf41cc7a036e1985d3e2ab4b6df /plugins/figlet.py
parentd528a2ff557a5c01f5d9cab6c67034c9237497f3 (diff)
parentd35256ccc9cd205aa72a5599ab25db7cd7263527 (diff)
downloadpoezio-b881bfad964c69b0a2fdea560d7b59fd5c825709.tar.gz
poezio-b881bfad964c69b0a2fdea560d7b59fd5c825709.tar.bz2
poezio-b881bfad964c69b0a2fdea560d7b59fd5c825709.tar.xz
poezio-b881bfad964c69b0a2fdea560d7b59fd5c825709.zip
Merge https://lab.louiz.org/poezio/poezio
Diffstat (limited to 'plugins/figlet.py')
-rw-r--r--plugins/figlet.py22
1 files changed, 21 insertions, 1 deletions
diff --git a/plugins/figlet.py b/plugins/figlet.py
index b8fcb813..4d4c7577 100644
--- a/plugins/figlet.py
+++ b/plugins/figlet.py
@@ -11,15 +11,35 @@ Say something in a Chat tab.
.. note:: Can create fun things when used with :ref:`The rainbow plugin <rainbow-plugin>`.
"""
-from poezio.plugin import BasePlugin
+
import subprocess
+from poezio.plugin import BasePlugin
+
+
+def is_figlet() -> bool:
+ """Ensure figlet exists"""
+ process = subprocess.Popen(
+ ['which', 'figlet'],
+ stdout=subprocess.DEVNULL,
+ stderr=subprocess.DEVNULL,
+ )
+ return process.wait() == 0
class Plugin(BasePlugin):
def init(self):
+ if not is_figlet():
+ self.api.information(
+ 'Couldn\'t find the figlet program. '
+ 'Please install it and reload the plugin.',
+ 'Error',
+ )
+ return None
+
self.api.add_event_handler('muc_say', self.figletize)
self.api.add_event_handler('conversation_say', self.figletize)
self.api.add_event_handler('private_say', self.figletize)
+ return None
def figletize(self, msg, tab):
process = subprocess.Popen(