~ubuntu-branches/ubuntu/wily/pianobar/wily-proposed

« back to all changes in this revision

Viewing changes to contrib/eventcmd-examples/rbot.rb

  • Committer: Bazaar Package Importer
  • Author(s): Luke Faraone
  • Date: 2011-07-09 10:03:03 UTC
  • mfrom: (1.3.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20110709100303-m5heshhcrbrv3w3n
Tags: 2011.07.09-1
* New upstream version. 
  - XMLRPC api version bump (v31) (closes: #633345, LP: #807860)
* Update debian/watch for new location.
* Update symbols file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/ruby
 
2
 
 
3
# pianobar event script to make rbot send currently playing song to an IRC
 
4
# channel
 
5
 
 
6
# Copyright (c) 2010
 
7
# Matthew M. Boedicker <matthewm@boedicker.org>
 
8
 
 
9
# Permission is hereby granted, free of charge, to any person obtaining a copy
 
10
# of this software and associated documentation files (the "Software"), to deal
 
11
# in the Software without restriction, including without limitation the rights
 
12
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
13
# copies of the Software, and to permit persons to whom the Software is
 
14
# furnished to do so, subject to the following conditions:
 
15
 
 
16
# The above copyright notice and this permission notice shall be included in
 
17
# all copies or substantial portions of the Software.
 
18
 
 
19
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
20
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
21
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
22
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
23
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
24
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
25
# THE SOFTWARE.
 
26
 
 
27
# for setting up rbot-remote see rbot/bin/rbot-remote
 
28
 
 
29
# add this script to ~/.config/pianobar/config by adding
 
30
# event_command = /home/user/.config/pianobar/rbot.rb
 
31
 
 
32
# make sure these are quoted correctly for popen
 
33
rbot_remote = '/home/user/src/rbot/bin/rbot-remote'
 
34
rbot_user = 'remote'
 
35
rbot_password = 'secret'
 
36
channel = '#current'
 
37
 
 
38
event = ARGV.first
 
39
 
 
40
if event == 'songstart'
 
41
  d = {}
 
42
 
 
43
  STDIN.each_line { |line| d.store(*line.chomp.split('=', 2)) }
 
44
 
 
45
  IO.popen("#{rbot_remote} -u #{rbot_user} -p #{rbot_password} -d '#{channel}'",
 
46
    'w') do |p|
 
47
    p.write("now playing \"#{d['title']}\" by \"#{d['artist']}\"")
 
48
  end
 
49
 
 
50
end