Allow !latest to accept strings for regex matches #6

Merged
khuxkm merged 4 commits from tomasino/cosmicbot:latest-regex into master 2019-02-13 19:18:35 +00:00
Contributor

The shell command latest now includes post number in the output. After seeing people in the IRC channel attempt to get the latest posts by ship name, I've implemented that feature in the shell. Passing an int to latest gives that number of entries. Passing a string does a grep -i search and returns up to 5 results.

The shell command `latest` now includes post number in the output. After seeing people in the IRC channel attempt to get the latest posts by ship name, I've implemented that feature in the shell. Passing an int to `latest` gives that number of entries. Passing a string does a `grep -i` search and returns up to 5 results.
Author
Contributor

There might be some extra variable casting necessary. I'm not sure if the bot interprets all params as strings, even numeric ones. If that's the case then the isinstance probably needs to be replaced with a regex test instead.

I'm not sure of a way to test these changes prior to PR, sadly.

There *might* be some extra variable casting necessary. I'm not sure if the bot interprets all params as strings, even numeric ones. If that's the case then the isinstance probably needs to be replaced with a regex test instead. I'm not sure of a way to test these changes prior to PR, sadly.
Owner

@tomasino All params are strings. Probably you could do:

if re.match(r"d+",count): count = int(count)
@tomasino All params are strings. Probably you could do: ```python if re.match(r"d+",count): count = int(count) ```
Author
Contributor

Updated the code to reflect that test.

Updated the code to reflect that test.
Owner

Please update the "Latest entry from" message for the case that it's a string and not a number.

Please update the "Latest entry from" message for the case that it's a string and not a number.
Author
Contributor

I've provided a different message for non-numeric searches.

I've provided a different message for non-numeric searches.
Owner

Will it work with the weird indent on else?

Will it work with the weird indent on `else`?
Author
Contributor

No, it definitely wouldn't. Vim was expanding tabs, sadly. I've fixed the indenting. Do you want me to squash these commits down prior to merge?

No, it definitely wouldn't. Vim was expanding tabs, sadly. I've fixed the indenting. Do you want me to squash these commits down prior to merge?
Owner

No, I'll merge as is. Thanks!

No, I'll merge as is. Thanks!
khuxkm closed this pull request 2019-02-13 19:18:35 +00:00
Sign in to join this conversation.
No reviewers
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: khuxkm/cosmicbot#6
No description provided.