Class: Cinch::Plugins::Starcraft::Ranks
- Inherits:
-
Object
- Object
- Cinch::Plugins::Starcraft::Ranks
- Includes:
- Cinch::Plugin
- Defined in:
- lib/cinch/plugins/starcraft/ranks.rb
Instance Method Summary collapse
- #help(m) ⇒ Object
-
#initialize(*args) ⇒ Ranks
constructor
A new instance of Ranks.
-
#rank(m) ⇒ Object
Display current rank for yourself.
-
#rank_nick(m, nick) ⇒ Object
Display <nick>‘s current rank.
-
#refresh(m) ⇒ Object
Queue refresh for yourself.
-
#refresh_nick(m, nick) ⇒ Object
Queue refresh for <nick>.
-
#set(m, args) ⇒ Object
Usage: To set your own Starcraft II user !sc2set sc2ranks.com/#region/#bnetid/#username To set another Starcraft II user !sc2set <nick> sc2ranks.com/#region/#bnetid/#username.
Constructor Details
#initialize(*args) ⇒ Ranks
Returns a new instance of Ranks.
17 18 19 20 |
# File 'lib/cinch/plugins/starcraft/ranks.rb', line 17 def initialize(*args) super start_rss_thread end |
Instance Method Details
#help(m) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/cinch/plugins/starcraft/ranks.rb', line 47 def help(m) m.reply "Display current rank for a Starcraft II player" m.reply "!sc2rank - Display your current rank" m.reply "!sc2rank <nick> - Display <nick>'s current rank" m.reply "!sc2set <url> - Set your profile URL" m.reply "!sc2set <nick> <url> - Set <nick>'s profile URL" m.reply "!sc2refresh - Queue a refresh for yourself" m.reply "!sc2refresh <nick> - Queue a refresh for your <nick>" m.reply "To get your SC2ranks URL, visit http://sc2ranks.com" m.reply "Author: Logan Koester <[email protected]>" end |
#rank(m) ⇒ Object
Display current rank for yourself
80 81 82 83 84 85 86 87 |
# File 'lib/cinch/plugins/starcraft/ranks.rb', line 80 def rank(m) user = User.find_by_nick(m.user.nick.downcase) if user display_rank(m, user) else m.reply "Your nick is not registered, use !sc2set (!sc2help for more info)" end end |
#rank_nick(m, nick) ⇒ Object
Display <nick>‘s current rank
90 91 92 93 94 95 96 97 |
# File 'lib/cinch/plugins/starcraft/ranks.rb', line 90 def rank_nick(m, nick) user = User.find_by_nick(nick.downcase) if user display_rank(m, user) else m.reply "That nick is not registered, use !sc2set (!sc2help for more info)" end end |
#refresh(m) ⇒ Object
Queue refresh for yourself
60 61 62 63 64 65 66 67 |
# File 'lib/cinch/plugins/starcraft/ranks.rb', line 60 def refresh(m) user = User.find_by_nick(m.user.nick.downcase) if user m.reply "#{user.nick}: #{user.queue_refresh!}" else m.reply "That nick is not registered, use !sc2set (!sc2help for more info)" end end |
#refresh_nick(m, nick) ⇒ Object
Queue refresh for <nick>
70 71 72 73 74 75 76 77 |
# File 'lib/cinch/plugins/starcraft/ranks.rb', line 70 def refresh_nick(m, nick) user = User.find_by_nick(nick.downcase) if user m.reply "#{user.nick}: #{user.queue_refresh!}" else m.reply "That nick is not registered, use !sc2set (!sc2help for more info)" end end |
#set(m, args) ⇒ Object
Usage:
To set your own Starcraft II user
!sc2set http://sc2ranks.com/#{region}/#{bnetid}/#{username}
To set another Starcraft II user
!sc2set <nick> http://sc2ranks.com/#{region}/#{bnetid}/#{username}
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/cinch/plugins/starcraft/ranks.rb', line 27 def set(m, args) args = args.split(" ") # Optional nickname parameter if args.size > 1 nick = args[0].downcase url = args[1] else nick = m.user.nick.downcase url = args[0] end user = User.find_by_nick(nick) user = User.create(:nick => nick) unless user user.update_from_url(url) user.save restart_rss_thread m.reply "#{user.nick}'s battle.net user set to #{user.username}, Battle.net ID #{user.bnetid}" end |