summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorMaxime “pep” Buquet <pep@bouah.net>2019-06-07 16:09:06 +0200
committerMaxime “pep” Buquet <pep@bouah.net>2019-06-07 16:09:06 +0200
commit91eabbd17d6ef85c92ac3d9711cf9fc92b22d5be (patch)
tree8841cf5aa253d9adb46bfa36b9d3d6ef5bb4e12c /plugins
parentb7fc562c888f1c71c5b462c5cb612455625d838c (diff)
downloadpoezio-91eabbd17d6ef85c92ac3d9711cf9fc92b22d5be.tar.gz
poezio-91eabbd17d6ef85c92ac3d9711cf9fc92b22d5be.tar.bz2
poezio-91eabbd17d6ef85c92ac3d9711cf9fc92b22d5be.tar.xz
poezio-91eabbd17d6ef85c92ac3d9711cf9fc92b22d5be.zip
plugins/figlet: error out when figlet doesn't exist
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
Diffstat (limited to 'plugins')
-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(