Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

find: shameless micro-optimizations #2267

Merged
merged 1 commit into from
Mar 15, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions sopel/modules/find.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ def shutdown(bot):
@plugin.unblockable
def collectlines(bot, trigger):
"""Create a temporary log of what people say"""
line = trigger.group()
if line.startswith('s/') or line.startswith('s|'):
# Don't remember substitutions
return

# Add a log for the channel and nick, if there isn't already one
if trigger.sender not in bot.memory['find_lines']:
bot.memory['find_lines'][trigger.sender] = SopelIdentifierMemory(
Expand All @@ -52,14 +57,10 @@ def collectlines(bot, trigger):

# Update in-memory list of the user's lines in the channel
line_list = bot.memory['find_lines'][trigger.sender][trigger.nick]
line = trigger.group()
if line.startswith('s/') or line.startswith('s|'):
# Don't remember substitutions
return
# store messages in reverse order (most recent first)
elif line.startswith('\x01ACTION'): # For /me messages
line = line[:-1]
line_list.appendleft(line)

# Messages are stored in reverse order (most recent first)
if line.startswith('\x01ACTION'):
line_list.appendleft(line[:-1])
else:
line_list.appendleft(line)

Expand Down