From: kaliko <kaliko@azylum.org>
Date: Sat, 15 Nov 2014 13:34:43 +0000 (+0100)
Subject: Add ping comand
X-Git-Tag: 0.1.0~43
X-Git-Url: https://git.kaliko.me/?a=commitdiff_plain;h=e518fc7f4c42f6e911d85ce8f662b3d21b6da757;p=sid.git

Add ping comand
---

diff --git a/sid/ping.py b/sid/ping.py
new file mode 100644
index 0000000..827ddb6
--- /dev/null
+++ b/sid/ping.py
@@ -0,0 +1,37 @@
+# -*- coding: utf-8 -*-
+
+# Copyright (C) 2014 kaliko <kaliko@azylum.org>
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 only.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+from .plugin import Plugin, botcmd
+
+class Ping(Plugin):
+    PongURL = 'http://upload.wikimedia.org/wikipedia/commons/f/f8/Pong.png'
+
+    def __init__(self, bot):
+        Plugin.__init__(self, bot)
+
+    @botcmd
+    def ping(self, message, args):
+        """ping's answering a pong showing the bot is alive.
+        !ping : You'll get back "pong"!
+        """
+        msg = {
+                'mhtml':'!<a href="{0.PongURL}">pong</a>'.format(self),
+                'mbody':'!pong',
+                }
+        self.send(msg)
+
+# VIM MODLINE
+# vim: ai ts=4 sw=4 sts=4 expandtab