Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

plugins:Add plugin for saying no to 'sir' #651

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class name not starting with caps 😱

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thats by mistake @meetmangukiya i will correct all the issues now in this pr

"""
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(
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove comma after mentioning the user!
Although the returned message is OK, I guess it could be more informative.
What do you think @sladyn98?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@KVGarg Definitely if you have any suggestions you could have written here :)

Copy link

@KVGarg KVGarg Apr 23, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess we can frame a message somewhat like this

Hi @<username> :wave:! We don't use "Sir" in the community during the 
conversation. It's perfectly fine to call them via there usernames or handle. 
Also, If you want to do such think you can better go with buddy or something else :smiley: 

Something like this the message can be framed!

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()

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The assert statement does not match the bot output message, the test would always throw an assertion error because of the missing emot at the end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sladyn98 it's in

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@meetmangukiya Yeah your right,so it would pass, but it would be better to keep the outputs same although it doesnt matter :)