april 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,4 @@
1
+ ### 0.0.1 (????-??-??)
2
+
3
+ * First release
4
+
@@ -0,0 +1,41 @@
1
+ april
2
+ ===
3
+
4
+ This is a smartless IRC library for bots
5
+
6
+ Features
7
+ --------
8
+
9
+ * Tiny
10
+ * Easy to understand (written in Ruby!)
11
+ * Free
12
+
13
+ Installing
14
+ ----------
15
+
16
+ $ rake install
17
+
18
+ Using
19
+ -----
20
+
21
+ edit april.conf && ruby bot.rb :)
22
+
23
+ Contributing
24
+ ------------
25
+
26
+ Once you've made your great commits:
27
+
28
+ 1. [Fork][0] april
29
+ 2. Create a topic branch - `git checkout -b my_branch`
30
+ 3. Push to your branch - `git push origin my_branch`
31
+ 4. Create an [Issue][1] with a link to your branch
32
+ 5. That's it!
33
+
34
+ Author
35
+ ------
36
+
37
+ fyskij :: fyskij@gmail.org
38
+
39
+ [0]: http://help.github.com/forking/
40
+ [1]: http://github.com/fyskij/april/issues
41
+
data/bin/bot ADDED
@@ -0,0 +1,41 @@
1
+ #! /usr/bin/env ruby
2
+
3
+ require 'april'
4
+ require 'getoptlong'
5
+
6
+ home = ENV["HOME"]
7
+
8
+ args = GetoptLong.new(
9
+ ['--version', '-v', GetoptLong::NO_ARGUMENT],
10
+ ['--help', '-h', GetoptLong::NO_ARGUMENT],
11
+ ['--config', '-f', GetoptLong::REQUIRED_ARGUMENT]
12
+ )
13
+
14
+ options = {
15
+ :config => "#{home}/.aprilrc"
16
+ }
17
+
18
+ args.each {|option, value|
19
+ case option
20
+
21
+ when '--version'
22
+ puts "April library version: #{APRIL::VERSION}"
23
+ exit 0
24
+
25
+ when '--config'
26
+ options[:config] = value
27
+
28
+ when '--help'
29
+ puts "April commands:
30
+ --config
31
+ --version
32
+ "
33
+ exit 0
34
+
35
+ end
36
+ }
37
+
38
+
39
+ client = APRIL::Client.new(YAML.load_file(options[:config]))
40
+ client.go
41
+
@@ -0,0 +1,16 @@
1
+ ---
2
+ informations:
3
+ - nick: rube
4
+ - user: loller
5
+ - realname: Gipsy
6
+
7
+ server: "irc.azzurra.org"
8
+ port: "6667"
9
+ channels:
10
+ - "0x90"
11
+ - "lulz"
12
+
13
+ modules:
14
+ - Quotes: true
15
+ - Greetings: true
16
+
@@ -0,0 +1,14 @@
1
+ dir = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift(dir) unless $LOAD_PATH.include? dir
3
+
4
+ require 'yaml'
5
+ require 'socket'
6
+
7
+ require 'april/client'
8
+ require 'april/parser'
9
+ require 'april/socket'
10
+
11
+ module APRIL
12
+ VERSION = '0.0.0'
13
+ end
14
+
@@ -0,0 +1,39 @@
1
+ module APRIL
2
+
3
+ class Client
4
+ attr_reader :version, :modules, :config, :user, :nick, :realname, :channels, :irc
5
+
6
+
7
+ def initialize(config)
8
+ @version = APRIL::VERSION
9
+
10
+ @modules = {}
11
+
12
+ @irc = APRIL::Socket.new
13
+
14
+ @config = config
15
+ @config.each do |k,v|
16
+ self.class.send(:define_method, k, proc{v})
17
+ end
18
+
19
+ @nick = informations[0]["nick"]
20
+ @user = informations[1]["user"]
21
+ @realname = informations[2]["realname"]
22
+ @channels = channels
23
+ end
24
+
25
+ def go
26
+
27
+ @irc.connect(server, port)
28
+
29
+ @irc.user(@user, @realname)
30
+ @irc.nick(@nick)
31
+
32
+ @irc.join(@channels)
33
+
34
+ @irc.listen
35
+ end
36
+
37
+ end
38
+ end
39
+
File without changes
File without changes
@@ -0,0 +1,12 @@
1
+ module APRIL
2
+ module PARSER
3
+
4
+ def handle(s)
5
+ match = s.match(/PING\s+(.*)$/)
6
+ if match
7
+ write "PONG #{match[1]}"
8
+ end
9
+ end
10
+ end
11
+ end
12
+
@@ -0,0 +1,49 @@
1
+ lib = File.dirname(__FILE__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
4
+ module APRIL
5
+
6
+ class Socket
7
+ include APRIL::PARSER
8
+
9
+ attr_reader :server, :port, :socket
10
+
11
+ def connect(server, port)
12
+ @server = server
13
+ @port = port
14
+
15
+ @socket = TCPSocket.new(@server, @port)
16
+ end
17
+
18
+ def write(msg)
19
+ puts ">> #{msg}"
20
+ @socket.write "#{msg}\n"
21
+ end
22
+
23
+ def listen
24
+ until @socket.eof? do
25
+ puts "<< #{@socket.gets}"
26
+ self.handle (@socket.gets)
27
+ end
28
+ end
29
+
30
+ # Send NICK command
31
+ def nick(nick)
32
+ write("NICK #{nick}")
33
+ end
34
+
35
+ # Send USER command
36
+ def user(user, realname)
37
+ write("USER #{user} * * :#{realname}")
38
+ end
39
+
40
+ # Send JOIN command
41
+ def join(channels)
42
+ channels.each do |channel|
43
+ write("JOIN ##{channel}")
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+
@@ -0,0 +1,6 @@
1
+ module APRIL
2
+ def debug
3
+ puts "i'm useless :("
4
+ end
5
+ end
6
+
metadata ADDED
@@ -0,0 +1,71 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: april
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 0
8
+ - 0
9
+ version: 0.0.0
10
+ platform: ruby
11
+ authors:
12
+ - fyskij
13
+ autorequire:
14
+ bindir: bin
15
+ cert_chain: []
16
+
17
+ date: 2010-05-05 00:00:00 +02:00
18
+ default_executable:
19
+ dependencies: []
20
+
21
+ description: IRC Client Library
22
+ email: fyskij@gmail.com
23
+ executables:
24
+ - bot
25
+ extensions: []
26
+
27
+ extra_rdoc_files: []
28
+
29
+ files:
30
+ - README.markdown
31
+ - HISTORY.markdown
32
+ - lib/april/client.rb
33
+ - lib/april/modules/Logger.rb
34
+ - lib/april/utils.rb
35
+ - lib/april/parser.rb
36
+ - lib/april/module.rb
37
+ - lib/april/socket.rb
38
+ - lib/april.rb
39
+ - etc/april.conf
40
+ has_rdoc: true
41
+ homepage: http://github.com/fyskij/april
42
+ licenses: []
43
+
44
+ post_install_message:
45
+ rdoc_options: []
46
+
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ requirements:
51
+ - - ">="
52
+ - !ruby/object:Gem::Version
53
+ segments:
54
+ - 0
55
+ version: "0"
56
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ segments:
61
+ - 0
62
+ version: "0"
63
+ requirements: []
64
+
65
+ rubyforge_project:
66
+ rubygems_version: 1.3.6
67
+ signing_key:
68
+ specification_version: 3
69
+ summary: IRC Client Library
70
+ test_files: []
71
+