public
Rubygem
Description: irccat is like `cat`, but here, the STDOUT is an IRC channel.
Homepage: http://irccat.rubyforge.org/
Clone URL: git://github.com/webs/irccat.git
Search Repo:
Click here to lend your support to: irccat and make a donation at www.pledgie.com !
introducing iecho, echo for irccat
webs (author)
Sun Feb 17 08:15:09 -0800 2008
commit  b6f01f4320cae42ed887ba05da4c49f15ce56e3c
tree    27b494e7482f4814912bdcb8c9ac14a414895e9c
parent  8e8442d268db1087153ebf623c129e7a86653134
...
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
0
@@ -1 +1,54 @@
0
+#!/usr/bin/env ruby
0
+#
0
+# `echo` for irccat :)
0
+#
0
+# Created on 2008-2-17.
0
+# Copyright (c) 2008. All rights reserved.
0
+
0
+require 'optparse'
0
+require 'yaml'
0
+
0
+OPTIONS = {
0
+ :profile => 'default'
0
+}
0
+MANDATORY_OPTIONS = %w( )
0
+
0
+parser = OptionParser.new do |opts|
0
+ opts.banner = <<BANNER
0
+iecho - just like echo but for irccat
0
+
0
+Usage: #{File.basename($0)} [options] <file>
0
+
0
+Options are:
0
+BANNER
0
+ opts.separator ""
0
+ opts.on("-p", "--profile=PROFILE", String,
0
+ "Profile to use (in ~/.irccat.yml).",
0
+ "Default: 'default'") { |OPTIONS[:profile]| }
0
+ opts.on("-h", "--help",
0
+ "Show this help message.") { puts opts; exit }
0
+ opts.parse!(ARGV)
0
+
0
+ if MANDATORY_OPTIONS && MANDATORY_OPTIONS.find { |option| OPTIONS[option.to_sym].nil? }
0
+ puts opts; exit
0
+ end
0
+end
0
+
0
+raise "Can't read configuration file (~/.irccat.yml)" unless File.exists?(File.expand_path("~/.irccat.yml"))
0
+@config = YAML.load_file(File.expand_path("~/.irccat.yml"))
0
+
0
+@profile = @config["#{OPTIONS[:profile]}"]
0
+raise "Can't find profile #{OPTIONS[:profile]} in ~/.irccat.yml" if @profile.nil?
0
+
0
+raise "Nothing to send" if ARGV.empty?
0
+
0
+begin
0
+ require 'irc_cat/tcp_client'
0
+rescue LoadError
0
+ require 'lib/irc_cat/tcp_client'
0
+end
0
+
0
+message = ARGV.join(' ')
0
+
0
+IrcCat::TcpClient.notify(@profile['host'], @profile['port'], message)
...
43
44
45
46
 
47
48
49
...
43
44
45
 
46
47
48
49
0
@@ -43,7 +43,7 @@
0
   configfile = './config.yml'
0
 end
0
 
0
-exit unless File.exists?(configfile)
0
+raise "Can't read configuration file (#{configfile})" unless File.exists?(configfile)
0
 @config = YAML.load_file(configfile)
0
 begin
0
   require 'irc_cat'
...
 
 
 
 
...
1
2
3
4
0
@@ -1 +1,5 @@
0
+# Configuration file for irccat clients (icat, iecho)
0
+default:
0
+ host: 127.0.0.1
0
+ port: 5678
...
 
1
2
3
...
1
2
3
4
0
@@ -1,3 +1,4 @@
0
+require 'socket'
0
 module IrcCat
0
   class TcpClient
0
     def self.notify(ip,port,message)

Comments

    No one has commented yet.