issola 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: a4d70788260a4bcf21283cb2de722cb483f0fbf6832b9dcfb4da0e6a5c36cb12
4
+ data.tar.gz: 65876b15387f7e9c3e6568bf070a09f44d10ac9e8584a28a1c5b543a9bc59be1
5
+ SHA512:
6
+ metadata.gz: 0a2350813ec9d0d47f778b3ce714e236d13c780a1aa39de2e028ca646724bb527998ddd33535f6ed6ebfe80901227dcf8fb34fd2fea5147d012c793f1b0de50d
7
+ data.tar.gz: 7f359b3838104c6921d2dedf985d7bbd4a733476bdffb61310ba160e516c070de0abfe8fe10b4c6264b0c9b462085c317736a14ed3ac649e52007137f1b0b84a
@@ -0,0 +1 @@
1
+ DISCORD_TOKEN=
@@ -0,0 +1,2 @@
1
+ .env*
2
+ !.env*.dist
File without changes
File without changes
data/Gemfile ADDED
@@ -0,0 +1 @@
1
+ gemspec
@@ -0,0 +1,57 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ issola (0.0.0)
5
+ discordrb (~> 3.3.0)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ discordrb (3.3.0)
11
+ discordrb-webhooks (~> 3.3.0)
12
+ ffi (>= 1.9.24)
13
+ opus-ruby
14
+ rbnacl (~> 3.4.0)
15
+ rest-client (>= 2.1.0.rc1)
16
+ websocket-client-simple (>= 0.3.0)
17
+ discordrb-webhooks (3.3.0)
18
+ rest-client (>= 2.1.0.rc1)
19
+ domain_name (0.5.20180417)
20
+ unf (>= 0.0.5, < 1.0.0)
21
+ dotenv (2.5.0)
22
+ event_emitter (0.2.6)
23
+ ffi (1.9.25)
24
+ http-accept (1.7.0)
25
+ http-cookie (1.0.3)
26
+ domain_name (~> 0.5)
27
+ mime-types (3.2.2)
28
+ mime-types-data (~> 3.2015)
29
+ mime-types-data (3.2018.0812)
30
+ netrc (0.11.0)
31
+ opus-ruby (1.0.1)
32
+ ffi
33
+ rbnacl (3.4.0)
34
+ ffi
35
+ rest-client (2.1.0.rc1)
36
+ http-accept (>= 1.7.0, < 2.0)
37
+ http-cookie (>= 1.0.2, < 2.0)
38
+ mime-types (>= 1.16, < 4.0)
39
+ netrc (~> 0.8)
40
+ unf (0.1.4)
41
+ unf_ext
42
+ unf_ext (0.0.7.5)
43
+ websocket (1.2.8)
44
+ websocket-client-simple (0.3.0)
45
+ event_emitter
46
+ websocket
47
+
48
+ PLATFORMS
49
+ ruby
50
+
51
+ DEPENDENCIES
52
+ bundler
53
+ dotenv
54
+ issola!
55
+
56
+ BUNDLED WITH
57
+ 1.16.1
data/LICENSE ADDED
File without changes
File without changes
File without changes
@@ -0,0 +1,21 @@
1
+ $LOAD_PATH.unshift 'lib'
2
+
3
+ APPLICATION_ENV = ENV.fetch('APPLICATION_ENV', 'development')
4
+
5
+ require 'bundler'
6
+ Bundler.require(:default, APPLICATION_ENV)
7
+
8
+ # Ignore all warnings about uninitialized instane variables, as `sequel`
9
+ # generates plenty of those.
10
+ Warning.ignore(/instance variable @\w+ not initialized/)
11
+
12
+ # Not limiting to specific environments, as we don't know which envs it might be used in.
13
+ if Object.const_defined?(:Dotenv)
14
+ env_file = ".env.#{ APPLICATION_ENV }"
15
+ puts "Loading env-specific env variables from #{ env_file }"
16
+ Dotenv.load env_file
17
+ else
18
+ puts 'Dotenv not available, skipping.'
19
+ end
20
+
21
+ require 'issola'
@@ -0,0 +1,25 @@
1
+ $LOAD_PATH.unshift '.'
2
+ require 'bin/boot'
3
+
4
+ class InternalCommands
5
+ def register(cmd_handler)
6
+ cmd_handler.register do |cmd|
7
+ cmd.key :help
8
+ cmd.action do |event|
9
+ puts "Starting command :)"
10
+ event << 'Help help!'
11
+ end
12
+ end
13
+ end
14
+ end
15
+
16
+ puts 'Starting bot'
17
+
18
+ bot = Issola::Bot.new(
19
+ token: Issola::Config::Discord::TOKEN
20
+ )
21
+
22
+ bot.register(InternalCommands.new)
23
+
24
+ puts "Invite me: #{ bot.invite_url }"
25
+ bot.run
File without changes
File without changes
@@ -0,0 +1,4 @@
1
+ require 'issola/config'
2
+
3
+ require 'issola/bot'
4
+ require 'issola/command'
@@ -0,0 +1,29 @@
1
+ require 'discordrb'
2
+
3
+ module Issola
4
+ class Bot
5
+ def initialize(token:)
6
+ @bot = Discordrb::Bot.new(
7
+ token: token,
8
+ )
9
+
10
+ @command_handler = Command::Handler.new
11
+
12
+ @bot.message(start_with: Config::Bot::COMMAND_PREFIX) do |event|
13
+ @command_handler.handle(event)
14
+ end
15
+ end
16
+
17
+ def invite_url
18
+ @bot.invite_url
19
+ end
20
+
21
+ def register(obj)
22
+ obj.register(@command_handler)
23
+ end
24
+
25
+ def run
26
+ @bot.run
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,4 @@
1
+ require 'issola/command/builder'
2
+ require 'issola/command/command'
3
+ require 'issola/command/handler'
4
+ require 'issola/command/processor'
@@ -0,0 +1,23 @@
1
+ module Issola
2
+ module Command
3
+ class Builder
4
+ def key(key)
5
+ @key = key.to_s
6
+ end
7
+
8
+ def action(&blk)
9
+ @action = blk
10
+ end
11
+
12
+ def command
13
+ raise ArgumentError, 'Unable to build command, missing attributes' unless valid?
14
+
15
+ Command.new(key: @key, action: @action)
16
+ end
17
+
18
+ def valid?
19
+ @key && @action
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,12 @@
1
+ module Issola
2
+ module Command
3
+ class Command
4
+ attr_reader :key, :action
5
+
6
+ def initialize(key:, action:)
7
+ @key = key
8
+ @action = action
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,32 @@
1
+ module Issola
2
+ module Command
3
+ class Handler
4
+ def initialize
5
+ @commands = {}
6
+ end
7
+
8
+ def register
9
+ builder = Builder.new
10
+
11
+ yield builder
12
+ raise ArgumentError, 'Unable to register command, required attribute(s) missing.' unless builder.valid?
13
+
14
+ cmd = builder.command
15
+ @commands[cmd.key] = cmd
16
+ end
17
+
18
+ def handle(event)
19
+ tokens = event.message.content.split(' ')
20
+ puts "Checking for command in message: #{ tokens.inspect }"
21
+
22
+ # Get rid of command prefix
23
+ key = tokens.first[1..-1]
24
+ cmd = @commands[key]
25
+ if cmd
26
+ puts "Found command!"
27
+ cmd.action.call(event)
28
+ end
29
+ end
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,7 @@
1
+ module Issola
2
+ module Command
3
+ class Processor
4
+
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,11 @@
1
+ module Issola
2
+ module Config
3
+ module Discord
4
+ TOKEN = ENV.fetch('DISCORD_TOKEN')
5
+ end
6
+
7
+ module Bot
8
+ COMMAND_PREFIX = ENV.fetch('BOT_COMMAND_PREFIX', '!')
9
+ end
10
+ end
11
+ end
metadata ADDED
@@ -0,0 +1,109 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: issola
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Michael Senn
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2018-12-08 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: discordrb
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 3.3.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 3.3.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: bundler
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: dotenv
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description:
56
+ email:
57
+ - michael@morrolan.ch
58
+ executables:
59
+ - boot.rb
60
+ - issola.rb
61
+ extensions: []
62
+ extra_rdoc_files: []
63
+ files:
64
+ - ".env.development.dist"
65
+ - ".gitignore"
66
+ - CHANGELOG.md
67
+ - Dockerfile
68
+ - Gemfile
69
+ - Gemfile.lock
70
+ - LICENSE
71
+ - README.md
72
+ - Rakefile
73
+ - bin/boot.rb
74
+ - bin/issola.rb
75
+ - docker-compose.yml
76
+ - docker-entrypoint.sh
77
+ - lib/issola.rb
78
+ - lib/issola/bot.rb
79
+ - lib/issola/command.rb
80
+ - lib/issola/command/builder.rb
81
+ - lib/issola/command/command.rb
82
+ - lib/issola/command/handler.rb
83
+ - lib/issola/command/processor.rb
84
+ - lib/issola/config.rb
85
+ homepage: https://github.com/Dragaera/issola
86
+ licenses:
87
+ - Apache-2.0
88
+ metadata: {}
89
+ post_install_message:
90
+ rdoc_options: []
91
+ require_paths:
92
+ - lib
93
+ required_ruby_version: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - ">="
96
+ - !ruby/object:Gem::Version
97
+ version: '0'
98
+ required_rubygems_version: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ requirements: []
104
+ rubyforge_project:
105
+ rubygems_version: 2.7.3
106
+ signing_key:
107
+ specification_version: 4
108
+ summary: Discord bot framework, built on top of `discordrb`
109
+ test_files: []