2021-02-07 03:23:51 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
module Chronicle
|
2021-02-15 02:06:46 +00:00
|
|
|
module Addon
|
2021-02-07 03:23:51 +00:00
|
|
|
# Ping - Pong. Useful for testing
|
2021-02-15 02:06:46 +00:00
|
|
|
class Ping
|
|
|
|
def self.register(bot)
|
|
|
|
addon_instance = new(bot)
|
|
|
|
addon_command = ['ping']
|
2021-02-08 01:45:54 +00:00
|
|
|
|
2021-02-15 02:06:46 +00:00
|
|
|
[addon_instance, addon_command]
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(bot)
|
|
|
|
@bot = bot
|
|
|
|
end
|
|
|
|
|
2021-02-15 03:37:56 +00:00
|
|
|
# Provide help information for this command
|
|
|
|
#
|
2021-02-17 04:13:46 +00:00
|
|
|
# @param message [Message object] The relevant message object (Unused)
|
|
|
|
def help_command(_)
|
|
|
|
'Returns "Pong!"' \
|
|
|
|
"\nUsage: !ping"
|
2021-02-15 03:37:56 +00:00
|
|
|
end
|
|
|
|
|
2021-02-15 02:06:46 +00:00
|
|
|
# Handle a command from the Matrix protocol
|
|
|
|
#
|
|
|
|
# @param message [Message object] The relevant message object
|
|
|
|
def matrix_command(message)
|
|
|
|
room = @bot.client.ensure_room(message.room_id)
|
|
|
|
|
|
|
|
room.send_notice('Pong!')
|
|
|
|
end
|
2021-02-07 03:23:51 +00:00
|
|
|
end
|
2021-02-08 01:45:54 +00:00
|
|
|
|
|
|
|
# 8-Ball: Give a random, vague response to a question
|
2021-02-15 02:06:46 +00:00
|
|
|
class Eightball
|
|
|
|
def self.register(bot)
|
|
|
|
addon_instance = new(bot)
|
|
|
|
addon_command = ['8ball']
|
|
|
|
|
|
|
|
[addon_instance, addon_command]
|
|
|
|
end
|
|
|
|
|
|
|
|
def initialize(bot)
|
|
|
|
@bot = bot
|
|
|
|
end
|
|
|
|
|
2021-02-15 03:37:56 +00:00
|
|
|
# Provide help information for this command
|
|
|
|
#
|
2021-02-17 04:13:46 +00:00
|
|
|
# @param message [Message object] The relevant message object (Unused)
|
|
|
|
def help_command(_)
|
|
|
|
'Questions the fates to determine an answer for your question.' \
|
|
|
|
"\nUsage: !8ball QUESTION"
|
2021-02-15 03:37:56 +00:00
|
|
|
end
|
|
|
|
|
2021-02-15 02:06:46 +00:00
|
|
|
# Handle a command from the Matrix protocol
|
|
|
|
#
|
|
|
|
# @param message [Message object] The relevant message object
|
|
|
|
def matrix_command(message)
|
|
|
|
msgstr = message.content[:body]
|
|
|
|
.gsub(/!8ball\s*/, '')
|
|
|
|
.strip
|
|
|
|
|
|
|
|
room = @bot.client.ensure_room(message.room_id)
|
|
|
|
|
|
|
|
fates = [
|
|
|
|
'Resoundingly, yes.',
|
|
|
|
'Chances are good.',
|
|
|
|
'Signs point to yes.',
|
|
|
|
'Wheel.',
|
|
|
|
'It is worth the attempt.',
|
|
|
|
'Uncertainty clouds my sight.',
|
|
|
|
'Wheel and woe.',
|
|
|
|
'Neither wheel nor woe.',
|
|
|
|
'Concentrate, and ask again.',
|
|
|
|
'I cannot say for sure.',
|
|
|
|
'The fates do not know.',
|
|
|
|
"Why are you asking me? I'm just a bot.",
|
|
|
|
'Error: Fate API returned 404. Try again later.',
|
|
|
|
'Woe.',
|
|
|
|
'Chances are poor.',
|
|
|
|
'Signs point to no.',
|
|
|
|
'Very doubtful.',
|
|
|
|
'Absolutely no.'
|
|
|
|
]
|
|
|
|
|
|
|
|
res = if msgstr[-1] == '?'
|
|
|
|
fates.sample
|
|
|
|
else
|
|
|
|
'You must ask a question. Try again'
|
|
|
|
end
|
|
|
|
|
|
|
|
room.send_notice(res)
|
|
|
|
end
|
2021-02-08 01:45:54 +00:00
|
|
|
end
|
2021-02-07 03:23:51 +00:00
|
|
|
end
|
|
|
|
end
|