def ScanNotice(word, word_eol, userdata): sender = word[0] text = word_eol[1] # if it is a nickserv status request if sender == "NickServ" and text.split()[0] == "STATUS": type = word[1] type, nick, level = text.split() statusReturn(nick, level, db) # if server has identified the bot, join channels elif sender == "NickServ" and text.count("Password accepted") > 0: status["identified"] = True status["identifying"] = False statusCheck() elif sender == "ChanServ" and text == "Permission denied.": #assume bot was trying to unban self from a channel, declare channel can't be joined status["cannotJoinChans"].append(status["unbanChanList"][0]) status["unbanChanList"].pop(0) if len(status["unbanChanList"]) != 0: hexchat.command("cs unban %s" % status["unbanChanList"][0]) elif sender == "ChanServ" and text.count("You have been unbanned") > 0: hexchat.command("join %s" % status["unbanChanList"][0]) status["unbanChanList"].pop(0) if len(status["unbanChanList"]) != 0: hexchat.command("cs unban %s" % status["unbanChanList"][0]) return hexchat.EAT_PLUGIN
def text(self, width, height): """ Yields the next portion of text that fits width and height. """ if self.has_text(): block1, block2 = text.split(self._remainder, width, height, self.widows, self.orphans, self.forward) self._remainder = block2 return block1
def number(self, width, height): """ Yields the number as a string if it fits the given width and height. """ if self.has_number(): block1, block2 = text.split(str(self._remainder), width, height) if block2 == "": self._remainder = None return block1 return ""
def PointAnalysis(self, fulltext): pointlist = [] # Perform text normalization, while preserving offsets ## OLD: text = fulltext.replace('\t', '') text = fulltext.replace('\t', ' ') # new replacement text = text.replace('\n', '') print '11111111111111111111111111111111111111111111111111111111\n' * 10 print text # Find all lines starting with digit, recording offset ## OLD: m = self.pointtext_pattern.findall(text) # TODO: convert into helper function for use elsewhere (e.g., findall_with_offsets) # Commented to """ offset = 0 m = [] starts = [] ends = [] while (len(text) > 0): match = self.pointtext_pattern.search(text) if not match: break m.append(match.group(0)) starts.append(offset + match.start(0)) ends.append(offset + match.end(0)) text = text[match.end(0) : ] offset += match.end(0) if (len(m) == 0): self.logger.warn("No points detected in text: %s" % fulltext) #print"No points detected in text: %s" % fulltext """ point_text = [x.strip() for x in text.split("[ENDPOINT]") if x.strip()] print 'point_text', point_text # Create hash entries for point/text representation for i in range(0, len(point_text)): # Collect number proper and item text ## OLD: num = re.search(r'^(\d+(\.\d)?\s\.)*', m[i]).group() ##num = re.search(r'^\s*(\d+(\.\d)?\s\.)*', point_text[i]).group().strip() # Hack SKB num = re.search(r'^\s*\d+(\.|\d)*\s\.', point_text[i]).group().strip() pointlist.append({ 'Point_No': 'P' + str(num)[:-2], 'Point_Text': point_text[i][len(num):].replace('\n', ' ') }) debug_print("Standard.PointAnalysis(%s) => %s" % (fulltext, str(pointlist)), level=5) return pointlist
def text_splitter(self, text): text_splitted = text.split(" ") rec = [] s = "" for i in text_splitted: if len(s + i) < self.stroke_size: s = s + " " + i continue rec.append(s) s = " " + i rec.append(s) return rec