bwrb 0.3.2

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: e9cbfa5d37841cb21e596090d6e053388ed883ac78cdf925690d8b1fd7d95859
4
+ data.tar.gz: e26a9036f8603fb5eba8a7677642c05ad88611dc09511626affeba8c6c7a9cb1
5
+ SHA512:
6
+ metadata.gz: 7673a982c6a26c561e7bdeb84bd272173509d15b732e317bd6fbdf2e281ecbbefed57c52239adcfb108b95b86b34d5cdead3f801748abebc9dbdb6ef27573264
7
+ data.tar.gz: 163395d260a0624feb1e383da507a8250f5427277b5ab939f1a15e0953951b32f684f05496fe8699d49446880d6d453369ffd151f0068917170e9fb8ec3c7ea3
data/.gitignore ADDED
@@ -0,0 +1,12 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ Gemfile.lock
10
+
11
+ # rspec failure tracking
12
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
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: 120
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ gemspec name: "bwrb"
6
+
7
+ gem "rake", "~> 13.0"
8
+ gem "rspec", "~> 3.0"
9
+ gem "rubocop", "~> 1.7"
10
+ gem "yaml", "~> 0.2.0"
11
+ gem "json", "~> 2.6", ">= 2.6.1"
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2022 Abdfn
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 all
13
+ 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 THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,57 @@
1
+ # Botwayrb
2
+
3
+ > Ruby client package for Botway.
4
+
5
+ ## Dependencies
6
+
7
+ * Ruby >= 2.6 supported
8
+ * An installed build system for native extensions (on Windows, make sure you download the "Ruby+Devkit" version of [RubyInstaller](https://rubyinstaller.org/downloads/))
9
+
10
+ ## Installation
11
+
12
+ ### With Bundler
13
+
14
+ Using [Bundler](https://bundler.io/#getting-started), you can add bwrb to your Gemfile:
15
+
16
+ gem "bwrb"
17
+
18
+ And then install via `bundle install`.
19
+
20
+ ### With Gem
21
+
22
+ Alternatively, while Bundler is the recommended option, you can also install bwrb without it.
23
+
24
+ #### Linux / macOS
25
+
26
+ gem install bwrb
27
+
28
+ #### Windows
29
+
30
+ > **Make sure you have the DevKit installed!**
31
+ gem install bwrb --platform=ruby
32
+
33
+ ```ruby
34
+ gem "bwrb"
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ > this is an example of botway discord ruby template
40
+
41
+ ```ruby
42
+ require "discordrb"
43
+ require "bwrb"
44
+
45
+ bw = Botwayrb::Core.new
46
+ bot = Discordrb::Bot.new token: bw.get_token
47
+
48
+ bot.message(with_text: "ping") do |event|
49
+ event.respond "pong!"
50
+ end
51
+
52
+ bot.run
53
+ ```
54
+
55
+ ## License
56
+
57
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
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 "bwrb"
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
data/bwrb.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/bwrb/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "bwrb"
7
+ spec.version = Botwayrb::VERSION
8
+ spec.authors = ["abdfnx"]
9
+
10
+ spec.summary = "Ruby client package for Botway."
11
+ spec.description = spec.summary
12
+ spec.homepage = "https://github.com/abdfnx/botway"
13
+ spec.license = "MIT"
14
+ spec.required_ruby_version = Gem::Requirement.new(">= 2.4.0")
15
+
16
+ spec.metadata["homepage_uri"] = spec.homepage
17
+ spec.metadata["source_code_uri"] = "https://rubygems.org/gems/bwrb"
18
+ spec.metadata["changelog_uri"] = "https://github.com/abdfnx/botway/main/CHANGELOG.md"
19
+
20
+ spec.files = Dir.chdir(File.expand_path(__dir__)) do
21
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{\A(?:test|spec|features)/}) }
22
+ end
23
+
24
+ spec.bindir = "exe"
25
+ spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
26
+ spec.require_paths = ["lib"]
27
+
28
+ spec.add_dependency "yaml", "~> 0.2.0"
29
+ spec.add_dependency "json", "~> 2.6"
30
+
31
+ spec.add_development_dependency "bundler", ">= 1.10", "< 3"
32
+ spec.add_development_dependency "rake", "~> 13.0"
33
+ spec.add_development_dependency "rspec", "~> 3.11.0"
34
+ spec.add_development_dependency "rspec-prof", "~> 0.0.7"
35
+ spec.add_development_dependency "rubocop", "~> 1.27.0"
36
+ spec.add_development_dependency "rubocop-performance", "~> 1.0"
37
+ spec.add_development_dependency "rubocop-rake", "~> 0.6.0"
38
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Botwayrb
4
+ VERSION = "0.3.2"
5
+ end
data/lib/bwrb.rb ADDED
@@ -0,0 +1,47 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "bwrb/version"
4
+ require "yaml"
5
+ require "json"
6
+
7
+ module Botwayrb
8
+ BotwatConfig = JSON.parse(File.read(File.join(File.expand_path("~"), ".botway", "botway.json")))
9
+
10
+ class Error < StandardError; end
11
+
12
+ class Core
13
+ def get_bot_info(value)
14
+ data = YAML.load_file(".botway.yaml")
15
+
16
+ data["bot"][value]
17
+ end
18
+
19
+ def get_token()
20
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_token"]
21
+ end
22
+
23
+ def get_app_id()
24
+ if get_bot_info("type") == "slack"
25
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_token"]
26
+ else
27
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_id"]
28
+ end
29
+ end
30
+
31
+ def get_guild_id(serverName)
32
+ if get_bot_info("type") != "discord"
33
+ raise Error, "ERROR: This function/feature is only working with discord bots"
34
+ else
35
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["guilds"][serverName]["server_id"]
36
+ end
37
+ end
38
+
39
+ def get_signing_secret()
40
+ if get_bot_info("type") != "slack"
41
+ raise Error, "ERROR: This function/feature is only working with slack bots"
42
+ else
43
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["signing_secret"]
44
+ end
45
+ end
46
+ end
47
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bwrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.3.2
5
+ platform: ruby
6
+ authors:
7
+ - abdfnx
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-09-17 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: yaml
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.2.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.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: json
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '2.6'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '2.6'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.10'
48
+ - - "<"
49
+ - !ruby/object:Gem::Version
50
+ version: '3'
51
+ type: :development
52
+ prerelease: false
53
+ version_requirements: !ruby/object:Gem::Requirement
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ version: '1.10'
58
+ - - "<"
59
+ - !ruby/object:Gem::Version
60
+ version: '3'
61
+ - !ruby/object:Gem::Dependency
62
+ name: rake
63
+ requirement: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - "~>"
66
+ - !ruby/object:Gem::Version
67
+ version: '13.0'
68
+ type: :development
69
+ prerelease: false
70
+ version_requirements: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - "~>"
73
+ - !ruby/object:Gem::Version
74
+ version: '13.0'
75
+ - !ruby/object:Gem::Dependency
76
+ name: rspec
77
+ requirement: !ruby/object:Gem::Requirement
78
+ requirements:
79
+ - - "~>"
80
+ - !ruby/object:Gem::Version
81
+ version: 3.11.0
82
+ type: :development
83
+ prerelease: false
84
+ version_requirements: !ruby/object:Gem::Requirement
85
+ requirements:
86
+ - - "~>"
87
+ - !ruby/object:Gem::Version
88
+ version: 3.11.0
89
+ - !ruby/object:Gem::Dependency
90
+ name: rspec-prof
91
+ requirement: !ruby/object:Gem::Requirement
92
+ requirements:
93
+ - - "~>"
94
+ - !ruby/object:Gem::Version
95
+ version: 0.0.7
96
+ type: :development
97
+ prerelease: false
98
+ version_requirements: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - "~>"
101
+ - !ruby/object:Gem::Version
102
+ version: 0.0.7
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - "~>"
108
+ - !ruby/object:Gem::Version
109
+ version: 1.27.0
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: 1.27.0
117
+ - !ruby/object:Gem::Dependency
118
+ name: rubocop-performance
119
+ requirement: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - "~>"
122
+ - !ruby/object:Gem::Version
123
+ version: '1.0'
124
+ type: :development
125
+ prerelease: false
126
+ version_requirements: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - "~>"
129
+ - !ruby/object:Gem::Version
130
+ version: '1.0'
131
+ - !ruby/object:Gem::Dependency
132
+ name: rubocop-rake
133
+ requirement: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - "~>"
136
+ - !ruby/object:Gem::Version
137
+ version: 0.6.0
138
+ type: :development
139
+ prerelease: false
140
+ version_requirements: !ruby/object:Gem::Requirement
141
+ requirements:
142
+ - - "~>"
143
+ - !ruby/object:Gem::Version
144
+ version: 0.6.0
145
+ description: Ruby client package for Botway.
146
+ email:
147
+ executables: []
148
+ extensions: []
149
+ extra_rdoc_files: []
150
+ files:
151
+ - ".gitignore"
152
+ - ".rspec"
153
+ - ".rubocop.yml"
154
+ - Gemfile
155
+ - LICENSE
156
+ - README.md
157
+ - Rakefile
158
+ - bin/console
159
+ - bin/setup
160
+ - bwrb.gemspec
161
+ - lib/bwrb.rb
162
+ - lib/bwrb/version.rb
163
+ homepage: https://github.com/abdfnx/botway
164
+ licenses:
165
+ - MIT
166
+ metadata:
167
+ homepage_uri: https://github.com/abdfnx/botway
168
+ source_code_uri: https://rubygems.org/gems/bwrb
169
+ changelog_uri: https://github.com/abdfnx/botway/main/CHANGELOG.md
170
+ post_install_message:
171
+ rdoc_options: []
172
+ require_paths:
173
+ - lib
174
+ required_ruby_version: !ruby/object:Gem::Requirement
175
+ requirements:
176
+ - - ">="
177
+ - !ruby/object:Gem::Version
178
+ version: 2.4.0
179
+ required_rubygems_version: !ruby/object:Gem::Requirement
180
+ requirements:
181
+ - - ">="
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ requirements: []
185
+ rubygems_version: 3.1.2
186
+ signing_key:
187
+ specification_version: 4
188
+ summary: Ruby client package for Botway.
189
+ test_files: []