from __future__ import unicode_literals
import re

crontable = []
outputs = []

state = {}


class ClueState:

    def __init__(self):
        self.count = 0
        self.clue = ''

def process_message(data):

    channel = data['channel']
    if channel not in state.keys():
        state[channel] = ClueState()

    st = state[channel]

    # Count the number of messages we have seen in this channel since
    # stony last repeated a clue.
    st.count = st.count + 1

    if re.search("\n?\s*&gt;", data['text']):
        st.clue = data['text']
        st.count = 1
    else:
        if st.count % 10 == 0:
            outputs.append([channel, st.clue])

from __future__ import unicode_literals
import re

crontable = []
outputs = []

state = {}


class ClueState:

    def __init__(self):
        self.count = 0
        self.clue = ''

def process_message(data):

    channel = data['channel']
    if channel not in state.keys():
        state[channel] = ClueState()

    st = state[channel]

    # Count the number of messages we have seen in this channel since
    # stony last repeated a clue.
    st.count = st.count + 1

    if re.search("^\s*&gt;", data['text'], re.MULTILINE):
        st.clue = data['text']
        st.count = 1
    else:
        if st.count % 10 == 0:
            outputs.append([channel, st.clue])

Fix to only match '>' at the beginning of a line
Fix to only match '>' at the beginning of a line

Which was the intention with the '\n' in the pattern before, but I had
made it optional for the common case of the '>' being at the beginning
of the message, which of course had the side effect of allowing the
'>' to be matched anywhere (bleh).

Now, with a MULTLINE-mode regexp and '^' in the pattern, the '>' will
only be treated as significant at the beginning of a line, (preceded
by optional whitespace).
