emissary-ruby 0.0.2 → 0.0.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 6027531fa65f64344606200f289efe2fc218fc9424c628dfc2cb5e6c4393a095
4
- data.tar.gz: ff0c4c8ef3afe0bde5f1c2ce06f5c06e00a3cae5de51ac0d6899e4ee99e7ce78
3
+ metadata.gz: e079c3d6412aec1ff8fafa45be88815d1b7d9d21b2b6e1bdfa73fc7f3877655c
4
+ data.tar.gz: 11cb0ba431892f25777d7a81cb3d7ed74f80913536147ce5e6a361597e204aec
5
5
  SHA512:
6
- metadata.gz: 628c743051894f063c89effed6d752a4790be51b68e702040e601f9f13ec6f059a50c5cfd518bb5092d62d6f76ca393ca203579dd28d5d4e2c9ba73f1443fa11
7
- data.tar.gz: 8189472f28905e98cc8e7196f58c2dc64a7e5980b52cdeb22dcadbff258a05f628358cb20f9df40bb6b9f8c42ea7dfdd6429bd819849680cfe1548cd4fd4e036
6
+ metadata.gz: 910d242d70f9dbd1ed7cc3561b81eb4469d2bb10564d071e7ac2830d3441b22e5d7c21bc0f3cbd644db32eb9b57e73448241fa8747a63932db2e89714ded6e24
7
+ data.tar.gz: 2d45556b04e7ef17700809d96c01b1dc6b5b28d7addf737d61054c911fe9eeb5e0073a3d31e05c87359489d0ebdc530c361cdf88ba376fa45746c93008b792c1
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at simoncorreaocampo@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/README.md CHANGED
@@ -2,6 +2,9 @@
2
2
  Simple error catcher integrated with services like Discord and Trello, use chatbots to monitor your application and server.
3
3
  Receive error catching reports to a Discord Server Channel, and use chatbots to send commands and fetch reports.
4
4
 
5
+ # PRESENTATION
6
+ [![Watch the presentation](https://github.com/MakarovCode/Emissary/raw/main/thumb.png)](https://dms.licdn.com/playlist/C4E05AQHyxbCfCVGHYA/mp4-720p-30fp-crf28/0/1623710691404?e=1623808800&v=beta&t=gUzmyqiD7vgxfWC7KYeU53-us6buF-kf2o60RfZfxuQ)
7
+
5
8
  # Features
6
9
  * This tools allows you to configurate the errors or lines you want to capture from any log file, in this example you will find a configuration for catching HTTP ERROR 500.
7
10
  * You can configurate the timeframes in which the logs will be read, the conditions that triggers the errores, the lines to fetch from the files, the language to markup the error to discord, characters to ignore, how often the errors fetched would be clear, and how often you want a receive reports with error ocurrences.
@@ -22,38 +25,26 @@ Receive error catching reports to a Discord Server Channel, and use chatbots to
22
25
  * 4. Find your Trello **ListID**, you can do this by openning the web tools in your browser, click on the navigation tab and watch for the navigation log when editing the name of your list, the ID will be visible under the **Preview Tab**
23
26
  * 5. Use the Trello **ListID** in the loggr.json file under the configuration you want trello to work with.
24
27
 
25
- # 2. Download / Clone the code
26
- ```bash
27
-
28
- git clone git@github.com:MakarovCode/Emissary.git
29
-
30
- ```
31
-
32
- # 3. Make it run
33
- create runner.rb or config/initializer/emissary.rb file
34
-
28
+ # 2. Install gem and dependencies
35
29
  ```ruby
36
30
 
37
- require './emissary'
31
+ #Gemfile
32
+ gem "emissary-ruby"
33
+ gem "discordrb"
34
+ gem "ruby-trello"
38
35
 
39
- Emissary.configure do |config|
40
- config.server_name = "A name for chat titles"
41
- config.header_format = "__***{title}***__" #Any markup
42
- config.webhooks_url = '{discord webhooks_url}'
43
- config.bot_token = '{discord bot_token}'
44
- config.trello_public_key = '{trello public_key}'
45
- config.trello_member_token = '{trello member_token}'
46
- end
47
-
48
- emi = Emissary.new
36
+ #Or install each gem
37
+ gem install "discordrb"
38
+ gem install "ruby-trello"
39
+ gem install "emissary-ruby"
49
40
 
50
41
  ```
51
42
 
52
- # 4. Configure your log readers and commands in the loggr.json file
43
+ # 3. Configure your log readers and commands by creating a file emissary.json inside your project.
53
44
 
54
45
  See some examples
55
46
 
56
- ```javascript
47
+ ```json
57
48
  {
58
49
  "rails": {
59
50
  "name": "Rails Logger",
@@ -109,6 +100,14 @@ See some examples
109
100
  }
110
101
  ```
111
102
 
103
+ # 3. Make it run
104
+ Run the **bundle exec emissary** command and pass as parameter the path to the **emissary.json** file you just created
105
+
106
+ ```ruby
107
+ bundle exec emissary "/path/to/config/file.json"
108
+
109
+ ```
110
+
112
111
  # 5. If everything goes right
113
112
  You can type the next commands in your Discord Server Channel and the Chatbot will answer.
114
113
 
@@ -121,10 +120,17 @@ You can type the next commands in your Discord Server Channel and the Chatbot wi
121
120
 
122
121
  !emy rails {id} trello #Add message report to trello list
123
122
  ```
123
+
124
124
  # Roadmap
125
125
  This tools is in the making
126
- * Upload as Ruby Gem
126
+ * Multi server with the same BOT
127
+ * Better command params handling
128
+ * Convert the message HASH into a Ruby Class
129
+ * Change the JSON config file to a init class configuration for better customization
130
+ * Title dates formatting
131
+ * Gem dependencies
127
132
  * Regex conditioning
128
133
  * Slack Integration
129
134
  * Email reports Integration
130
- * Convert the message HASH into a Ruby Class
135
+ * Authy integration for TwoFactor authentication for sensible commands
136
+ * API Keys with ENV variables
data/bin/emissary ADDED
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/emissary'
4
+
5
+ file = File.open ARGV[0]
6
+ c_config = JSON.load file
7
+
8
+ Emissary.configure do |config|
9
+ # usuario transacional para sms instantaneos
10
+ config.server_name = c_config["server_name"]
11
+ config.header_format = c_config["header_format"]
12
+ config.webhooks_url = c_config["webhooks_url"]
13
+ config.bot_token = c_config["bot_token"]
14
+ config.trello_public_key = c_config["trello_public_key"]
15
+ config.trello_member_token = c_config["trello_member_token"],
16
+ config.json_file_path = ARGV[0]
17
+ end
18
+
19
+
20
+ begin
21
+ puts "====> Emissary is starting..."
22
+ puts "====> Server name #{Emissary.server_name}..."
23
+
24
+ emi = Emissary.new
25
+ rescue => e
26
+ puts "#{e}"
27
+ exit 1
28
+ end
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/emissary.gemspec ADDED
@@ -0,0 +1,31 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = "emissary-ruby"
7
+ spec.version = "0.0.7"
8
+ spec.authors = ["MakarovCode"]
9
+ spec.email = ["simoncorreaocampo@gmail.com"]
10
+
11
+ spec.summary = "Simple error catcher integrated with services like Discord and Trello, use chatbots to monitor your application and server. Receive error catching reports to a Discord Server Channel, and use chatbots to send commands and fetch reports."
12
+ spec.homepage = "https://github.com/MakarovCode/Emissary"
13
+ spec.license = "MIT"
14
+
15
+ # Specify which files should be added to the gem when it is released.
16
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
17
+ spec.files = ["emissary.gemspec", "README.md", "CODE_OF_CONDUCT.md"] + `git ls-files | grep -E '^(bin|lib|web)'`.split("\n")
18
+ # spec.bindir = "exe"
19
+ spec.executables = ["emissary"]
20
+ spec.require_paths = ["lib"]
21
+
22
+ # spec.add_development_dependency "bundler", "~> 2.0"
23
+ # spec.add_development_dependency "rake", "~> 13.0"
24
+ # spec.add_development_dependency "discordrb", "~> 3.4.2"
25
+ # spec.add_development_dependency "ruby-trello", "~> 3.0.0"
26
+ #
27
+ # spec.add_runtime_dependency "bundler", "~> 2.0"
28
+ # spec.add_runtime_dependency "rake", "~> 13.0"
29
+ # spec.add_runtime_dependency "discordrb", "~> 3.4.2"
30
+ # spec.add_runtime_dependency "ruby-trello", "~> 3.0.0"
31
+ end
data/lib/emissary.rb CHANGED
@@ -1,14 +1,11 @@
1
1
  require 'discordrb'
2
-
3
2
  require "json"
4
-
5
-
6
- require './lib/loggr';
3
+ require 'loggr';
7
4
 
8
5
  class Emissary
9
6
 
10
7
  class << self
11
- attr_accessor :webhooks_url, :bot_token, :trello_public_key, :trello_member_token, :server_name, :header_format
8
+ attr_accessor :webhooks_url, :bot_token, :trello_public_key, :trello_member_token, :server_name, :header_format, :json_file_path
12
9
  def configure(&block)
13
10
  block.call(self)
14
11
  end
@@ -38,7 +35,7 @@ class Emissary
38
35
 
39
36
  def read_loggrs
40
37
 
41
- file = File.open "./lib/loggr.json"
38
+ file = File.open Emissary.json_file_path
42
39
  raw_loggrs = JSON.load file
43
40
  raw_loggrs.each do |k, v|
44
41
  loggr = Loggr.new v
@@ -61,16 +58,24 @@ class Emissary
61
58
  if loggr.bash_command == ""
62
59
  if args.count > 1
63
60
  if args[1] == "report"
64
- loggr.report
65
- "#{Emissary.header}\nGenerating Last Report"
61
+ if args[2].nil? || (!args[2].nil? && args[2] == Emissary.server_name)
62
+ loggr.report
63
+ "#{Emissary.header}\nGenerating Last Report"
64
+ end
66
65
  elsif args[1] == "fetch"
67
- loggr.fetch
68
- "#{Emissary.header}\nFetching Report"
66
+ if args[2].nil? || (!args[2].nil? && args[2] == Emissary.server_name)
67
+ loggr.fetch
68
+ "#{Emissary.header}\nFetching Report"
69
+ end
69
70
  elsif args[1] == "clear"
70
- loggr.clear
71
- "#{Emissary.header}\nClearing Report"
71
+ if args[2].nil? || (!args[2].nil? && args[2] == Emissary.server_name)
72
+ loggr.clear
73
+ "#{Emissary.header}\nClearing Report"
74
+ end
72
75
  elsif args[1] == "last"
73
- loggr.message_to_chat loggr.last_message
76
+ if args[2].nil? || (!args[2].nil? && args[2] == Emissary.server_name)
77
+ loggr.message_to_chat loggr.last_message
78
+ end
74
79
  elsif ![nil, ""].include?(args[1]) && args[1].include?(loggr.alias)
75
80
  if args.count > 2
76
81
  if args[2] == "trello"
data/lib/loggr.rb CHANGED
@@ -72,7 +72,7 @@ class Loggr
72
72
  if @messages["#{file_lines[i+1]}"].nil?
73
73
  @last_id += 1
74
74
  @messages["#{file_lines[i+1]}"] = {
75
- id: "#{@alias}-#{@last_id}",
75
+ id: "#{Emissary.server_name}-#{@alias}-#{@last_id}",
76
76
  trigger: "Completed 500 Internal Server Error",
77
77
  lines: file_lines[i..(i+@lines)],
78
78
  count: 1,
@@ -93,7 +93,7 @@ class Loggr
93
93
  end
94
94
 
95
95
  def last_message
96
- message_by_id("#{@alias}-#{@last_id}")
96
+ message_by_id("#{Emissary.server_name}-#{@alias}-#{@last_id}")
97
97
  end
98
98
 
99
99
  def lines_to_code(message)
metadata CHANGED
@@ -1,81 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: emissary-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - MakarovCode
8
8
  autorequire:
9
- bindir: exe
9
+ bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-13 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.4.2
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 3.4.2
27
- - !ruby/object:Gem::Dependency
28
- name: ruby-trello
29
- requirement: !ruby/object:Gem::Requirement
30
- requirements:
31
- - - "~>"
32
- - !ruby/object:Gem::Version
33
- version: 3.0.0
34
- type: :development
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
39
- - !ruby/object:Gem::Version
40
- version: 3.0.0
41
- - !ruby/object:Gem::Dependency
42
- name: discordrb
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: 3.4.2
48
- type: :runtime
49
- prerelease: false
50
- version_requirements: !ruby/object:Gem::Requirement
51
- requirements:
52
- - - "~>"
53
- - !ruby/object:Gem::Version
54
- version: 3.4.2
55
- - !ruby/object:Gem::Dependency
56
- name: ruby-trello
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - "~>"
60
- - !ruby/object:Gem::Version
61
- version: 3.0.0
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - "~>"
67
- - !ruby/object:Gem::Version
68
- version: 3.0.0
11
+ date: 2021-06-16 00:00:00.000000000 Z
12
+ dependencies: []
69
13
  description:
70
14
  email:
71
15
  - simoncorreaocampo@gmail.com
72
- executables: []
16
+ executables:
17
+ - emissary
73
18
  extensions: []
74
19
  extra_rdoc_files: []
75
20
  files:
76
- - ".gitignore"
77
- - LICENSE
21
+ - CODE_OF_CONDUCT.md
78
22
  - README.md
23
+ - bin/emissary
24
+ - bin/setup
25
+ - emissary.gemspec
79
26
  - lib/emissary.rb
80
27
  - lib/loggr.json
81
28
  - lib/loggr.rb
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /runner.rb
2
- /.bundle/
3
- /.yardoc
4
- /_yardoc/
5
- /coverage/
6
- /doc/
7
- /pkg/
8
- /spec/reports/
9
- /tmp/
10
- *.gem
data/LICENSE DELETED
@@ -1,21 +0,0 @@
1
- MIT License
2
-
3
- Copyright (c) 2021 Simón
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.