try: from supybot.i18n import PluginInternationalization _ = PluginInternationalization('Markovgen') except ImportError: # Placeholder that allows to run the plugin on a bot # without the i18n module _ = lambda x: x try: import markovgen except ImportError: raise callbacks.Error('Cannot load markovgen library. Make sure you ' 'installed it (%s -m pip install markovgen).' % sys.executable) from imp import reload as r r(markovgen) MATCH_MESSAGE_STRIPNICK = re.compile('^(<[^ ]+> )?(?P<message>.*)$') CHANNELLOGER_REGEXP_BASE = re.compile('^[^ ]* (<[^ ]+> )?(?P<message>.*)$') CHANNELLOGER_REGEXP_STRIPNICK = re.compile( '^[^ ]* (<[^ ]+> )?(<[^ ]+> )?(?P<message>.*)$') def get_channelloger_extracter(stripRelayedNick): @markovgen.mixed_encoding_extracting def channelloger_extracter(x): regexp = CHANNELLOGER_REGEXP_STRIPNICK if stripRelayedNick else \ CHANNELLOGER_REGEXP_BASE m = regexp.match(x) if m:
import supybot.callbacks as callbacks try: from supybot.i18n import PluginInternationalization _ = PluginInternationalization('Markovgen') except ImportError: # Placeholder that allows to run the plugin on a bot # without the i18n module _ = lambda x:x try: import markovgen except ImportError: raise callbacks.Error('Cannot load markovgen library. Make sure you ' 'installed it.') from imp import reload as r r(markovgen) CHANNELLOGER_REGEXP = re.compile('^[^ ]* (<[^ ]+> )?(?P<message>.*)$') @markovgen.mixed_encoding_extracting def channelloger_extracter(x): m = CHANNELLOGER_REGEXP.match(x) if m: return m.group('message') class Markovgen(callbacks.Plugin): """Add the help for "@plugin help Markovgen" here This should describe *how* to use this plugin.""" threaded = True def __init__(self, irc): super(Markovgen, self).__init__(irc)