Class: Waylon::Skills::Default

Inherits:
Waylon::Skill show all
Defined in:
lib/waylon/skills/default.rb

Overview

The default skill for Waylon, mostly for fallback actions like permissions issues

Instance Attribute Summary

Attributes inherited from Waylon::Skill

#request, #route, #sense, #tokens

Instance Method Summary collapse

Methods inherited from Waylon::Skill

#acknowledgement, #codify, config_namespace, #details, #initialize, #mention, #message, #named_tokens, perform, queue, #react, #reply, #reply_with_blocks, route, #threaded_reply

Methods included from BaseComponent

included

Constructor Details

This class inherits a constructor from Waylon::Skill

Instance Method Details

#deniedObject

This action is performed when a User tries to run something they aren’t allowed to



8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/waylon/skills/default.rb', line 8

def denied
  log("Denied '#{tokens.first}' from #{message.author.email}")
  prefix = message.private_message? ? "" : "#{mention(message.author)},"

  react :lock

  responses = [
    "I can't do that. You'll need an admin adjust your permissions.",
    "I know what you'd like to do, but you don't have permission for that.",
    "You don't have permission to do that."
  ]

  reply("#{prefix} #{responses.sample} #{help_postfix}")
end

#help_postfixString

A useful addition to message to tell the User how to get help

Returns:

  • (String)


30
31
32
# File 'lib/waylon/skills/default.rb', line 30

def help_postfix
  "Use `help` to see what you're allowed to do."
end

#ignoreObject

This action ignores messages



24
25
26
# File 'lib/waylon/skills/default.rb', line 24

def ignore
  log("Ignoring black-holed message from #{message.author.email}")
end

#unknownObject

This is run for unroutable messages (meaning no Skill has claimed them)



35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/waylon/skills/default.rb', line 35

def unknown
  log("Unroutable message '#{tokens.first}' from #{message.author.email}")

  prefix = message.private_message? ? "" : "#{mention(message.author)},"

  react :shrug

  responses = [
    "Sorry, I'm not sure what you mean by that.",
    "I don't have the ability to handle that request, but PRs are welcome!",
    "I don't know what that means.",
    "My AI and NLP is only so good... Maybe try rephrasing that request?"
  ]

  reply("#{prefix} #{responses.sample} #{help_postfix}")
end