rateless_bot 0.1.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dcb565ed4cf49d1c3c13ea7e05238e0b3e8b4d98
4
- data.tar.gz: e3d131c54adc1783ddb3e2a643c14cb8d0a3db38
3
+ metadata.gz: 4d306de6ccac07468a7fb019147f9af6ddb274f3
4
+ data.tar.gz: ce52ba39ab6a7b75c9cd898fe821485b5fc8a48f
5
5
  SHA512:
6
- metadata.gz: 3321f44fbfd5631fc473c2be3d56181fcc56e203d1497cea81925dc316c4dc403aa6be5fb42d2fada57aa4f90146a8383473ff3cf93d181f85137c9511b7c13f
7
- data.tar.gz: 79d03b89c7c410ca88c1ae8ae6528e2fb85ac92ccf746d980f66d16ce4a87b9d8df6d397214e6275838a51bab4064cb16fcd489c43b1e4d9acc1b169c8704654
6
+ metadata.gz: 8f33192e7cf9bec0ffdcdd63a885feec37850ab33b5558e7a2f4dfdd6747033a4b8f9e773555bebabd9c57f88876f46390db35e2594256207d6ffd3597a34116
7
+ data.tar.gz: ff9c4ffd5a5dbcf2c2096101734bed97249ac5920a9aa32c07b84585781e16972c4b3bbe309c3169ec2c362d56bfde832d1522ccfc86d28cd855b5ad52da076a
data/.gitignore CHANGED
@@ -1,7 +1,5 @@
1
1
  /.bundle/
2
2
  /.yardoc
3
- /Gemfile.lock
4
- /_yardoc/
5
3
  /coverage/
6
4
  /doc/
7
5
  /pkg/
@@ -9,5 +7,8 @@
9
7
  /tmp/
10
8
  *.gem
11
9
 
10
+ # aptana studio project file
11
+ .project
12
+
12
13
  # vim swp file
13
14
  *.swp
data/Gemfile.lock ADDED
@@ -0,0 +1,49 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ rateless_bot (0.2.0)
5
+ cinch
6
+ lastfm
7
+ video_info
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ activesupport (4.2.1)
13
+ i18n (~> 0.7)
14
+ json (~> 1.7, >= 1.7.7)
15
+ minitest (~> 5.1)
16
+ thread_safe (~> 0.3, >= 0.3.4)
17
+ tzinfo (~> 1.1)
18
+ addressable (2.3.7)
19
+ cinch (2.2.4)
20
+ htmlentities (4.3.3)
21
+ httparty (0.13.3)
22
+ json (~> 1.8)
23
+ multi_xml (>= 0.5.2)
24
+ i18n (0.7.0)
25
+ json (1.8.2)
26
+ lastfm (1.26.0)
27
+ activesupport (>= 3.2.0)
28
+ httparty
29
+ xml-simple
30
+ minitest (5.5.1)
31
+ multi_json (1.11.0)
32
+ multi_xml (0.5.5)
33
+ rake (10.4.2)
34
+ thread_safe (0.3.5)
35
+ tzinfo (1.2.2)
36
+ thread_safe (~> 0.1)
37
+ video_info (2.4.2)
38
+ addressable
39
+ htmlentities
40
+ multi_json
41
+ xml-simple (1.1.5)
42
+
43
+ PLATFORMS
44
+ ruby
45
+
46
+ DEPENDENCIES
47
+ bundler (~> 1.9)
48
+ rake (~> 10.0)
49
+ rateless_bot!
data/LICENSE.txt CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2015 TODO: Write your name
3
+ Copyright (c) 2014-2015 TODO: Vincent Heuken
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
data/README.md CHANGED
@@ -1,22 +1,12 @@
1
- # RatelessBot
1
+ # Rateless Bot
2
2
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/rateless_bot`. To experiment with that code, run `bin/console` for an interactive prompt.
4
-
5
- TODO: Delete this and the text above, and describe your gem
3
+ This is an IRC Bot that I made for my IRC channel. I figured other people might want to use it.
6
4
 
7
5
  ## Installation
8
6
 
9
- Add this line to your application's Gemfile:
10
-
11
- ```ruby
12
- gem 'rateless_bot'
13
- ```
14
-
15
- And then execute:
16
-
17
- $ bundle
7
+ If you haven't already, install RubyGems. You can do this with your package manager or with [RVM](https://rvm.io)
18
8
 
19
- Or install it yourself as:
9
+ Once you have RubyGems, simply install it like so:
20
10
 
21
11
  $ gem install rateless_bot
22
12
 
data/exe/rateless_bot CHANGED
@@ -1,18 +1,59 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'rateless_bot'
4
+ require 'optparse'
5
+
6
+ options = {}
7
+
8
+ OptionParser.new do |opts|
9
+ opts.banner = "Usage: rateless_bot [options]"
10
+
11
+ opts.on("--nick NICK", "Bot's nick") do |nick|
12
+ options[:nick] = nick
13
+ end
14
+
15
+ opts.on("--server SERVER", "IRC server") do |server|
16
+ options[:server] = server
17
+ end
18
+
19
+ opts.on("--channel CHANNEL", "IRC channel") do |channel|
20
+ options[:channel] = '#' + channel
21
+ end
22
+
23
+ opts.on("--lastfm-api-key=KEY", "LastFM API key") do |key|
24
+ options[:lastfm_api_key] = key
25
+ end
26
+
27
+ opts.on("--lastfm-api-secret=SECRET", "LastFM secret API key") do |secret|
28
+ options[:lastfm_api_secret] = secret
29
+ end
30
+
31
+ opts.on("-h", "--help", "Prints this help") do
32
+ puts opts
33
+ exit
34
+ end
35
+ end.parse!
36
+ puts options
4
37
 
5
38
  bot = Cinch::Bot.new do
6
39
  configure do |c|
7
- c.nick = "Rateless-Bot"
8
- c.server = "irc.rizon.net"
9
- c.channels = ["#rateless"]
40
+ c.nick = options[:nick]
41
+ c.server = options[:server]
42
+ c.channels << options[:channel]
10
43
 
11
44
  c.plugins.plugins = [CoinFlipper,
12
- DiceRoller,
13
- Help,
14
- MagicEightBall,
45
+ DiceRoller,
46
+ Help,
47
+ LastFM,
48
+ MagicEightBall,
15
49
  VideoTitle]
50
+
51
+ c.plugins.options = {
52
+ LastFM => {
53
+ :api_key => options[:lastfm_api_key],
54
+ :api_secret => options[:lastfm_api_secret]
55
+ }
56
+ }
16
57
  end
17
58
  end
18
59
 
@@ -5,4 +5,4 @@ require_relative 'plugins/dice_roller'
5
5
  require_relative 'plugins/help'
6
6
  require_relative 'plugins/magic_eight_ball'
7
7
  require_relative 'plugins/video_title'
8
-
8
+ require_relative 'plugins/lastfm'
@@ -0,0 +1,28 @@
1
+ require 'cinch'
2
+ require 'lastfm'
3
+
4
+ class LastFM
5
+ include Cinch::Plugin
6
+
7
+ def initialize(*args)
8
+ super
9
+ @lastfm = Lastfm.new(config[:api_key], config[:api_secret])
10
+ end
11
+
12
+ match /lastfm [^\s-]/
13
+
14
+ def execute(m)
15
+ user = m.message.split('!lastfm ')[1]
16
+ scrobbles = @lastfm.user.get_recent_tracks(:user => user)
17
+ track = scrobbles[0]
18
+
19
+
20
+ m.reply make_track_str(track)
21
+ end
22
+
23
+ def make_track_str(track)
24
+ artist_and_title = track['artist']['content'] + ' - ' + track['name']
25
+
26
+ artist_and_title + (track['nowplaying'] ? ' [Now Playing]' : '')
27
+ end
28
+ end
@@ -1,3 +1,3 @@
1
1
  module RatelessBot
2
- VERSION = "0.1.0"
2
+ VERSION = "0.3.0"
3
3
  end
data/rateless_bot.gemspec CHANGED
@@ -11,7 +11,7 @@ Gem::Specification.new do |spec|
11
11
 
12
12
  spec.summary = %q{An IRC Bot}
13
13
  # spec.description = %q{TODO: Write a longer description or delete this line.}
14
- spec.homepage = "https://github.com/vheuken/Rateless-Bot"
14
+ spec.homepage = "https://github.com/vheuken/rateless_bot"
15
15
  spec.license = "MIT"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
@@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency "cinch"
26
26
  spec.add_dependency "video_info"
27
+ spec.add_dependency "lastfm"
27
28
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rateless_bot
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vincent Heuken
@@ -66,6 +66,20 @@ dependencies:
66
66
  - - ">="
67
67
  - !ruby/object:Gem::Version
68
68
  version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: lastfm
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
69
83
  description:
70
84
  email:
71
85
  - me@vincentheuken.com
@@ -76,6 +90,7 @@ extra_rdoc_files: []
76
90
  files:
77
91
  - ".gitignore"
78
92
  - Gemfile
93
+ - Gemfile.lock
79
94
  - LICENSE.txt
80
95
  - README.md
81
96
  - Rakefile
@@ -87,11 +102,12 @@ files:
87
102
  - lib/rateless_bot/plugins/coin_flipper.rb
88
103
  - lib/rateless_bot/plugins/dice_roller.rb
89
104
  - lib/rateless_bot/plugins/help.rb
105
+ - lib/rateless_bot/plugins/lastfm.rb
90
106
  - lib/rateless_bot/plugins/magic_eight_ball.rb
91
107
  - lib/rateless_bot/plugins/video_title.rb
92
108
  - lib/rateless_bot/version.rb
93
109
  - rateless_bot.gemspec
94
- homepage: https://github.com/vheuken/Rateless-Bot
110
+ homepage: https://github.com/vheuken/rateless_bot
95
111
  licenses:
96
112
  - MIT
97
113
  metadata: {}