def privateAction(self, connection, user, channel, message): matches = self.privateMatch.findall(message) print "[Define] %s" % matches try: result, src = self.getDefinition(matches[0]) except: connection.message( user, "%s: There is no such word as '%s' in my dictionary. In fact, everything between 'herring' and 'marmalade' appears to be completely missing." % (user, matches[0])) return True print "[Define] %s" % result if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.message(user, "%s... " % stringOne) connection.message(user, "... %s" % stringTwo) else: connection.message(user, "%s" % result) return True
def privateAction(self, connection, user, channel, message): matches = self.privateMatch.findall(message) print "[Bible] %s" % matches bibleConnection = bible.ESVSession() result = bibleConnection.doPassageQuery('%s %s' % (matches[0][0], matches[0][1])) result = ' '.join(result.split('\n')) if len(result) > 880 * 2: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(user, "%s... " % stringOne) connection.msg(user, "... %s [ESV]" % stringTwo) else: connection.msg(user, "%s [ESV]" % result) return True
def privateAction(self, connection, user, channel, message): matches = self.privateMatch.findall(message) self.logger.info("[Define] %s" % matches) try: result, src = self.getDefinition(matches[0]) except: connection.message( user, "%s: There is no such word as '%s' in my dictionary. In fact, everything between 'herring' and 'marmalade' appears to be completely missing." % (user, matches[0])) return True self.logger.info("[Define] %s" % result) if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.message(user, "%s... " % stringOne) connection.message(user, "... %s" % stringTwo) else: connection.message(user, "%s" % result) return True
def channelAction(self, connection, user, channel, message): matches = self.channelMatch.findall(message); if self.overUsed(): connection.msg(user, "Enough with the religion for now. (Overuse triggered)") return print "[Bible] %s" % matches bibleConnection = bible.ESVSession() result = bibleConnection.doPassageQuery('%s %s' % (matches[0][0], matches[0][1])) result = ' '.join(result.split('\n')) self.updateOveruse() if len(result) > 880*2: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(channel, "%s... " % stringOne) connection.msg(channel, "... %s [ESV]" % stringTwo) else: connection.msg(channel, "%s [ESV]" % result) return True
def channelAction(self, connection, user, channel, message): matches = self.channelMatch.findall(message); print "[Define] %s" % matches if self.overUsed(): connection.msg(user, "The dictionary is on fire. Leave it alone. (Overuse triggered)") return self.updateOveruse() try: result, src = self.getDefinition(matches[0]) except: connection.msg(channel, "%s: There is no such word as '%s' in my dictionary. In fact, everything between 'herring' and 'marmalade' appears to be completely missing." % (user, matches[0])) return True print "[Define] %s" % result if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(channel, "%s... " % stringOne) connection.msg(channel, "... %s" % stringTwo) else: connection.msg(channel, "%s" % result) return True
def privateAction(self, connection, user, channel, message): matches = self.privateMatch.findall(message) print "[Bible] %s" % matches bibleConnection = bible.ESVSession() result = bibleConnection.doPassageQuery( '%s %s' % (matches[0][0], matches[0][1])) result = ' '.join(result.split('\n')) if len(result) > 880 * 2: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.message(user, "%s... " % stringOne) connection.message(user, "... %s [ESV]" % stringTwo) else: connection.message(user, "%s [ESV]" % result) return True
def channelAction(self, connection, user, channel, message): matches = self.channelMatch.findall(message) if self.overUsed(): connection.msg( user, "Enough with the religion for now. (Overuse triggered)") return print "[Bible] %s" % matches bibleConnection = bible.ESVSession() result = bibleConnection.doPassageQuery('%s %s' % (matches[0][0], matches[0][1])) result = ' '.join(result.split('\n')) self.updateOveruse() if len(result) > 880 * 2: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(channel, "%s... " % stringOne) connection.msg(channel, "... %s [ESV]" % stringTwo) else: connection.msg(channel, "%s [ESV]" % result) return True
def getLiteral(self, connection, user, channel, message, matches): key = matches if not user.lower() in self.admin: row = self.define(key) if row: connection.msg(channel, "%s: %s is *literally* \"%s\"" % (user, row[0], row[1])) self.blame = row[2] self.lastasked2 = self.lastasked self.lastasked = key self.answered = row[1] return True else: connection.msg(channel, "%s: Literally No Clue" % user) return True cursor = self.dbconnection.cursor() query = "Select word,definition,author from define where lower(word) = %s" cursor.execute(query, (key.lower(), ) ) defines = [] rows = cursor.fetchall() for row in rows: defines.append(row[1]) if len(defines) > 1: result = '"' result += "\", \"".join(defines[0:-1]) result += "\" & \"%s\"" % defines[-1] elif len(defines) == 1: result = defines[0] else: result = "No idea" if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(channel, "%s... " % stringOne) connection.msg(channel, "... %s" % stringTwo) else: connection.msg(channel, "%s" % result) return True
def getLiteral(self, connection, user, channel, message, matches): key = matches if not user.lower() in self.admin: row = self.define(key) if row: connection.message( channel, "%s: %s is *literally* \"%s\"" % (user, row[0], row[1])) self.blame = row[2] self.lastasked2 = self.lastasked self.lastasked = key self.answered = row[1] return True else: connection.message(channel, "%s: Literally No Clue" % user) return True cursor = self.dbconnection.cursor() query = "Select word,definition,author from define where lower(word) = %s" cursor.execute(query, (key.lower(), )) defines = [] rows = cursor.fetchall() for row in rows: defines.append(row[1]) if len(defines) > 1: result = '"' result += "\", \"".join(defines[0:-1]) result += "\" & \"%s\"" % defines[-1] elif len(defines) == 1: result = defines[0] else: result = "No idea" if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.message(channel, "%s... " % stringOne) connection.message(channel, "... %s" % stringTwo) else: connection.message(channel, "%s" % result) return True
def privateAction(self, connection, user, channel, message): self.channel = "PM"; print "[WHOWAS] privately requested" if self.privateMatch.match(message): matches = self.privateMatch.findall(message) searchingfor = matches[0] if searchingfor[-1:] == "?": searchingfor = searchingfor[0:-1] space = re.compile(".*\s.*") if searchingfor.lower() == "your mum": connection.msg(user, "%s: Not since she took on one piece of crumpet too many" % user) elif space.match(searchingfor): connection.msg(user, "No idea, %s. Have you looked under the sofa?" % user) elif searchingfor.lower() == user.lower(): connection.msg(user, "Yes. You're over there. Hello %s. Did you want a cookie or something?" % user) elif searchingfor.lower() == connection.nickname.lower(): connection.msg(user, "I'm right here.") else: result = self.lastseen(searchingfor); if searchingfor in connection.people: result = "%s, plus, I think they're online right now.!" % (result) if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(user, "%s... " % stringOne.encode('utf8')) connection.msg(user, "... %s" % stringTwo.encode('utf8')) else: connection.msg(user, result.encode('utf8'))
def channelAction(self, connection, user, channel, message): if self.overUsed(): connection.msg(channel, "I'm out of boxes, new delivery shortly.") return print "[Box] called " level = random.randint(1,5); sock = urllib.urlopen('http://www.warehouse23.com/basement/box/index.html?level=%d' % level) box = sock.read() description = re.findall('<p>\n(.*)\n</p>', box, re.MULTILINE)[0]; result = 'In a box on level %d, I found: %s ' % (level, description) result = ' '.join(result.split('\n')) result = re.sub(r'<[^>]*?>', '', result) self.updateOveruse() if len(result) > 880*2: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(channel, "%s... " % stringOne) connection.msg(channel, "... %s" % stringTwo) else: connection.msg(channel, "%s" % result) return True
def channelAction(self, connection, user, channel, message): matches = self.channelMatch.findall(message) print "[Define] %s" % matches if self.overUsed(): connection.msg( user, "The dictionary is on fire. Leave it alone. (Overuse triggered)" ) return self.updateOveruse() try: result, src = self.getDefinition(matches[0]) except: connection.msg( channel, "%s: There is no such word as '%s' in my dictionary. In fact, everything between 'herring' and 'marmalade' appears to be completely missing." % (user, matches[0])) return True print "[Define] %s" % result if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(channel, "%s... " % stringOne) connection.msg(channel, "... %s" % stringTwo) else: connection.msg(channel, "%s" % result) return True
def splitDefinition(self, result): string = [] if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] string.append("%s" % result) self.logger.info(string) return string
def splitDefinition(self, result): string = [] if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] string.append("%s" % result) print string return string
def channelAction(self, connection, user, channel, message): self.logger.info("[WHOWAS] requested") self.channel = channel matches = self.channelMatch.findall(message) searchingfor = matches[0] if searchingfor[-1:] == "?": searchingfor = searchingfor[0:-1] space = re.compile(".*\s.*") if searchingfor.lower() == "your mum": connection.message( channel, "%s: Not since she took on one piece of crumpet too many" % user) elif space.match(searchingfor): connection.message( channel, "No idea, %s. Have you looked under the sofa?" % user) elif searchingfor.lower() == user.lower(): connection.message( channel, "Yes. You're over there. Hello %s. Did you want a cookie or something?" % user) elif searchingfor.lower() == connection.nickname.lower(): connection.message(channel, "I'm right here.") else: result = self.lastseen(searchingfor) if searchingfor in connection.people: result = "%s. Also, I think they're currently online!" % ( result) if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.message(channel, "%s... " % stringOne) connection.message(channel, "... %s" % stringTwo) else: connection.message(channel, result) return True
def privateAction(self, connection, user, channel, message): self.channel = "PM" print "[WHOWAS] privately requested" if self.privateMatch.match(message): matches = self.privateMatch.findall(message) searchingfor = matches[0] if searchingfor[-1:] == "?": searchingfor = searchingfor[0:-1] space = re.compile(".*\s.*") if searchingfor.lower() == "your mum": connection.msg( user, "%s: Not since she took on one piece of crumpet too many" % user) elif space.match(searchingfor): connection.msg( user, "No idea, %s. Have you looked under the sofa?" % user) elif searchingfor.lower() == user.lower(): connection.msg( user, "Yes. You're over there. Hello %s. Did you want a cookie or something?" % user) elif searchingfor.lower() == connection.nickname.lower(): connection.msg(user, "I'm right here.") else: result = self.lastseen(searchingfor) if searchingfor in connection.people: result = "%s, plus, I think they're online right now.!" % ( result) if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(user, "%s... " % stringOne.encode('utf8')) connection.msg(user, "... %s" % stringTwo.encode('utf8')) else: connection.msg(user, result.encode('utf8'))
def channelAction(self, connection, user, channel, message): matches = self.channelMatch.findall(message); print "[Define] %s" % matches if self.overUsed(): connection.msg(user, "The dictionary is on fire. Leave it alone. (Overuse triggered)") return self.updateOveruse() specialDict = { 'foip' : 'FOIP (\'Find Out In Play\') is any information you have that another character in the system does not have. Therefore, it is anything not on the website, in the almanac or in the rules books. Broadcasting this is a kickable offence on #maelfroth. If someone claims what you are talking about is FOIP, you need to stop talking about it as you may be damaging the game of others.', 'herring': 'Type of fish. There is nothing between it and Marmalade it in my dictionary. My dictionary is not in alphabetical order, which is why it still has "kelp"', 'marmalade' : 'A type of citrus-based conserve. There is nothing before it in my dictionary until "herring". My dictionary is oddly ordered, however, so it still contains "Lemur"', 'catbus' : 'You don\'t want to know.', 'glados' : '*happy sigh*', 'lampstand' : "That's me. Hi there", 'hal' : 'grrrrr.', 'inconceivable' : 'adj. Not what you think it means.', #'tenant' : 'n. An opinion, doctrine, or principle held as being true by a person or especially by an organization', #'tenet' : 'n. One that pays rent to use or occupy land, a building, or other property owned by another.' } if specialDict.has_key(matches[0].lower()): connection.msg(channel, "%s" % specialDict[matches[0].lower()]) return try: dictcxn = dictclient.Connection("dict.org") dfn = dictcxn.define("*", matches[0]) except socket.error: print "[Define] Argh. Dictionary server's offline" connection.msg(channel, "Sorry, but my dictionary server's not working.") return True if not dfn: connection.msg(channel, "%s: There is no such word as '%s' in my dictionary. In fact, everything between 'herring' and 'marmalade' appears to be completely missing." % (user, matches[0])) return True result = ' '.join(dfn[0].getdefstr().split('\n')) print "[Define] %s" % result if len(result) > 880: whereToSplit = splitAt(result, 860) result = "%s [Cut for length]" % result[0:whereToSplit] if len(result) > 440: whereToSplit = splitAt(result, 440) stringOne = result[0:whereToSplit] stringTwo = result[whereToSplit:] connection.msg(channel, "%s... " % stringOne) connection.msg(channel, "... %s" % stringTwo) else: connection.msg(channel, "%s" % result) return True