Module: Qywx::Client::GroupRobotClient::NotifyText

Included in:
Qywx::Client::GroupRobotClient
Defined in:
lib/qywx/client/group_robot_client/notify_text.rb

Instance Method Summary collapse

Instance Method Details

#notify_text(code, content, **options) ⇒ Object

Parameters:

  • code (Symbol)

    set token_code and template_file

  • content (String)
  • options (Hash)

    a customizable set of options

Options Hash (**options):

  • template_file (String) — default: code

    without file suffix

  • at_users (Array) — default: ["wangqing", "@all"]
  • at_mobiles (Array) — default: ["13800001111", "@all"]


12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/qywx/client/group_robot_client/notify_text.rb', line 12

def notify_text(code, content, **options)
  options.with_defaults!(
    at_users: [],
    at_mobiles: []
  )
  token_code = code.to_sym
  token = fetch_token(token_code)
  content = String(content)
  at_users = Array(options[:at_users]).presence
  at_mobiles = Array(options[:at_mobiles]).presence
  body = get_text_body(content, at_users, at_mobiles)
  notify(token, body)
end