Module: PWN::Plugins::SlackClient
- Defined in:
- lib/pwn/plugins/slack_client.rb
Overview
This plugin is used for interacting w/ Slack over the Web API.
Constant Summary collapse
Class Method Summary collapse
-
.authors ⇒ Object
- Author(s)
-
0day Inc.
-
.help ⇒ Object
Display Usage for this Module.
-
.login(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::SlackClient.login( api_token: ‘required slack api token’ ).
-
.logout(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::SlackClient.logout( slack_obj: ‘required slack_obj returned from login method’ ).
-
.post_message(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::SlackClient.post_message( slack_obj: ‘required slack_obj returned from login method’, channel: ‘required #channel to post message’, message: ‘required message to post’ ).
Class Method Details
.authors ⇒ Object
- Author(s)
-
0day Inc. <[email protected]>
75 76 77 78 79 |
# File 'lib/pwn/plugins/slack_client.rb', line 75 public_class_method def self. "AUTHOR(S): 0day Inc. <[email protected]> " end |
.help ⇒ Object
Display Usage for this Module
83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 |
# File 'lib/pwn/plugins/slack_client.rb', line 83 public_class_method def self.help puts "USAGE: slack_obj = #{self}.login( api_token: 'optional slack api token (will prompt if blank)' ) #{self}.post_message( slack_obj: 'required slack_obj returned from login method', channel: 'required #channel to post message', message: 'required message to post' ) #{self}.logout( slack_obj: 'required slack_obj returned from login method' ) #{self}.authors " end |
.login(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::SlackClient.login(
api_token: 'required slack api token'
)
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/pwn/plugins/slack_client.rb', line 16 public_class_method def self.login(opts = {}) api_token = opts[:api_token] if opts[:api_token].nil? api_token = PWN::Plugins::AuthenticationHelper.mask_password else api_token = opts[:api_token].to_s.scrub end @@logger.info('Logging into Slack...') slack_obj = Slack::Web::Client.new slack_obj.token = api_token slack_obj.auth_test slack_obj rescue StandardError => e raise e end |
.logout(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::SlackClient.logout(
slack_obj: 'required slack_obj returned from login method'
)
63 64 65 66 67 68 69 70 71 |
# File 'lib/pwn/plugins/slack_client.rb', line 63 public_class_method def self.logout(opts = {}) slack_obj = opts[:slack_obj] @@logger.info('Logging out...') slack_obj.token = nil slack_obj = nil @@logger.info('Complete.') rescue StandardError => e raise e end |
.post_message(opts = {}) ⇒ Object
- Supported Method Parameters
-
PWN::Plugins::SlackClient.post_message(
slack_obj: 'required slack_obj returned from login method', channel: 'required #channel to post message', message: 'required message to post'
)
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/pwn/plugins/slack_client.rb', line 42 public_class_method def self.(opts = {}) slack_obj = opts[:slack_obj] channel = opts[:channel].to_s.scrub = opts[:message].to_s.scrub slack_obj.chat_postMessage( channel: channel, text: , as_user: true ) slack_obj rescue StandardError => e raise e end |