descartes 0.3.12 → 0.3.13

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: 634c0cfd23a887e6eb8fe17f918380346022f097
4
- data.tar.gz: 33c225011be954c5cc93881de00193df8d805ae2
3
+ metadata.gz: 0a3bc14f871a16d06a72a43d19022257ad20f83a
4
+ data.tar.gz: db9b1e43fc1839133f5d633dd8277292ab5f51b3
5
5
  SHA512:
6
- metadata.gz: e4610faff31930c5678ae26ebf3a3e1a53ed5f26d10cc76a910880079925db3213546152cb6b20b35f42bfa4f46f2b83aae663110cc88f58b6b9f8618734a82c
7
- data.tar.gz: 247aaa2a57e3b67257b17ae120462b9c73bb09648f7735288d77aa029ab90bc387570bda9a24c383471ae27120753d1897a86fcae90f5afd49aacc482757abbc
6
+ metadata.gz: 7df8ba572ba08a42e8506b8ddf5959fd7c65e992f93c04ddf8be18093a502e4927d88659844f33506d66122b68ac7acd67c07b6e02382644131ae27fbe490931
7
+ data.tar.gz: 8d5e03890c017803f7bb641dc4b52294947584e42fe9772aa10426f8508cce000dd72e9dfc27bf04b52302a4d3eb6fe2d778498d411c432d8f79cc42ca13c975
@@ -0,0 +1,91 @@
1
+ ##
2
+ ## DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
3
+ ## Version 2, December 2004
4
+ ##
5
+ ## Everyone is permitted to copy and distribute verbatim or modified
6
+ ## copies of this license document, and changing it is allowed as long
7
+ ## as the name is changed.
8
+ ##
9
+ ## DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
10
+ ## TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
11
+ ##
12
+ ## 0. You just DO WHAT THE FUCK YOU WANT TO.
13
+ ##
14
+
15
+ require 'rockstar'
16
+ require 'yaml'
17
+ require 'fileutils'
18
+
19
+ class Descartes
20
+ class LastFm
21
+ include Cinch::Plugin
22
+
23
+ def authenticate!
24
+ Rockstar.lastfm = {
25
+ :api_key => 'bc15f325a6aa7dcc4e8d2df74ade7cdd',
26
+ :api_secret => 'c055b169a789ce6491a1b016ff6ebb21'
27
+ }
28
+ end
29
+
30
+ def get_lastfm_nicks_archive
31
+ file = File.join File.dirname(__FILE__), 'reply', 'lastfm_nicks.yml'
32
+ FileUtils.touch file unless File.exists? file
33
+ YAML.load_file(file) || {}
34
+ end
35
+
36
+ match 'lastsong', method: :last_played_song
37
+ def last_played_song(m)
38
+ usernick = m.user.nick
39
+ lastfmnick = get_lastfm_nicks_archive[usernick]
40
+ m.reply "Hey #{usernick}, I don't know your Last.fm nick. add it using !lastfmuser add <lastfmnick>" unless lastfmnick
41
+
42
+ user = Rockstar::User.new lastfmnick
43
+ track = user.recent_tracks.first
44
+
45
+ album = track.album ? "in #{track.album}" : 'in no known album'
46
+ if track.now_playing?
47
+ m.reply "#{lastfmnick} is listening to #{track.name} by #{track.artist} (#{album}) right now!"
48
+ else
49
+ m.reply "the last song #{lastfmnick} listened to is #{track.name} by #{track.artist} (#{album})."
50
+ end
51
+ end
52
+
53
+ match /lastfmuser add (\w{1,15})/, method: :add_user
54
+ def add_user(m, lastfmnick)
55
+ nicks = get_lastfm_nicks_archive
56
+ nicks[m.user.nick] = lastfmnick
57
+
58
+ file = File.join File.dirname(__FILE__), 'reply', 'lastfm_nicks.yml'
59
+ File.open(file, ?w) { |f| f.write YAML.dump(nicks) }
60
+
61
+ m.reply "Ok, added user #{lastfmnick}"
62
+ end
63
+
64
+ match 'lastfmuser remove', method: :remove_user
65
+ def remove_user(m)
66
+ nicks = get_lastfm_nicks_archive
67
+ nicks.delete m.user.nick
68
+
69
+ file = File.join File.dirname(__FILE__), 'reply', 'lastfm_nicks.yml'
70
+ File.open(file, ?w) { |f| f.write YAML.dump(nicks) }
71
+
72
+ m.reply "Ok, removed user #{lastfmnick}"
73
+ end
74
+
75
+ match /lastfmuser show ([^\b]+)/, method: :show_relations
76
+ def show_relations(m, usernicks)
77
+ usernick_list = usernicks.split
78
+ found = false
79
+
80
+ get_lastfm_nicks_archive.each { |usernick, lastfmnick|
81
+ if usernick_list.include? usernick
82
+ found = true
83
+ m.reply "#{usernick} is known as #{lastfmnick}"
84
+ end
85
+ }
86
+
87
+ m.reply 'I don\'t know anthing, I know only what I know.' unless found
88
+ end
89
+
90
+ end
91
+ end
@@ -14,6 +14,6 @@
14
14
 
15
15
  class Descartes
16
16
  def self.version
17
- '0.3.12'
17
+ '0.3.13'
18
18
  end
19
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: descartes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.12
4
+ version: 0.3.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Giovanni Capuano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-13 00:00:00.000000000 Z
11
+ date: 2013-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cinch
@@ -108,6 +108,20 @@ dependencies:
108
108
  - - ">="
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: rockstar
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
111
125
  description: A serious modular ruby IRC bot.
112
126
  email: webmaster@giovannicapuano.net
113
127
  executables:
@@ -119,6 +133,7 @@ files:
119
133
  - lib/descartes/modules/crunchyroll.rb
120
134
  - lib/descartes/modules/currency.rb
121
135
  - lib/descartes/modules/google.rb
136
+ - lib/descartes/modules/lastfm.rb
122
137
  - lib/descartes/modules/musicthoughts.rb
123
138
  - lib/descartes/modules/quotone.rb
124
139
  - lib/descartes/modules/reply/replies.txt