Skip to content

Commit

Permalink
Merge pull request #1 from Exirel/choices-spooky
Browse files Browse the repository at this point in the history
8ball: add the spooky magic 8 ball

Thank you @dgw for your review!
  • Loading branch information
Exirel authored Jul 10, 2021
2 parents e95db5a + 5ca44d0 commit 9bd2c01
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 4 deletions.
1 change: 1 addition & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ sopel.plugins =
sopel_8ball.choices =
classic = sopel_8ball.choices:Classic
snarky = sopel_8ball.choices:Snarky
spooky = sopel_8ball.choices:Spooky

[flake8]
max-line-length = 79
Expand Down
40 changes: 37 additions & 3 deletions sopel_8ball/choices.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def configure(self, settings: Config) -> None:
"""

@abc.abstractmethod
def choices(self) -> Tuple[str]:
def choices(self) -> Tuple[str, ...]:
"""Retrieve available choices from this magic 8 ball.
:return: all possible choices for this 8 ball
Expand All @@ -56,7 +56,7 @@ def query(self, destination: Identifier, user: Identifier) -> str:

class Classic(AbstractChoiceProvider):
"""The classic magic 8 ball."""
def choices(self):
def choices(self) -> Tuple[str, ...]:
return (
# affirmative answers
"It is Certain.",
Expand Down Expand Up @@ -89,7 +89,7 @@ def choices(self):

class Snarky(AbstractChoiceProvider):
"""A snarky magic 8 ball."""
def choices(self):
def choices(self) -> Tuple[str, ...]:
return (
# affirmative answers
"What’s the opposite of no?",
Expand Down Expand Up @@ -118,3 +118,37 @@ def choices(self):
"Would you take ‘no’ for an answer?",
"Not in this lifetime!",
)


class Spooky(AbstractChoiceProvider):
"""A spooky magic 8 ball."""
def choices(self) -> Tuple[str, ...]:
return (
# affirmative answers
"The ghost over your shoulder said yes.",
"The accursed screams in agreement.",
"The elders smile from the deep.",
"I've seen this in the dreams of a Great Old One.",
"For once eerie voices whisper in harmony.",

# non-committal answers
"The abyss remains silent.",
"I hear the whispers of a thousand voices "
"but none have your answer.",
"The unfathomable truth cannot be revealed.",
"In the darkness this won't matter anymore.",
"From the depth comes no answer.",

"The spirits are bored of this tune.",
"The answer lies beyond the stars, ineffable.",
"Answers are lost in the midst of black seas of infinity.",
"You shall go mad from the revelation of the truth.",
"I hear your call, yet their shrieking keeps me silent.",

# negative answers
"This would anger the old gods.",
"This will bring sorrow and tears.",
"The elders scowl from the deep.",
"Hidden and fathomless minds pulsate in rage.",
"The underworld grumbles with repudiation.",
)
10 changes: 9 additions & 1 deletion tests/test_choices.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Test ``sopel_8ball.choices``."""
from __future__ import generator_stop

from sopel_8ball.choices import AbstractChoiceProvider, Classic, Snarky
from sopel_8ball.choices import AbstractChoiceProvider, Classic, Snarky, Spooky


def test_abstract_provider():
Expand All @@ -27,3 +27,11 @@ def test_snarky():

assert len(choices) == 20
assert provider.query(None, None) in choices


def test_spooky():
provider = Spooky()
choices = provider.choices()

assert len(choices) == 20
assert provider.query(None, None) in choices
23 changes: 23 additions & 0 deletions tests/test_managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def test_manager_provider_names():
assert managers.manager.provider_names == (
'classic',
'snarky',
"spooky",
)


Expand Down Expand Up @@ -68,3 +69,25 @@ def test_manager_setup_snarky(configfactory, botfactory):
manager.setup(mockbot)

assert isinstance(manager.provider, choices.Snarky)


TMP_CONFIG_SPOOKY = """
[core]
owner = testnick
nick = TestBot
enable = coretasks, 8ball
[magic8ball]
choices = spooky
"""


def test_manager_setup_spooky(configfactory, botfactory):
manager = managers.Manager()
tmpconfig = configfactory('test.cfg', TMP_CONFIG_SPOOKY)
mockbot = botfactory(tmpconfig)

tmpconfig.define_section('magic8ball', config.Magic8ballSection)
manager.setup(mockbot)

assert isinstance(manager.provider, choices.Spooky)

0 comments on commit 9bd2c01

Please sign in to comment.