Skip to content

Commit

Permalink
Plugins: Add plugin for saying no to 'sir'.
Browse files Browse the repository at this point in the history
we have added a plugin and related test
to prevent any contributor from saying sir.

Closes #337
  • Loading branch information
AkshJain99 committed Mar 10, 2019
1 parent 1de93b6 commit 44f2db5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 0 deletions.
11 changes: 11 additions & 0 deletions plugins/no_sir.plug
Original file line number Diff line number Diff line change
@@ -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]
20 changes: 20 additions & 0 deletions plugins/no_sir.py
Original file line number Diff line number Diff line change
@@ -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

)
)
9 changes: 9 additions & 0 deletions tests/no_sir_test.py
Original file line number Diff line number Diff line change
@@ -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()

0 comments on commit 44f2db5

Please sign in to comment.