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

!manga and !anime commands #62

Merged
merged 8 commits into from Oct 20, 2017

Conversation

Projects
None yet
2 participants
@winny-
Copy link
Contributor

winny- commented Oct 17, 2017

Had to run bundle update, but it appears to not break anything :)))))

Babby's first cherry pick!

!manga and !anime commands
Had to run bundle update, but it appears to not break anything :)))))

Babby's first cherry pick!
end

def usage
'!<anime|manga> <search> - Search MyAnimeList for anime or manga.'

This comment has been minimized.

@woodruffw

woodruffw Oct 17, 2017

Owner

Instead of !anime and !manga, what do you think about just !mal? It looks like both use the same method call/API endpoint anyways.

This comment has been minimized.

This comment has been minimized.

@woodruffw

woodruffw Oct 17, 2017

Owner

Oh, I didn't see the conditional in search. Never mind then!

begin
res = type == 'anime' ? MyAnimeList.search_anime(query) : MyAnimeList.search_manga(query)
rescue MyAnimeList::ApiException
m.reply 'No results for ' + type + ' "' + query + '".', true

This comment has been minimized.

@woodruffw

woodruffw Oct 17, 2017

Owner

This and the string building below can be cleaned up a bit through use of interpolation:

m.reply "No results for '#{query}'.", true

This comment has been minimized.

@winny-

winny- Oct 17, 2017

Author Contributor

Good catch, thx

url = "http://myanimelist.net/#{type}/#{first['id']}"
title = first['title'].strip

syn = @entities.decode(first['synopsis']).strip

This comment has been minimized.

@woodruffw

woodruffw Oct 17, 2017

Owner

Prefer double quotes everywhere, even when you're not doing interpolation.


m.reply "#{url} #{title}#{maybe_english} -- #{syn}", true
else
m.reply "No results for #{type} \"#{query}\"", true

This comment has been minimized.

@woodruffw

woodruffw Oct 17, 2017

Owner

Use single quotes for quoting inside a string, instead of escaping double quotes.

Gemfile Outdated
@@ -27,3 +27,5 @@ gem "time_difference"
gem "wolfram"
gem "wunderground"
gem "xkcd"
gem 'myanimelist', '~> 1.0'

This comment has been minimized.

@woodruffw

woodruffw Oct 17, 2017

Owner

Double quotes here too.

res = nil
end

if !res.nil? && res.any? then

This comment has been minimized.

@woodruffw

woodruffw Oct 17, 2017

Owner

You can do safe navigation here, and drop the then:

if res&.any?
@woodruffw

This comment has been minimized.

Copy link
Owner

woodruffw commented Oct 19, 2017

Now that #65 is merged, let's add MAL_USERNAME and MAL_PASSWORD to the config.yml.example as stubs.

@woodruffw woodruffw merged commit 42e8575 into woodruffw:master Oct 20, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment