Created
March 31, 2014 10:50
-
-
Save tomblench/9889760 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
import string | |
from errbot import BotPlugin, botcmd | |
class ofhave(BotPlugin): | |
def callback_message(self, conn, mess): | |
reply = self.couldShould(mess.getBody()) | |
if reply: | |
self.send( | |
mess.getFrom(), | |
reply, | |
message_type=mess.getType() | |
) | |
def couldShould(me, sentence) : | |
pronMap = {"i": "you", | |
"you": "you", | |
"they": "they", | |
"we": "you", | |
"he": "he", | |
"she": "she", | |
"it": "it"}; | |
# (could should would won't can't) | |
m = re.search("(I|you|they|we|he|she|it)\s+(could|couldn't|should|shouldn't|would|wouldn't|won't|will not|can't|cannot|can not)(\s+have|'ve)\s+([^-.;,]*)", sentence, re.I); | |
if (m) : | |
return (pronMap[m.group(1).lower()] + " " + m.group(2) + " of " + m.group(4) + "!"); | |
return None | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment