botwayrb 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: 5b596ce276c0822c1a429a104dedc5b4d3467376dc5824df83bf7b4f23bfbfd0
4
+ data.tar.gz: fedc85bb64797cdd53fb6064e353bcaf306b25fa2bed1e41478bab924f2cdab6
5
+ SHA512:
6
+ metadata.gz: 064e7847cc6bce1256be6bb42044619fc59053496eb5bd1ed20bcabef24a552791c926f2705839a505e5f27a3223d55134b0f98fb5ad48720a54c2f2146fdd81
7
+ data.tar.gz: b06e1034016235bb8919b164d8100039d7845c5fcdf2fa2dde3584c2c63c6177f80517b52767f137cc146a7c27a86d4993ff94c656854c6e3b46c058b4870890
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: "botwayrb"
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 botwayrb to your Gemfile:
15
+
16
+ gem "botwayrb"
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 botwayrb without it.
23
+
24
+ #### Linux / macOS
25
+
26
+ gem install botwayrb
27
+
28
+ #### Windows
29
+
30
+ > **Make sure you have the DevKit installed! See the [Dependencies](https://github.com/shardlab/botwayrb#dependencies) section)**
31
+ gem install botwayrb --platform=ruby
32
+
33
+ ```ruby
34
+ gem "botwayrb"
35
+ ```
36
+
37
+ ## Usage
38
+
39
+ > this is an example of botway discord ruby template
40
+
41
+ ```ruby
42
+ require "discordrb"
43
+ require "botwayrb"
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 "botwayrb"
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/botwayrb.gemspec ADDED
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "lib/botwayrb/version"
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "botwayrb"
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/botwayrb"
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.1.0"
5
+ end
data/lib/botwayrb.rb ADDED
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "botwayrb/version"
4
+ require "yaml"
5
+ require "json"
6
+
7
+
8
+ module Botwayrb
9
+ BotwatConfig = JSON.parse(File.read(File.join(File.expand_path("~"), ".botway", "botway.json")))
10
+
11
+ class Error < StandardError; end
12
+
13
+ class Core
14
+ def get_bot_info(value)
15
+ data = YAML.load_file(".botway.yaml")
16
+
17
+ data["bot"][value]
18
+ end
19
+
20
+ def get_token()
21
+ if get_bot_info("lang") != "ruby"
22
+ raise Error, "ERROR: Botway is not running in Ruby"
23
+ else
24
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_token"]
25
+ end
26
+ end
27
+
28
+ def get_app_id()
29
+ if get_bot_info("lang") != "ruby"
30
+ raise Error, "ERROR: Botway is not running in Ruby"
31
+ else
32
+ if get_bot_info("type") == "slack"
33
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_token"]
34
+ else
35
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["bot_app_id"]
36
+ end
37
+ end
38
+ end
39
+
40
+ def get_guild_id(serverName)
41
+ if get_bot_info("lang") != "ruby"
42
+ raise Error, "ERROR: Botway is not running in Ruby"
43
+ elsif get_bot_info("type") != "discord"
44
+ raise Error, "ERROR: This function/feature is only working with discord bots."
45
+ else
46
+ BotwatConfig["botway"]["bots"][get_bot_info("name")]["guilds"][serverName]["server_id"]
47
+ end
48
+ end
49
+ end
50
+ end
metadata ADDED
@@ -0,0 +1,189 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: botwayrb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - abdfnx
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2022-05-04 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
+ - botwayrb.gemspec
161
+ - lib/botwayrb.rb
162
+ - lib/botwayrb/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/botwayrb
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: []