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

Add ability to watch for new trucks #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sethkrasnianski
Copy link
Member

No description provided.

This acts similar to the existing question, instead if "watch" is present then
it will find the provided twitter handle and either save it or notify the user
that we already are keeping an eye on it.

if Regex.run ~r/<@#{slack.me.id}>:?\s+.*watch.*/, message.text do
twitter_regex = ~r/(?<=^|(?<=[^a-zA-Z0-9-_\.]))@([A-Za-z]+[A-Za-z0-9]+)/
truck_handle = Regex.scan(twitter_regex, message.text) |> List.last |> List.first
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we only seem to care about the first match here, it might make sense to use run/3 instead of scan/3 here. Will keep us from doing the (somewhat) wonky |> List.last |> List.first at the end.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, we don't seem to be handling nil results in the scan here. We just pass it along to Trucks.watch/3, but I dont see a pattern there either that cases nil inputs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants