From 44f2db5f40600121907d695661b4de2d8fe8395e Mon Sep 17 00:00:00 2001 From: Akshit jain Date: Sun, 10 Mar 2019 04:23:38 +0530 Subject: [PATCH] Plugins: Add plugin for saying no to 'sir'. we have added a plugin and related test to prevent any contributor from saying sir. Closes https://github.com/coala/corobo/issues/337 --- plugins/no_sir.plug | 11 +++++++++++ plugins/no_sir.py | 20 ++++++++++++++++++++ tests/no_sir_test.py | 9 +++++++++ 3 files changed, 40 insertions(+) create mode 100644 plugins/no_sir.plug create mode 100644 plugins/no_sir.py create mode 100644 tests/no_sir_test.py diff --git a/plugins/no_sir.plug b/plugins/no_sir.plug new file mode 100644 index 00000000..86239268 --- /dev/null +++ b/plugins/no_sir.plug @@ -0,0 +1,11 @@ +[Core] +name = no_sir +module = no_sir + +[Documentation] +description = Tell people to not use 'sir' when they do. + +[Python] +version = 3 + +[Errbot] diff --git a/plugins/no_sir.py b/plugins/no_sir.py new file mode 100644 index 00000000..be685f60 --- /dev/null +++ b/plugins/no_sir.py @@ -0,0 +1,20 @@ +import re +from errbot import BotPlugin + + +class no_sir(BotPlugin): + """ + Do not use sir + """ + + def callback_message(self, msg): + emots = [':D'] + match_sir = re.search(r'\bsir\b', '\bSir\b', msg.body) + if match_sir: + self.send( + msg.frm, + '@{}, Do not use sir in your conversation. {}'.format( + msg.frm.nick + + ) + ) diff --git a/tests/no_sir_test.py b/tests/no_sir_test.py new file mode 100644 index 00000000..83ee5939 --- /dev/null +++ b/tests/no_sir_test.py @@ -0,0 +1,9 @@ +import plugins.no_sir + + +class Test_no_sir(object): + extra_plugin_dir = '.' + + def test_no_sir(self, testbot): + testbot.push_message(r'\bsir\b', '\bSir\b', msg.body) + assert 'Do not use sir in your conversation' in testbot.pop_message()