diff --git a/README.md b/README.md index 4d0b940..357c31d 100644 --- a/README.md +++ b/README.md @@ -12,13 +12,13 @@ productive fellow. - Ping (returns Pong!; good for testing connectivity) - Dice Roller (`!roll 2d4` -> `Roll: 2d4 ([2, 1]) ==> 3`) +- 8-ball (`!8ball Will I win the lottery?` --> `Try again later`) - More to come! ## Planned Features - [ ] Ad-hoc simple custom commands (`!addcommand hello Hey there!` --> `!hello` --> `Hey there!`) -- [ ] 8-ball (`!8ball Will I win the lottery?` --> `Try again later`) - [ ] Simple calculator (`!calc 8 + (9-10)` --> `Calc: 8 + (9 - 10) ==> 7`) - [ ] Simple games (Blackjack, High/Low) - [ ] A "mystery" game (Kind of like _Clue!_ or _Noir Syndrome_) @@ -40,6 +40,7 @@ You can run your own instance of Chronicle with a few steps: 5. Run `bundle exec chronicle -d CHRONICLE_ACCESS_TOKEN` 6. Invite the bot user to a room, and `!ping` to make sure it's working! +7. Update the `allowed_commands` variable to add additional commands (for now). # Contribute diff --git a/lib/addons/utils.rb b/lib/addons/utils.rb index 79660a6..e788d41 100644 --- a/lib/addons/utils.rb +++ b/lib/addons/utils.rb @@ -8,8 +8,49 @@ module Chronicle # @param message [Message object] The relevant message object def handle_ping(client, message) room = client.ensure_room message.room_id - + room.send_notice('Pong!') end + + # 8-Ball: Give a random, vague response to a question + # + # @param client [Client object] The current Matrix client connection + # @param message [Message object] The relevant message object + def handle_8ball(client, message) + msgstr = message.content[:body] + .gsub(/!8ball\s*/, '') + .strip + + room = 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 end end