Auto 4.0.0.alpha.1-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. data/.yardopts +7 -0
  2. data/Gemfile +19 -0
  3. data/LICENSE.md +31 -0
  4. data/README.md +109 -0
  5. data/Rakefile +41 -0
  6. data/bin/auto +110 -0
  7. data/bin/auto-conf +45 -0
  8. data/conf/example.json +100 -0
  9. data/conf/example.yml +125 -0
  10. data/docs/Contributing.md +77 -0
  11. data/docs/Events.md +103 -0
  12. data/docs/Todo.md +21 -0
  13. data/docs/Upgrade.md +16 -0
  14. data/ext/dsl_base.c +49 -0
  15. data/ext/libauto/auto.h +20 -0
  16. data/ext/libauto/extconf.rb +16 -0
  17. data/ext/libauto/libauto.c +29 -0
  18. data/ext/libauto/libauto.h +28 -0
  19. data/ext/libauto/logger.c +177 -0
  20. data/ext/libauto/logger.h +44 -0
  21. data/lib/auto.rb +43 -0
  22. data/lib/auto/api.rb +7 -0
  23. data/lib/auto/api/events.rb +166 -0
  24. data/lib/auto/api/object.rb +29 -0
  25. data/lib/auto/api/plugin.rb +155 -0
  26. data/lib/auto/api/timers.rb +93 -0
  27. data/lib/auto/bot.rb +338 -0
  28. data/lib/auto/config.rb +181 -0
  29. data/lib/auto/configure.rb +410 -0
  30. data/lib/auto/configure/shell.rb +154 -0
  31. data/lib/auto/dsl/base.rb +74 -0
  32. data/lib/auto/dsl/irc.rb +13 -0
  33. data/lib/auto/irc.rb +8 -0
  34. data/lib/auto/irc/common.rb +63 -0
  35. data/lib/auto/irc/library.rb +89 -0
  36. data/lib/auto/irc/object/channel.rb +21 -0
  37. data/lib/auto/irc/object/entity.rb +90 -0
  38. data/lib/auto/irc/object/message.rb +99 -0
  39. data/lib/auto/irc/object/user.rb +139 -0
  40. data/lib/auto/irc/protocol.rb +164 -0
  41. data/lib/auto/irc/protocol/numerics.rb +60 -0
  42. data/lib/auto/irc/sasl/diffie_hellman.rb +36 -0
  43. data/lib/auto/irc/sasl/mech.rb +15 -0
  44. data/lib/auto/irc/sasl/mech/dh_blowfish.rb +83 -0
  45. data/lib/auto/irc/sasl/mech/plain.rb +39 -0
  46. data/lib/auto/irc/server.rb +301 -0
  47. data/lib/auto/irc/state/channel_manager.rb +6 -0
  48. data/lib/auto/irc/state/support.rb +142 -0
  49. data/lib/auto/irc/state/user_manager.rb +6 -0
  50. data/lib/auto/irc/std/commands.rb +99 -0
  51. data/lib/auto/irc/std/numerics.rb +216 -0
  52. data/lib/auto/rubyext/integer.rb +25 -0
  53. data/lib/auto/rubyext/string.rb +10 -0
  54. data/lib/auto/version.rb +18 -0
  55. data/lib/libauto.so +0 -0
  56. data/spec/api_events_spec.rb +68 -0
  57. data/spec/config_json_spec.rb +116 -0
  58. data/spec/config_other_spec.rb +29 -0
  59. data/spec/config_yaml_spec.rb +136 -0
  60. data/spec/helper.rb +19 -0
  61. data/spec/irc_object_entity_spec.rb +51 -0
  62. data/spec/logger_spec.rb +30 -0
  63. data/spec/plugin_base_spec.rb +35 -0
  64. data/spec/timers_spec.rb +42 -0
  65. metadata +238 -0
@@ -0,0 +1,7 @@
1
+ --title "Auto 4.0 Phoenix"
2
+ --protected
3
+ --private
4
+ lib/**/*.rb
5
+ ext/**/*.c
6
+ - LICENSE.md
7
+ - docs/*
data/Gemfile ADDED
@@ -0,0 +1,19 @@
1
+ # Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
2
+ # This free software is distributed under the FreeBSD license (LICENSE.md).
3
+
4
+ # Gemfile
5
+
6
+ source :rubygems
7
+
8
+ gem 'colored', '~> 1.2'
9
+ gem 'sequel', '~> 3.43'
10
+ gem 'highline', '~> 1.6'
11
+ gem 'slop', '~> 3.4.1'
12
+
13
+ group :dev do
14
+ gem 'rake', '~> 10.0'
15
+ gem 'rake-compiler', '~> 0.8'
16
+ gem 'mocha', '~> 0.13'
17
+ end
18
+
19
+ # vim: set ts=4 sts=2 sw=2 et:
@@ -0,0 +1,31 @@
1
+ License
2
+ =======
3
+
4
+ Auto is free software distributed under the two-clause ("FreeBSD") BSD license:
5
+
6
+ Copyright (c) 2009-2013, Autumn Perrault, et al.
7
+ All rights reserved.
8
+
9
+ Redistribution and use in source and binary forms, with or without
10
+ modification, are permitted provided that the following conditions are met:
11
+
12
+ 1. Redistributions of source code must retain the above copyright notice, this
13
+ list of conditions and the following disclaimer.
14
+ 2. Redistributions in binary form must reproduce the above copyright notice,
15
+ this list of conditions and the following disclaimer in the documentation
16
+ and/or other materials provided with the distribution.
17
+
18
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
19
+ ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
20
+ WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
22
+ ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
23
+ (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
24
+ LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
25
+ ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26
+ (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
+ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
+
29
+ The views and conclusions contained in the software and documentation are those
30
+ of the authors and should not be interpreted as representing official policies,
31
+ either expressed or implied, of Autumn Perrault or the Auto Project.
@@ -0,0 +1,109 @@
1
+ Auto 4
2
+ ======
3
+
4
+ _A modern, simple, extensible multi-protocol bot, reloaded._
5
+
6
+ **Version**: 4.0.0.alpha.1 "Phoenix"
7
+ [![Build Status](https://travis-ci.org/Auto/Auto.png?branch=master)](https://travis-ci.org/Auto/Auto)
8
+ [![Dependency Status](https://gemnasium.com/Auto/Auto.png)](https://gemnasium.com/Auto/Auto)
9
+ [![Code Climate](https://codeclimate.com/badge.png)](https://codeclimate.com/github/Auto/Auto)
10
+
11
+ + [Homepage](http://auto.autoproj.org)
12
+ + [Git](https://github.com/Auto/Auto)
13
+ + [RubyGems](https://rubygems.org/gems/Auto)
14
+ + [Wiki](https://github.com/Auto/Auto/wiki)
15
+ + [Mailing List](https://groups.google.com/group/autobot-talk)
16
+ + [SourceForge](https://sourceforge.net/p/auto-bot)
17
+ + [Issue Hub](https://github.com/Auto/Auto/issues)
18
+
19
+ **Documentation** is available for the [latest git](http://rdoc.info/github/Auto/Auto),
20
+ and [this release](http://auto.autoproj.org/rdoc/4.0.0.alpha.1/).
21
+
22
+ Our official IRC channel is [#auto on irc.freenode.net](irc://irc.freenode.net/#auto).
23
+
24
+ Synopsis
25
+ --------
26
+
27
+ Auto is automated bot software, developed per thus philosophy:
28
+
29
+ * _Friendly_ to users, and to developers.
30
+ * _Simple_, _smart_, and _clean_.
31
+ * _Minimal_ but _extensible_.
32
+
33
+ Auto has a three-year history of service, dating back to December of 2009.
34
+ [Auto 3.0](https://github.com/Auto/Auto-legacy) was the last stable release,
35
+ and now the Auto Project presents this fourth major revision, 4.0 _Phoenix_,
36
+ intended to supersede 3.0 as a superior version.
37
+
38
+ Currently, it supports the IRCv3 protocol, with planned support for the XMPP
39
+ protocol. You can use it on many networks, including the six largest: Freenode,
40
+ QuakeNet, UnderNet, EFnet, DALnet, and IRCnet.
41
+
42
+ Quickstart
43
+ ----------
44
+
45
+ This will install the latest (pre)release:
46
+
47
+ $ gem install Auto --pre
48
+ $ gem install sqlite3
49
+ $ auto-conf
50
+ $ auto
51
+
52
+ If you would prefer to use **MySQL** or **Postgres**, substitute the respective
53
+ command below for `gem install sqlite3`:
54
+
55
+ $ gem install mysqlplus
56
+
57
+ **or**
58
+
59
+ $ gem install pg
60
+
61
+ For detailed installation instructions, see
62
+ [the guide](https://github.com/Auto/Auto/wiki/Install-Guide). This will guide
63
+ you to such things as configuring Auto manually, installing a standalone
64
+ copy, and building from git.
65
+
66
+ **Note: Ruefully, as of January 10, 2013, we no longer support JRuby. Please
67
+ use MRI (the official interpreter) or Rubinius. Thank you.**
68
+
69
+ Developing
70
+ ----------
71
+
72
+ Developers are provided extensive documentation of Auto 4
73
+ [on rdoc.info](http://rdoc.info/github/Auto/Auto/).
74
+
75
+ With especial, peruse the [Developing for Auto](http://rdoc.info/github/Auto/Auto/file/docs/Developing.md)
76
+ document.
77
+
78
+ Support
79
+ -------
80
+
81
+ If you should find yourself in need of support, please foremost consult with the
82
+ documentation on the [wiki](https://github.com/Auto/Auto/wiki).
83
+
84
+ If the wiki fails to address your needs, please either:
85
+
86
+ 1. Post to the [autobot-talk](https://groups.google.com/group/autobot-talk)
87
+ group under the _support_ category, **or**
88
+ 2. Join the official IRC chatroom at
89
+ [#auto on irc.freenode.net](http://webchat.freenode.net/?randomnick=1&channels=#auto&prompt=1)
90
+
91
+ **Bugs** should be reported on the [issue management hub](https://github.com/Auto/Auto/issues).
92
+
93
+ Authors
94
+ -------
95
+
96
+ Auto 4 was rewritten from scratch by Autumn Perrault (noxgirl) in Ruby and C,
97
+ and is actively developed by the **Auto Project**:
98
+
99
+ + [noxgirl](https://github.com/noxgirl) - [autumn@destellae.net](mailto://autumn@destellae.net)
100
+ + [swarley](https://github.com/swarley) - [matthew.b.carey@gmail.com](mailto://matthew.b.carey@gmail.com)
101
+ + [mattwb65](https://github.com/mattwb65) - [mattwb65@gmail.com](mailto://mattwb65@gmail.com)
102
+
103
+ Legal
104
+ -----
105
+
106
+ Copyright (c) 2009-2013, Autumn Perrault, et al. All rights reserved.
107
+
108
+ Auto is free, open-source software, distributed per the terms of the two-clause
109
+ ("FreeBSD") license, the full terms of which are in **LICENSE.md**.
@@ -0,0 +1,41 @@
1
+ # Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
2
+ # This free software is distributed under the FreeBSD license (LICENSE.md).
3
+
4
+ require 'rake/testtask'
5
+ require 'rake/extensiontask'
6
+ require 'rubygems'
7
+ require 'rubygems/package_task'
8
+
9
+ # import the gemspec
10
+ GEMSPEC = 'Auto.gemspec'
11
+ gemspec ||= eval(File.read(GEMSPEC), binding, GEMSPEC)
12
+
13
+ # Directives for Ruby Make (rake)
14
+ # to test/compile Auto 4, and optionally
15
+ # push to RubyGems
16
+
17
+ task :default => [:compile, :test]
18
+
19
+ desc 'Compile the native extension.'
20
+ Rake::ExtensionTask.new 'libauto', gemspec do |ext|
21
+ ext.cross_compile = true
22
+
23
+ ext.cross_compiling do |spec|
24
+ spec.post_install_message << "\r\nNOTICE: You have installed the binary distribution of this gem."
25
+ end
26
+ end
27
+
28
+ desc 'Test the application.'
29
+ Rake::TestTask.new do |t|
30
+ t.libs.push 'lib'
31
+ t.pattern = 'spec/*_spec.rb'
32
+ t.verbose = true
33
+ end
34
+
35
+ desc 'Package the gem.'
36
+ Gem::PackageTask.new(gemspec) do |pkg|
37
+ pkg.need_zip = true
38
+ pkg.need_tar = true
39
+ end
40
+
41
+ # vim: set ts=4 sts=2 sw=2 et:
@@ -0,0 +1,110 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
3
+ # This free software is distributed under the FreeBSD license (LICENSE.md).
4
+
5
+ # Forbid root.
6
+ if ENV.include? 'USER'
7
+ if ENV['USER'] == 'root'
8
+ puts "It is forbidden to run Auto as the root user!"
9
+ exit 1
10
+ end
11
+ end
12
+
13
+ # Check whether we're installed as a gem or a standalone
14
+ unless File.expand_path(__FILE__) =~ /^#{Regexp.escape File.join(Dir.home, '.gem')}/
15
+ gitdir = File.join(File.dirname(__FILE__), '..', '.git')
16
+ if Dir.exists? gitdir
17
+ REVISION = File.open(File.join(gitdir, 'refs', 'heads', 'master')).first[0..7] # Note the git revision
18
+ end
19
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) # Add the Auto libraries to LOAD_PATH
20
+ end
21
+
22
+ # Require necessary libraries.
23
+ require 'slop'
24
+ require 'auto'
25
+
26
+ # Parse options.
27
+ $VERBOSITY = 0
28
+ opts = Slop.parse(:banner => "Usage: #$0 [options]") do
29
+ on :h, :help, 'Display this help message.' do
30
+ puts self
31
+ exit 0
32
+ end
33
+ on :v, :version, 'Display version and exit.' do
34
+ puts <<-EOV
35
+ Auto #{Auto::FULLVERSION}
36
+ #{"Git revision: #{REVISION}\n" if defined? REVISION}
37
+ http://auto.autoproj.org
38
+ EOV
39
+ exit 0
40
+ end
41
+
42
+ on :d, :debug, 'Execute with debugging enabled.'
43
+ on :f, :foreground, 'Do not fork into the background.'
44
+ on :j, :json, 'Seek a JSON configuration file in lieu of a YAML one.'
45
+ on :c, :conf=, 'Specify a particular configuration file.'
46
+ on :V, :verbose, 'Increase verbosity of debugging (more uses the more verbose).' do
47
+ $VERBOSITY += 1
48
+ end
49
+ end
50
+
51
+ # Begin start up.
52
+ puts "* Auto #{Auto::VERSION} starting...".bold
53
+
54
+ # Enter main directory.
55
+ Dir.chdir(File.join(File.dirname(__FILE__), '..'))
56
+
57
+ # Create an instance of Auto.
58
+ begin
59
+ $m = Auto::Bot.new(opts)
60
+ status = $m.init
61
+ rescue => e
62
+ puts 'An error occurred!'.red.bold
63
+ puts e
64
+ puts e.backtrace
65
+ end
66
+
67
+ # Check our status.
68
+ if status
69
+ time = Time.now
70
+ puts "* Auto started @ #{time}".green.bold
71
+ $m.log.info("Auto started @ #{time}")
72
+ else
73
+ puts "Start up failed! Read above for errors.".red.bold
74
+ exit 1
75
+ end
76
+ STARTTIME = time.freeze
77
+
78
+ # We survived? We survived! Fork into the background if not in debug or foreground.
79
+ unless opts.debug? or opts.foreground?
80
+ puts "Forking into the background...".bold
81
+
82
+ # Direct all incoming data on STDIN and outgoing data on STDOUT/STDERR to /dev/null.
83
+ $stdin = File.open '/dev/null'
84
+ $stdout = $stderr = File.open '/dev/null', 'w'
85
+ # Fork and retrieve the PID.
86
+ pid = fork
87
+
88
+ # Save it to auto.pid.
89
+ unless pid.nil?
90
+ File.open('auto.pid', 'w') { |io| io.puts pid }
91
+ exit 0
92
+ end
93
+ end
94
+
95
+ # Signals
96
+ sig = {
97
+ 'TERM' => proc { $m.terminate('Caught termination signal') },
98
+ 'INT' => proc { $m.terminate('Ctrl-C pressed') },
99
+ 'HUP' => proc { $m.conf.rehash }
100
+ }
101
+ sig.delete 'HUP' if Auto.windows?
102
+ sig.each { |signal, prc| Signal.trap(signal) { prc.call } }
103
+
104
+ begin
105
+ $m.start
106
+ rescue => e
107
+ $m.error("FATAL EXCEPTION: #{e}", true, e.backtrace)
108
+ end
109
+
110
+ # vim: set ts=4 sts=2 sw=2 et:
@@ -0,0 +1,45 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (c) 2013, Autumn Perrault, et al. All rights reserved.
3
+ # This free software is distributed under the FreeBSD license (LICENSE.md).
4
+
5
+ require 'slop'
6
+
7
+ # Check whether we're installed as a gem or a standalone
8
+ unless File.expand_path(__FILE__) =~ /^#{Regexp.escape File.join(Dir.home, '.gem')}/
9
+ $:.unshift File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib')) # Add the Auto libraries to LOAD_PATH
10
+ end
11
+
12
+ require 'auto/configure'
13
+
14
+ # Parse options.
15
+ opts = Slop.parse(:banner => "Usage: #$0 [options]") do
16
+ on :h, :help, 'Display this help message.' do
17
+ puts self
18
+ exit 0
19
+ end
20
+ on :v, :version, 'Display version.' do
21
+ puts <<-EOV
22
+ Auto Configure
23
+ Version #{Auto::Configure::VERSION}
24
+
25
+ http://auto.autoproj.org
26
+ https://github.com/Auto/Auto/wiki/Auto-Configure
27
+ EOV
28
+ exit 0
29
+ end
30
+
31
+ on :p, :plugin, 'Install a plugin.'
32
+ on :s, :shell, 'Modify and interact with your existing configuration.'
33
+ end
34
+
35
+ # Configure.
36
+ autoconf = Auto::Configure.new
37
+
38
+ if opts.shell?
39
+ #autoconf.shell.go
40
+ puts "Auto Configure Shell is currently disabled.".red
41
+ else
42
+ autoconf.generate
43
+ end
44
+
45
+ # vim: set ts=4 sts=2 sw=2 et:
@@ -0,0 +1,100 @@
1
+ {
2
+
3
+ /*
4
+ Core libraries to load
5
+ ["lib1", "lib2"]
6
+
7
+ irc: IRC framework.
8
+ */
9
+ "libraries": ["irc"],
10
+
11
+ /*
12
+ irc module: IRC networks
13
+
14
+ Add each network to which you desire the bot to connect.
15
+ */
16
+ "irc": {
17
+ "freenode": {
18
+ // Network address
19
+ "address": "irc.freenode.net",
20
+
21
+ // Port on which to connect
22
+ "port": 7000,
23
+
24
+ // Whether to use SSL (true/false)
25
+ "useSSL": true,
26
+
27
+ // Nicknames the bot should use. If the first nickname is in use, the bot will alternate to the next until successful.
28
+ "nickname": ["moobot", "altnick"],
29
+
30
+ // Username the bot should use (as in nick!user@host)
31
+ "username": "Auto",
32
+
33
+ // Real name the bot should use
34
+ "realName": "Auto",
35
+
36
+ // Identify to services by means of SASL authentication
37
+ "SASL": {
38
+
39
+ // SASL timeout in seconds
40
+ "timeout": 15,
41
+
42
+ // SASL authentication username
43
+ "username": "moobot",
44
+
45
+ // SASL authentication password
46
+ "password": "moopass"
47
+
48
+ },
49
+
50
+ // Automatically join these channels
51
+ "autojoin": [
52
+ {"name": "#autoproject", "key": ""}
53
+ ]
54
+
55
+
56
+ },
57
+ "Rizon": {
58
+ // Network address
59
+ "address": "irc.rizon.net",
60
+
61
+ // Port on which to connect
62
+ "port": 6667,
63
+
64
+ // Whether to use SSL (true/false)
65
+ "useSSL": false,
66
+
67
+ // Nicknames the bot should use. If the first nickname is in use, the bot will alternate to the next until successful.
68
+ "nickname": ["moobot", "altnick"],
69
+
70
+ // Username the bot should use (as in nick!user@host)
71
+ "username": "Auto",
72
+
73
+ // Real name the bot should use
74
+ "realName": "Auto",
75
+
76
+ // Identify to services the traditional way
77
+ "nickIdentify": {
78
+
79
+ // Service (commonly NickServ)
80
+ "service": "NickServ",
81
+
82
+ // Command (commonly "identify")
83
+ "command": "identify",
84
+
85
+ // Password (for Atheme, you may desire to use "username password" for foolproof identification)
86
+ "password": "moopass"
87
+
88
+ }
89
+ }
90
+ },
91
+
92
+ /*
93
+ Plugins
94
+
95
+ These are optional plugins (located in plugins/) intended to extend the bot's features.
96
+ List them like so: if you desire to load plugins/foo.rb, list 'foo'
97
+ */
98
+ "plugins": []
99
+
100
+ }