advanced_ruby_command_handler 2.0.0 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/ruby.yml +5 -30
- data/Gemfile.lock +1 -1
- data/README.md +28 -18
- data/lib/advanced_ruby_command_handler/database.rb +3 -3
- data/lib/advanced_ruby_command_handler/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a11ba24daab81b761181e660e6dbec31f61e66f60e9921ae88ed025ff428dc6f
|
4
|
+
data.tar.gz: 63c1cf7eaf789454969ef8e7340573c11bc81c42a10de4381bf06524aaaccd61
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ff38ee1aa4a2d6a1bb6a11ae8b791f626746ca87bf68787e2d3da82ca549c1401de947c8ee952ca45030b098cdba81295e83bd5daae97ff4447a53ab1b95f87f
|
7
|
+
data.tar.gz: c450efad33bc9ee1070d3658dca1aa2297f0d69da7da99021ba83c3a865766819a6f52a018251cf1ff4ddd1c95aa0c44ef2d805e29f41d8363d653454600940b
|
data/.github/workflows/ruby.yml
CHANGED
@@ -1,37 +1,12 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
# separate terms of service, privacy policy, and support
|
4
|
-
# documentation.
|
5
|
-
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
|
6
|
-
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
|
7
|
-
|
8
|
-
name: Ruby
|
9
|
-
|
10
|
-
on:
|
11
|
-
push:
|
12
|
-
branches: [ main ]
|
13
|
-
pull_request:
|
14
|
-
branches: [ main ]
|
15
|
-
|
1
|
+
name: My workflow
|
2
|
+
on: [push, pull_request]
|
16
3
|
jobs:
|
17
4
|
test:
|
18
|
-
|
19
5
|
runs-on: ubuntu-latest
|
20
|
-
strategy:
|
21
|
-
matrix:
|
22
|
-
ruby-version: ['2.6', '2.7', '3.0']
|
23
|
-
|
24
6
|
steps:
|
25
7
|
- uses: actions/checkout@v2
|
26
|
-
-
|
27
|
-
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
|
28
|
-
# change this to (see https://github.com/ruby/setup-ruby#versioning):
|
29
|
-
# uses: ruby/setup-ruby@v1
|
30
|
-
uses: ruby/setup-ruby@473e4d8fe5dd94ee328fdfca9f8c9c7afc9dae5e
|
8
|
+
- uses: ruby/setup-ruby@v1
|
31
9
|
with:
|
32
|
-
ruby-version:
|
10
|
+
ruby-version: 2.6 # Not needed with a .ruby-version file
|
33
11
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
34
|
-
-
|
35
|
-
run: bundle install
|
36
|
-
- name: Run tests
|
37
|
-
run: bundle exec rake
|
12
|
+
- run: bundle exec rake
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
|
2
2
|
[](https://forthebadge.com)
|
3
3
|
|
4
|
-
[
|
4
|
+
[Les Laboratoires Ruby](https://discord.gg/4P7XcmbDnt)
|
5
5
|
|
6
6
|
# AdvancedRubyCommandHandler
|
7
7
|
## Installation
|
@@ -29,55 +29,65 @@ Firstly, you have to create a ruby file, where you put the followwing line:
|
|
29
29
|
require "advanced_ruby_command_handler"
|
30
30
|
```
|
31
31
|
|
32
|
-
Then, initialize the command handler. Specifying the directories and the
|
32
|
+
Then, initialize the command handler. Specifying the directories and the modules.
|
33
33
|
|
34
34
|
```rb
|
35
|
-
|
35
|
+
command_handler = CommandHandler.new(Hash[
|
36
|
+
:commands_dir => "src/commands/",
|
37
|
+
:events_dir => "src/events/",
|
38
|
+
:commands_module_name => "Commands",
|
39
|
+
:events_module_name => "Events"
|
40
|
+
])
|
41
|
+
.load_commands
|
42
|
+
.load_events
|
36
43
|
```
|
37
|
-
Note: if these
|
44
|
+
Note: if these directories dosen't exist, the command handler will create them
|
38
45
|
|
39
46
|
And run the bot:
|
40
47
|
```ruby
|
41
|
-
client.run
|
48
|
+
command_handler.client.run
|
42
49
|
```
|
43
50
|
|
44
51
|
### Events&Commands
|
45
52
|
|
46
53
|
The command handler have base events as message or ready, but you can create your owns events (in events directory).
|
47
54
|
|
48
|
-
Create a file with the name of your event (see https://www.rubydoc.info/github/meew0/discordrb/Discordrb/Events)
|
55
|
+
Create a file with the name of your event (see [https://www.rubydoc.info/github/meew0/discordrb/Discordrb/Events](the doc))
|
49
56
|
|
50
57
|
And use the following template:
|
51
58
|
```ruby
|
59
|
+
# src/events/message.rb
|
52
60
|
# frozen_string_literal: true
|
53
61
|
|
54
62
|
module Events
|
55
|
-
|
56
|
-
|
57
|
-
|
63
|
+
# self.<event_name>
|
64
|
+
def self.message(command_handler)
|
65
|
+
Event.new(:message, command_handler.client) do |message|
|
66
|
+
Logger.check("Message! : #{message.content}")
|
58
67
|
end
|
59
|
-
|
68
|
+
end
|
60
69
|
end
|
61
70
|
```
|
62
|
-
Now, when
|
71
|
+
Now, when a message is sent, the program will puts "Message! : 'message content'"
|
63
72
|
|
64
73
|
If you want to add some commands in your bot, you can create sub directories in your command directory.
|
65
74
|
In these directories, you can create ruby files for commands, here's an example:
|
66
75
|
|
67
76
|
```ruby
|
77
|
+
# src/commands/utils/ping.rb
|
68
78
|
# frozen_string_literal: true
|
69
79
|
|
70
|
-
require_relative "advanced_ruby_command_handler"
|
71
|
-
|
72
80
|
module Commands
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
81
|
+
# self.<command_name>
|
82
|
+
def self.ping
|
83
|
+
Command.new(Hash[
|
84
|
+
:name => "ping"
|
85
|
+
]) do |client, message|
|
86
|
+
message.respond "Pong!"
|
78
87
|
end
|
79
88
|
end
|
80
89
|
end
|
90
|
+
|
81
91
|
```
|
82
92
|
|
83
93
|
Now you can create events and commands ! ;)
|
@@ -5,12 +5,12 @@ require File.expand_path("base", File.dirname(__FILE__))
|
|
5
5
|
|
6
6
|
module AdvancedRubyCommandHandler
|
7
7
|
class Database < BaseDatabase
|
8
|
-
attr_accessor :
|
8
|
+
attr_accessor :client, :path
|
9
9
|
|
10
10
|
def initialize(path)
|
11
11
|
@path = path
|
12
|
-
@
|
13
|
-
super(@
|
12
|
+
@client = Mongo::Client.new(path)
|
13
|
+
super(@client)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: advanced_ruby_command_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- senchuu
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-10-
|
11
|
+
date: 2021-10-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: discordrb
|