discord_rubot 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: c0869ad183cbf204bfee0d125d0350ad198a11c534f295f6ca0eeafe2098368c
4
+ data.tar.gz: 90689aeb236bb30dc68feda37264a18c22ad3d9c8d1e12b8251a2c19625a9ae3
5
+ SHA512:
6
+ metadata.gz: 65850e17c37bed2a40fed2d1bc31872c63fbcf7589ce86d3c808e5a6e44c6a3b9a0d3ee7fcf79fc4b173a161ddfd1af2e37b995d3cf24cc93d0f983d93861fdd
7
+ data.tar.gz: 9764b0422c89238c1a97ce5d88dff1c9142ce76ef4207509d7f92a3fd484a250809817e8bcdffa0f5b5db9076e26453d37ad601e06ab751cbbfd30e0c2bfb91d
data/.idea/.gitignore ADDED
@@ -0,0 +1,8 @@
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Editor-based HTTP Client requests
5
+ /httpRequests/
6
+ # Datasource local storage ignored files
7
+ /dataSources/
8
+ /dataSources.local.xml
data/.idea/Rubot.iml ADDED
@@ -0,0 +1,85 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="RUBY_MODULE" version="4">
3
+ <component name="ModuleRunConfigurationManager">
4
+ <shared />
5
+ </component>
6
+ <component name="NewModuleRootManager">
7
+ <content url="file://$MODULE_DIR$">
8
+ <sourceFolder url="file://$MODULE_DIR$/features" isTestSource="true" />
9
+ <sourceFolder url="file://$MODULE_DIR$/spec" isTestSource="true" />
10
+ <sourceFolder url="file://$MODULE_DIR$/test" isTestSource="true" />
11
+ <excludeFolder url="file://$MODULE_DIR$/pkg" />
12
+ </content>
13
+ <orderEntry type="jdk" jdkName="RVM: ruby-3.0.0" jdkType="RUBY_SDK" />
14
+ <orderEntry type="sourceFolder" forTests="false" />
15
+ <orderEntry type="library" scope="PROVIDED" name="ast (v2.4.2, RVM: ruby-3.0.0) [gem]" level="application" />
16
+ <orderEntry type="library" scope="PROVIDED" name="bson (v4.15.0, RVM: ruby-3.0.0) [gem]" level="application" />
17
+ <orderEntry type="library" scope="PROVIDED" name="bundler (v2.3.4, RVM: ruby-3.0.0) [gem]" level="application" />
18
+ <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.5.0, RVM: ruby-3.0.0) [gem]" level="application" />
19
+ <orderEntry type="library" scope="PROVIDED" name="discordrb (v3.4.2@7c7865, RVM: ruby-3.0.0) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="domain_name (v0.5.20190701, RVM: ruby-3.0.0) [gem]" level="application" />
21
+ <orderEntry type="library" scope="PROVIDED" name="dotenv (v2.7.6, RVM: ruby-3.0.0) [gem]" level="application" />
22
+ <orderEntry type="library" scope="PROVIDED" name="event_emitter (v0.2.6, RVM: ruby-3.0.0) [gem]" level="application" />
23
+ <orderEntry type="library" scope="PROVIDED" name="ffi (v1.15.5, RVM: ruby-3.0.0) [gem]" level="application" />
24
+ <orderEntry type="library" scope="PROVIDED" name="http-accept (v1.7.0, RVM: ruby-3.0.0) [gem]" level="application" />
25
+ <orderEntry type="library" scope="PROVIDED" name="http-cookie (v1.0.5, RVM: ruby-3.0.0) [gem]" level="application" />
26
+ <orderEntry type="library" scope="PROVIDED" name="json (v2.6.2, RVM: ruby-3.0.0) [gem]" level="application" />
27
+ <orderEntry type="library" scope="PROVIDED" name="mime-types (v3.4.1, RVM: ruby-3.0.0) [gem]" level="application" />
28
+ <orderEntry type="library" scope="PROVIDED" name="mime-types-data (v3.2022.0105, RVM: ruby-3.0.0) [gem]" level="application" />
29
+ <orderEntry type="library" scope="PROVIDED" name="mongo (v2.18.0, RVM: ruby-3.0.0) [gem]" level="application" />
30
+ <orderEntry type="library" scope="PROVIDED" name="netrc (v0.11.0, RVM: ruby-3.0.0) [gem]" level="application" />
31
+ <orderEntry type="library" scope="PROVIDED" name="opus-ruby (v1.0.1, RVM: ruby-3.0.0) [gem]" level="application" />
32
+ <orderEntry type="library" scope="PROVIDED" name="parallel (v1.22.1, RVM: ruby-3.0.0) [gem]" level="application" />
33
+ <orderEntry type="library" scope="PROVIDED" name="parser (v3.1.2.0, RVM: ruby-3.0.0) [gem]" level="application" />
34
+ <orderEntry type="library" scope="PROVIDED" name="rainbow (v3.1.1, RVM: ruby-3.0.0) [gem]" level="application" />
35
+ <orderEntry type="library" scope="PROVIDED" name="rake (v13.0.6, RVM: ruby-3.0.0) [gem]" level="application" />
36
+ <orderEntry type="library" scope="PROVIDED" name="regexp_parser (v2.5.0, RVM: ruby-3.0.0) [gem]" level="application" />
37
+ <orderEntry type="library" scope="PROVIDED" name="rest-client (v2.1.0, RVM: ruby-3.0.0) [gem]" level="application" />
38
+ <orderEntry type="library" scope="PROVIDED" name="rexml (v3.2.5, RVM: ruby-3.0.0) [gem]" level="application" />
39
+ <orderEntry type="library" scope="PROVIDED" name="rspec (v3.11.0, RVM: ruby-3.0.0) [gem]" level="application" />
40
+ <orderEntry type="library" scope="PROVIDED" name="rspec-core (v3.11.0, RVM: ruby-3.0.0) [gem]" level="application" />
41
+ <orderEntry type="library" scope="PROVIDED" name="rspec-expectations (v3.11.0, RVM: ruby-3.0.0) [gem]" level="application" />
42
+ <orderEntry type="library" scope="PROVIDED" name="rspec-mocks (v3.11.1, RVM: ruby-3.0.0) [gem]" level="application" />
43
+ <orderEntry type="library" scope="PROVIDED" name="rspec-support (v3.11.0, RVM: ruby-3.0.0) [gem]" level="application" />
44
+ <orderEntry type="library" scope="PROVIDED" name="rubocop (v1.31.2, RVM: ruby-3.0.0) [gem]" level="application" />
45
+ <orderEntry type="library" scope="PROVIDED" name="rubocop-ast (v1.19.1, RVM: ruby-3.0.0) [gem]" level="application" />
46
+ <orderEntry type="library" scope="PROVIDED" name="ruby-progressbar (v1.11.0, RVM: ruby-3.0.0) [gem]" level="application" />
47
+ <orderEntry type="library" scope="PROVIDED" name="unf (v0.1.4, RVM: ruby-3.0.0) [gem]" level="application" />
48
+ <orderEntry type="library" scope="PROVIDED" name="unf_ext (v0.0.8.2, RVM: ruby-3.0.0) [gem]" level="application" />
49
+ <orderEntry type="library" scope="PROVIDED" name="unicode-display_width (v2.2.0, RVM: ruby-3.0.0) [gem]" level="application" />
50
+ <orderEntry type="library" scope="PROVIDED" name="websocket (v1.2.9, RVM: ruby-3.0.0) [gem]" level="application" />
51
+ <orderEntry type="library" scope="PROVIDED" name="websocket-client-simple (v0.5.1, RVM: ruby-3.0.0) [gem]" level="application" />
52
+ </component>
53
+ <component name="RakeTasksCache">
54
+ <option name="myRootTask">
55
+ <RakeTaskImpl id="rake">
56
+ <subtasks>
57
+ <RakeTaskImpl description="Build Rubot-0.1.0.gem into the pkg directory" fullCommand="build" id="build" />
58
+ <RakeTaskImpl id="build">
59
+ <subtasks>
60
+ <RakeTaskImpl description="Generate SHA512 checksum if Rubot-0.1.0.gem into the checksums directory" fullCommand="build:checksum" id="checksum" />
61
+ </subtasks>
62
+ </RakeTaskImpl>
63
+ <RakeTaskImpl description="Remove any temporary products" fullCommand="clean" id="clean" />
64
+ <RakeTaskImpl description="Remove any generated files" fullCommand="clobber" id="clobber" />
65
+ <RakeTaskImpl description="Build and install Rubot-0.1.0.gem into system gems" fullCommand="install" id="install" />
66
+ <RakeTaskImpl id="install">
67
+ <subtasks>
68
+ <RakeTaskImpl description="Build and install Rubot-0.1.0.gem into system gems without network access" fullCommand="install:local" id="local" />
69
+ </subtasks>
70
+ </RakeTaskImpl>
71
+ <RakeTaskImpl description="Create tag v0.1.0 and build and push Rubot-0.1.0.gem to https://rubygems.org" fullCommand="release[remote]" id="release[remote]" />
72
+ <RakeTaskImpl description="" fullCommand="default" id="default" />
73
+ <RakeTaskImpl description="" fullCommand="release" id="release" />
74
+ <RakeTaskImpl id="release">
75
+ <subtasks>
76
+ <RakeTaskImpl description="" fullCommand="release:guard_clean" id="guard_clean" />
77
+ <RakeTaskImpl description="" fullCommand="release:rubygem_push" id="rubygem_push" />
78
+ <RakeTaskImpl description="" fullCommand="release:source_control_push" id="source_control_push" />
79
+ </subtasks>
80
+ </RakeTaskImpl>
81
+ </subtasks>
82
+ </RakeTaskImpl>
83
+ </option>
84
+ </component>
85
+ </module>
data/.idea/discord.xml ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="DiscordProjectSettings">
4
+ <option name="show" value="PROJECT_FILES" />
5
+ <option name="description" value="Bot.rb reboot" />
6
+ </component>
7
+ </project>
data/.idea/misc.xml ADDED
@@ -0,0 +1,4 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectRootManager" version="2" project-jdk-name="RVM: ruby-3.0.0" project-jdk-type="RUBY_SDK" />
4
+ </project>
data/.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/Rubot.iml" filepath="$PROJECT_DIR$/.idea/Rubot.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
data/.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
data/.rubocop.yml ADDED
@@ -0,0 +1,44 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.5
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 200
14
+
15
+ Style/HashSyntax:
16
+ Enabled: true
17
+ EnforcedStyle: hash_rockets
18
+
19
+ Layout/EndOfLine:
20
+ Enabled: false
21
+
22
+ Metrics/ModuleLength:
23
+ Enabled: false
24
+
25
+ Metrics/MethodLength:
26
+ Enabled: false
27
+
28
+ Lint/RedundantStringCoercion:
29
+ Enabled: false
30
+
31
+ Style/Documentation:
32
+ Enabled: false
33
+
34
+ Metrics/PerceivedComplexity:
35
+ Enabled: false
36
+
37
+ Metrics/AbcSize:
38
+ Enabled: false
39
+
40
+ Metrics/CyclomaticComplexity:
41
+ Enabled: false
42
+
43
+ Metrics/BlockLength:
44
+ Enabled: false
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2022-07-19
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at senchuuuu@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in rubot.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rubocop"
11
+
12
+ gem "rspec", "~> 3.11"
13
+
14
+ gem "discordrb", :git => "https://github.com/shardlab/discordrb", :branch => "main"
15
+
16
+ gem "dotenv"
17
+
18
+ gem "mongo", "~> 2.18"
data/Gemfile.lock ADDED
@@ -0,0 +1,106 @@
1
+ GIT
2
+ remote: https://github.com/shardlab/discordrb
3
+ revision: 7c7865d7462a348e6a4171008322fda24634e437
4
+ branch: main
5
+ specs:
6
+ discordrb (3.4.2)
7
+ discordrb-webhooks (~> 3.4.2)
8
+ ffi (>= 1.9.24)
9
+ opus-ruby
10
+ rest-client (>= 2.0.0)
11
+ websocket-client-simple (>= 0.3.0)
12
+ discordrb-webhooks (3.4.2)
13
+ rest-client (>= 2.0.0)
14
+
15
+ PATH
16
+ remote: .
17
+ specs:
18
+ discord_rubot (0.1.0)
19
+ discordrb
20
+ dotenv
21
+ mongo
22
+
23
+ GEM
24
+ remote: https://rubygems.org/
25
+ specs:
26
+ ast (2.4.2)
27
+ bson (4.15.0)
28
+ diff-lcs (1.5.0)
29
+ domain_name (0.5.20190701)
30
+ unf (>= 0.0.5, < 1.0.0)
31
+ dotenv (2.7.6)
32
+ event_emitter (0.2.6)
33
+ ffi (1.15.5)
34
+ http-accept (1.7.0)
35
+ http-cookie (1.0.5)
36
+ domain_name (~> 0.5)
37
+ json (2.6.2)
38
+ mime-types (3.4.1)
39
+ mime-types-data (~> 3.2015)
40
+ mime-types-data (3.2022.0105)
41
+ mongo (2.18.0)
42
+ bson (>= 4.14.1, < 5.0.0)
43
+ netrc (0.11.0)
44
+ opus-ruby (1.0.1)
45
+ ffi
46
+ parallel (1.22.1)
47
+ parser (3.1.2.0)
48
+ ast (~> 2.4.1)
49
+ rainbow (3.1.1)
50
+ rake (13.0.6)
51
+ regexp_parser (2.5.0)
52
+ rest-client (2.1.0)
53
+ http-accept (>= 1.7.0, < 2.0)
54
+ http-cookie (>= 1.0.2, < 2.0)
55
+ mime-types (>= 1.16, < 4.0)
56
+ netrc (~> 0.8)
57
+ rexml (3.2.5)
58
+ rspec (3.11.0)
59
+ rspec-core (~> 3.11.0)
60
+ rspec-expectations (~> 3.11.0)
61
+ rspec-mocks (~> 3.11.0)
62
+ rspec-core (3.11.0)
63
+ rspec-support (~> 3.11.0)
64
+ rspec-expectations (3.11.0)
65
+ diff-lcs (>= 1.2.0, < 2.0)
66
+ rspec-support (~> 3.11.0)
67
+ rspec-mocks (3.11.1)
68
+ diff-lcs (>= 1.2.0, < 2.0)
69
+ rspec-support (~> 3.11.0)
70
+ rspec-support (3.11.0)
71
+ rubocop (1.31.2)
72
+ json (~> 2.3)
73
+ parallel (~> 1.10)
74
+ parser (>= 3.1.0.0)
75
+ rainbow (>= 2.2.2, < 4.0)
76
+ regexp_parser (>= 1.8, < 3.0)
77
+ rexml (>= 3.2.5, < 4.0)
78
+ rubocop-ast (>= 1.18.0, < 2.0)
79
+ ruby-progressbar (~> 1.7)
80
+ unicode-display_width (>= 1.4.0, < 3.0)
81
+ rubocop-ast (1.19.1)
82
+ parser (>= 3.1.1.0)
83
+ ruby-progressbar (1.11.0)
84
+ unf (0.1.4)
85
+ unf_ext
86
+ unf_ext (0.0.8.2)
87
+ unicode-display_width (2.2.0)
88
+ websocket (1.2.9)
89
+ websocket-client-simple (0.5.1)
90
+ event_emitter
91
+ websocket
92
+
93
+ PLATFORMS
94
+ x86_64-linux
95
+
96
+ DEPENDENCIES
97
+ discord_rubot!
98
+ discordrb!
99
+ dotenv
100
+ mongo (~> 2.18)
101
+ rake (~> 13.0)
102
+ rspec (~> 3.11)
103
+ rubocop
104
+
105
+ BUNDLED WITH
106
+ 2.3.4
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Senchuu
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # Rubot
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/Rubot`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'rubot'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install Rubot
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/Rubot. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/Rubot/blob/master/CODE_OF_CONDUCT.md).
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the Rubot project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/Rubot/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ task :default => %i[]
data/bin/console ADDED
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "bundler/setup"
5
+ require "rubot"
6
+
7
+ # You can add fixtures and/or initialization code here to make experimenting
8
+ # with your gem easier. You can also use a different console, if you like.
9
+
10
+ # (If you use this, don't forget to add pry to your Gemfile!)
11
+ # require "pry"
12
+ # Pry.start
13
+
14
+ require "irb"
15
+ IRB.start(__FILE__)
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,65 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "discordrb"
4
+ require "dotenv/load"
5
+ require File.expand_path("manager", File.dirname(__FILE__))
6
+ require File.expand_path("command", File.dirname(__FILE__))
7
+ require File.expand_path("event", File.dirname(__FILE__))
8
+ require File.expand_path("rapplication_command", File.dirname(__FILE__))
9
+
10
+ module Rubot
11
+ class Client < Discordrb::Bot
12
+ attr_reader :commands, :events, :rapplication_commands
13
+
14
+ def initialize
15
+ super(:token => ENV["BOT_TOKEN"], :intents => :all, :ignore_bots => true)
16
+ end
17
+
18
+ def run(background = false)
19
+ @events.each(&:run)
20
+ Thread.new do
21
+ loop do
22
+ stop if $stdin.gets.chomp.downcase.match?(/^\.exit/)
23
+ end
24
+ end
25
+ super(background)
26
+ end
27
+
28
+ def add_command(name:, &block)
29
+ @commands ||= Array[]
30
+ @commands << Command.new(block, :name => name)
31
+ end
32
+
33
+ def add_event(attributes = {}, name:, &block)
34
+ @events ||= Array[]
35
+ @events << Event.new(block, attributes, :name => name)
36
+ end
37
+
38
+ def command(name)
39
+ @commands[name] || false
40
+ end
41
+
42
+ def event(name)
43
+ @events[name] || false
44
+ end
45
+
46
+ def add_application_command(command:, subcommand: nil, group: nil, proprieties: nil, default_permission: nil, &block)
47
+ @rapplication_commands ||= Array[]
48
+ command = RApplicationCommand.new(self, :command => command, :subcommand => subcommand, :group => group, :props => proprieties, :default_permissions => default_permission, &block)
49
+ command.create
50
+ @rapplication_commands << command
51
+ end
52
+
53
+ def remove_application_commands
54
+ get_application_commands.map(&:id).each do |id|
55
+ delete_application_command(id)
56
+ end
57
+ @rapplication_commands = Array[]
58
+ end
59
+
60
+ def stop(_no_sync = nil)
61
+ remove_application_commands
62
+ super
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubot
4
+ class Command
5
+ attr_reader :props, :execute
6
+
7
+ def initialize(execute, name:)
8
+ @props = Hash[:name => name]
9
+ @execute = execute
10
+ end
11
+
12
+ def [](prop)
13
+ @props[prop.to_sym]
14
+ end
15
+
16
+ def []=(prop, value)
17
+ @props[prop.to_sym] = value
18
+ end
19
+
20
+ def method_missing(symbol, *_args)
21
+ @props[symbol] || super
22
+ end
23
+
24
+ def respond_to_missing?(symbol, _include_private = false)
25
+ !!@props[symbol] || super
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "mongo"
4
+
5
+ module Rubot
6
+ class Database < Mongo::Client
7
+ def initialize(addresses_or_uri, options = nil)
8
+ super
9
+ end
10
+
11
+ def ensure(collection, schema)
12
+ c = self[collection]
13
+ c.insert_one(schema)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,23 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "discordrb"
4
+
5
+ module Rubot
6
+ class Event
7
+ attr_reader :name, :execute, :attributes
8
+
9
+ def initialize(execute, attributes = {}, name:)
10
+ @name = name
11
+ @attributes = attributes
12
+ @execute = execute
13
+ end
14
+
15
+ def run
16
+ raise "Unknown event #{@name}" unless Rubot.client.method(@name.to_sym)
17
+
18
+ Rubot.client.send(@name) do |event|
19
+ @execute.call(event)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "fileutils"
4
+
5
+ module Rubot
6
+ class Manager
7
+ attr_accessor :commands_path, :events_path
8
+
9
+ def initialize(commands_path, events_path)
10
+ @commands_path = commands_path
11
+ @events_path = events_path
12
+ end
13
+
14
+ def files(path)
15
+ files = []
16
+ Dir.entries(path).each do |entry|
17
+ next if %w[. ..].include?(entry)
18
+
19
+ if Dir.exist?("#{@commands_path}/#{entry}")
20
+ files.concat(files("#{path}/#{entry}"))
21
+ else
22
+ files << "#{path}/#{entry}" unless files.include?("#{path}/#{entry}")
23
+ end
24
+ end
25
+ files
26
+ end
27
+
28
+ def command_files
29
+ files(@commands_path)
30
+ end
31
+
32
+ def event_files
33
+ files(@events_path)
34
+ end
35
+
36
+ def load
37
+ command_files.each { |file| Kernel.load file }
38
+ event_files.each { |file| Kernel.load file }
39
+ true
40
+ end
41
+ end
42
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "discordrb"
4
+
5
+ module Rubot
6
+ class RApplicationCommand
7
+ attr_reader :client, :command, :subcommand, :group, :execute, :props, :id, :default_permissions
8
+
9
+ def initialize(client, command:, subcommand: nil, group: nil, props: nil, default_permissions: nil, &block)
10
+ @client = client
11
+ @command = command
12
+ @subcommand = subcommand
13
+ @group = group
14
+ @props = props
15
+ @default_permissions = default_permissions
16
+ @execute = block
17
+ end
18
+
19
+ def create
20
+ @client.register_application_command(@command[:name].to_sym, @command[:description]) do |command|
21
+ unless @subcommand
22
+ proprieties(command) if @props
23
+ permissions(command) if @default_permissions
24
+ next
25
+ end
26
+
27
+ if @group
28
+ command.group(@group[:name].to_sym, @group[:description]) do |group|
29
+ group.command(@subcommand[:name].to_sym, @subcommand[:description]) do |b|
30
+ proprieties(b) if @props
31
+ permissions(command) if @default_permissions
32
+ end
33
+ end
34
+ else
35
+ command.subcommand(@subcommand[:name].to_sym, @subcommand[:description]) do |b|
36
+ proprieties(b) if @props
37
+ permissions(command) if @default_permissions
38
+ end
39
+ end
40
+ end
41
+
42
+ command = @client.application_command(@command[:name].to_sym) do |event|
43
+ @id = event.command_id
44
+ @execute.call(event)
45
+ end
46
+
47
+ return unless @subcommand
48
+
49
+ command.subcommand(@subcommand[:name].to_sym) do |event|
50
+ @id = event.command_id
51
+ @execute.call(event)
52
+ end
53
+ end
54
+
55
+ def proprieties(builder)
56
+ attributes = %i[boolean integer channel number role string user]
57
+ @props.each do |prop|
58
+ next unless attributes.include?(prop[:type])
59
+
60
+ builder.method(prop[:type].to_sym).parameters.each do |type, name|
61
+ raise "Missing required key #{name} in #{prop[:type]} propriety" if type == :req && !prop.key?(name)
62
+ end
63
+
64
+ builder.method(prop.delete(:type)).call(prop.delete(:name), prop.delete(:description), **prop)
65
+ end
66
+ end
67
+
68
+ def permissions(builder); end
69
+
70
+ def application_command
71
+ return nil unless @id
72
+
73
+ @client.get_application_command(@id)
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,102 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubot
4
+ class BetterEmbed < Discordrb::Webhooks::Embed
5
+ # @param [String] template The template to use for the embed.
6
+ def initialize(template = nil)
7
+ super()
8
+ templates(template.to_sym) if template
9
+ end
10
+
11
+ # Returns prebuilt Discordrb::Embed.
12
+ # @return [Discordrb::Embed] The embed.
13
+ def templates(template)
14
+ Hash[
15
+ :default => proc do
16
+ timestamp(Time.at(Time.now.to_i))
17
+ color("ffbc95")
18
+ end,
19
+ :error => proc do
20
+ timestamp(Time.at(Time.now.to_i))
21
+ color("ffbc95")
22
+ end,
23
+ :success => proc do
24
+ timestamp(Time.at(Time.now.to_i))
25
+ color("ffbc95")
26
+ end
27
+ ][template.to_sym].call
28
+ end
29
+
30
+ # set the embed's author
31
+ # @param [Discordrb::Webhooks::EmbedAuthor] author The author to set.
32
+ # @return [Discordrb::Webhooks::Embed] The embed object.
33
+ def author(author)
34
+ self.author = author
35
+ self
36
+ end
37
+
38
+ # set the embed's description
39
+ # @param [String] description The description to set.
40
+ # @return [Discordrb::Webhooks::Embed] The embed object.
41
+ def description(description)
42
+ self.description = description
43
+ self
44
+ end
45
+
46
+ # set the embed's title
47
+ # @param [String] title The title to set.
48
+ # @return [Discordrb::Webhooks::Embed] The embed object.
49
+ def title(title)
50
+ self.title = title
51
+ self
52
+ end
53
+
54
+ # set the embed's url
55
+ # @param [String] url The url to set.
56
+ # @return [Discordrb::Webhooks::Embed] The embed object.
57
+ def url(url)
58
+ self.url = url
59
+ self
60
+ end
61
+
62
+ # set the embed's color
63
+ # @param [String] color The color to set.
64
+ # @return [Discordrb::Webhooks::Embed] The embed object.
65
+ def color(color)
66
+ self.color = color
67
+ self
68
+ end
69
+
70
+ # set the embed's footer
71
+ # @param [Discordrb::Webhooks::EmbedFooter] footer The footer to set.
72
+ # @return [Discordrb::Webhooks::Embed] The embed object.
73
+ def footer(footer)
74
+ self.footer = footer
75
+ self
76
+ end
77
+
78
+ # set the embed's timestamp
79
+ # @param [Time] timestamp The timestamp to set.
80
+ # @return [Discordrb::Webhooks::Embed] The embed object.
81
+ def timestamp(timestamp)
82
+ self.timestamp = timestamp
83
+ self
84
+ end
85
+
86
+ # set the embed's thumbnail
87
+ # @param [Discordrb::Webhooks::EmbedThumbnail] thumbnail The thumbnail to set.
88
+ # @return [Discordrb::Webhooks::Embed] The embed object.
89
+ def thumbnail(thumbnail)
90
+ self.thumbnail = thumbnail
91
+ self
92
+ end
93
+
94
+ # set the embed's image
95
+ # @param [Discordrb::Webhooks::EmbedImage] image The image to set.
96
+ # @return [Discordrb::Webhooks::Embed] The embed object.
97
+ def image(image)
98
+ self.image = image
99
+ self
100
+ end
101
+ end
102
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Rubot
4
+ VERSION = "0.1.0"
5
+ end
data/lib/rubot.rb ADDED
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "rubot/version"
4
+ require File.expand_path("rubot/classes/client", File.dirname(__FILE__))
5
+ require File.expand_path("rubot/utils/better_embed", File.dirname(__FILE__))
6
+
7
+ module Rubot
8
+ def self.new(commands_path, events_path)
9
+ raise "Rubot already initialized. Call Rubot.client to access client." if @client
10
+
11
+ @client = Rubot::Client.new
12
+ @manager = Rubot::Manager.new(commands_path, events_path)
13
+ @client.remove_application_commands
14
+ @manager.load
15
+ @client
16
+ end
17
+
18
+ # @return [Rubot::Client]
19
+ def self.client
20
+ return @client if @client
21
+
22
+ raise "Rubot is not initialized. Call Rubot.new(commands_path, events_path) first."
23
+ end
24
+
25
+ # @return [Rubot::Manager]
26
+ def self.manager
27
+ return @manager if @manager
28
+
29
+ raise "Rubot is not initialized. Call Rubot.new(commands_path, events_path) first." end
30
+ end
data/rubot.gemspec ADDED
@@ -0,0 +1,37 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/rubot/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "discord_rubot"
7
+ spec.version = Rubot::VERSION
8
+ spec.authors = ["Senchuu"]
9
+ spec.email = ["senchuuuu@gmail.com"]
10
+
11
+ spec.summary = "A most advanced version of Bot.rb"
12
+ spec.description = "Use rubot as a command handler for, your ruby written discord bot. Simply to use, and fun!"
13
+ spec.homepage = "https://github.com/Senchuu/rubot"
14
+ spec.license = "MIT"
15
+ spec.required_ruby_version = ">= 2.6.0"
16
+
17
+ spec.metadata["allowed_push_host"] = "https://rubygems.org"
18
+
19
+ spec.metadata["homepage_uri"] = spec.homepage
20
+ spec.metadata["source_code_uri"] = spec.homepage
21
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
26
+ `git ls-files -z`.split("\x0").reject do |f|
27
+ (f == __FILE__) || f.match(%r{\A(?:(?:test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
28
+ end
29
+ end
30
+ spec.bindir = "exe"
31
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
32
+ spec.require_paths = ["lib"]
33
+
34
+ spec.add_dependency "discordrb"
35
+ spec.add_dependency "dotenv"
36
+ spec.add_dependency "mongo"
37
+ end
data/sig/client.rbs ADDED
@@ -0,0 +1,17 @@
1
+ module Rubot
2
+ class Client
3
+ attr_reader commands: Array[Command]
4
+ attr_reader events: Array[Event]
5
+ attr_reader rapplication_commands: Array[RApplicationCommand]
6
+
7
+ def intialize: -> void
8
+ def run: (bool) -> void
9
+ def add_command: (name: String, block: Proc) -> Command
10
+ def command: (String) -> (Command | false)
11
+ def add_event: (?Hash[Symbol, Object], Proc, name: String) -> Event
12
+ def event: (String) -> (Event | false)
13
+ def add_application_command: (command: Hash[Symbol, String], subcommand: Hash[Symbol, String]?, group: Symbol?) -> void
14
+ def remove_application_commands: () -> []
15
+ def stop: () -> void
16
+ end
17
+ end
data/sig/command.rbs ADDED
@@ -0,0 +1,10 @@
1
+ module Rubot
2
+ class Command
3
+ attr_reader props: Hash[Symbol, String]
4
+ attr_reader execute: Proc
5
+
6
+ def initialize: (Proc, name: String) -> void
7
+ def []: (String) -> String
8
+ def []=: (String, String) -> String
9
+ end
10
+ end
data/sig/event.rbs ADDED
@@ -0,0 +1,10 @@
1
+ module Rubot
2
+ class Event
3
+ attr_reader name: String
4
+ attr_reader execute: Proc
5
+ attr_reader attributes: Hash[Symbol, Object]
6
+
7
+ def initialize: (Proc, Hash[Symbol, Object], name: String) -> void
8
+ def run: -> void
9
+ end
10
+ end
data/sig/manager.rbs ADDED
@@ -0,0 +1,12 @@
1
+ module Rubot
2
+ class Manager
3
+ attr_accessor path: String
4
+
5
+ def initialize: (String) -> void
6
+ def files: (String) -> Array[String]
7
+ def load_commands: (Array[String]) -> void
8
+ def command_files: -> Array[String]
9
+ def event_files: -> Array[String]
10
+ def load: -> bool
11
+ end
12
+ end
@@ -0,0 +1,15 @@
1
+ module Rubot
2
+ class RApplicationCommand
3
+ attr_reader client: Rubot::Client
4
+ attr_reader command: Hash[Symbol, String]
5
+ attr_reader subcommand: Hash[Symbol, String]?
6
+ attr_reader group: Symbol?
7
+ attr_reader execute: Proc
8
+ attr_reader props: Hash[Symbol, String]?
9
+ attr_reader application_command: Discordrb::ApplicationCommand?
10
+
11
+ def initialize: (Rubot::Client, command: Hash[Symbol, String], subcommand: Hash[Symbol, String]?, group: Symbol?, props: Hash[Symbol, String]?) -> void
12
+ def create: -> void
13
+ def proprieties: -> void
14
+ end
15
+ end
data/sig/rubot.rbs ADDED
@@ -0,0 +1,4 @@
1
+ module Rubot
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,121 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: discord_rubot
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Senchuu
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-07-31 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: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: dotenv
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
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: mongo
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ description: Use rubot as a command handler for, your ruby written discord bot. Simply
56
+ to use, and fun!
57
+ email:
58
+ - senchuuuu@gmail.com
59
+ executables: []
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - ".idea/.gitignore"
64
+ - ".idea/Rubot.iml"
65
+ - ".idea/discord.xml"
66
+ - ".idea/misc.xml"
67
+ - ".idea/modules.xml"
68
+ - ".idea/vcs.xml"
69
+ - ".rubocop.yml"
70
+ - CHANGELOG.md
71
+ - CODE_OF_CONDUCT.md
72
+ - Gemfile
73
+ - Gemfile.lock
74
+ - LICENSE.txt
75
+ - README.md
76
+ - Rakefile
77
+ - bin/console
78
+ - bin/setup
79
+ - lib/rubot.rb
80
+ - lib/rubot/classes/client.rb
81
+ - lib/rubot/classes/command.rb
82
+ - lib/rubot/classes/database.rb
83
+ - lib/rubot/classes/event.rb
84
+ - lib/rubot/classes/manager.rb
85
+ - lib/rubot/classes/rapplication_command.rb
86
+ - lib/rubot/utils/better_embed.rb
87
+ - lib/rubot/version.rb
88
+ - rubot.gemspec
89
+ - sig/client.rbs
90
+ - sig/command.rbs
91
+ - sig/event.rbs
92
+ - sig/manager.rbs
93
+ - sig/rapplication_command.rbs
94
+ - sig/rubot.rbs
95
+ homepage: https://github.com/Senchuu/rubot
96
+ licenses:
97
+ - MIT
98
+ metadata:
99
+ allowed_push_host: https://rubygems.org
100
+ homepage_uri: https://github.com/Senchuu/rubot
101
+ source_code_uri: https://github.com/Senchuu/rubot
102
+ post_install_message:
103
+ rdoc_options: []
104
+ require_paths:
105
+ - lib
106
+ required_ruby_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: 2.6.0
111
+ required_rubygems_version: !ruby/object:Gem::Requirement
112
+ requirements:
113
+ - - ">="
114
+ - !ruby/object:Gem::Version
115
+ version: '0'
116
+ requirements: []
117
+ rubygems_version: 3.2.3
118
+ signing_key:
119
+ specification_version: 4
120
+ summary: A most advanced version of Bot.rb
121
+ test_files: []