Compare commits
4 commits
1ad92d9dd3
...
195d0a38ea
Author | SHA1 | Date | |
---|---|---|---|
195d0a38ea | |||
dece | 7964f63513 | ||
dece | 9c077c72fc | ||
dece | 6eaac2c8ea |
|
@ -65,6 +65,9 @@
|
||||||
"sentences": ["you're breathtaking"],
|
"sentences": ["you're breathtaking"],
|
||||||
"calm_rate": 100
|
"calm_rate": 100
|
||||||
},
|
},
|
||||||
|
"doupsland": {
|
||||||
|
"commands": ["doupsland"]
|
||||||
|
},
|
||||||
"horoscope": {
|
"horoscope": {
|
||||||
"commands": ["horoscope"],
|
"commands": ["horoscope"],
|
||||||
"meditation": "/me looks at the stars",
|
"meditation": "/me looks at the stars",
|
||||||
|
@ -144,6 +147,12 @@
|
||||||
"positive": ["I like it."],
|
"positive": ["I like it."],
|
||||||
"negative": ["I don't like it."]
|
"negative": ["I don't like it."]
|
||||||
},
|
},
|
||||||
|
"plus": {
|
||||||
|
"commands": ["plus"],
|
||||||
|
"aliases": {
|
||||||
|
"plus": "more"
|
||||||
|
}
|
||||||
|
},
|
||||||
"randomchoice": {
|
"randomchoice": {
|
||||||
"commands": ["choose"],
|
"commands": ["choose"],
|
||||||
"separator": "or",
|
"separator": "or",
|
||||||
|
|
|
@ -26,9 +26,12 @@ class CapturePlugin(Plugin):
|
||||||
return False
|
return False
|
||||||
if self.current_thing is not None:
|
if self.current_thing is not None:
|
||||||
message = event.arguments[0]
|
message = event.arguments[0]
|
||||||
if message == self.config["capture_sentence"]:
|
capture_sentence = self.config["capture_sentence"]
|
||||||
|
if message == capture_sentence:
|
||||||
self.capture(event.source.nick, event.target)
|
self.capture(event.source.nick, event.target)
|
||||||
return True
|
return True
|
||||||
|
else:
|
||||||
|
self.bot.log_d(f"Capture: “{message}” != “{capture_sentence}”")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
if proc(self.config["rate"]):
|
if proc(self.config["rate"]):
|
||||||
|
|
64
edmond/plugins/doupsland.py
Normal file
64
edmond/plugins/doupsland.py
Normal file
|
@ -0,0 +1,64 @@
|
||||||
|
import random
|
||||||
|
|
||||||
|
from edmond.plugin import Plugin
|
||||||
|
|
||||||
|
|
||||||
|
P_TIME = [
|
||||||
|
"ce matin", "hier soir", "aujourd'hui", "tout à l'heure", "au réveil", "",
|
||||||
|
]
|
||||||
|
P_ACTION = [
|
||||||
|
"j'ai aperçu", "j'ai caressé", "j'ai nadenade", "j'ai passé du temps avec",
|
||||||
|
"je me suis arrêté vers", "je me suis promené avec", "j'ai salué",
|
||||||
|
"j'ai approché", "j'ai suivi", "je me suis assis devant", "j'ai regardé",
|
||||||
|
"j'ai parlé avec",
|
||||||
|
]
|
||||||
|
P_SUBJ = [
|
||||||
|
"le chat", "le chat calico", "le chat noir", "le chaton",
|
||||||
|
"le chat blanc", "le chat tigré", "le chat gris", "le chat avec le cœur",
|
||||||
|
"le chat errant", "le vieux chat", "le gros chat", "le petit chat",
|
||||||
|
"le chat doux", "le beau chat",
|
||||||
|
]
|
||||||
|
P_PLACE = [
|
||||||
|
"en ville", "au port de pêche", "sur l'île", "sous l'arbre",
|
||||||
|
"au monument de pierre", "sur la plage", "sur le chemin", "dans l'herbe",
|
||||||
|
"devant l'école", "dans la petite cour",
|
||||||
|
"qui miaulait", "qui dormait", "qui était devant la boutique",
|
||||||
|
"qui voulait manger", "qui demandait le nadenade",
|
||||||
|
"sur le quai",
|
||||||
|
]
|
||||||
|
P_COORD = [
|
||||||
|
"et", "et donc", "et puis", "après quoi",
|
||||||
|
]
|
||||||
|
P_ACTION2 = [
|
||||||
|
"il a miaulé", "il s'est endormi", "il m'a remercié",
|
||||||
|
"il est resté avec moi",
|
||||||
|
"il m'a suivi", "il a reclamé un nadenade", "il est monté sur le toît",
|
||||||
|
"il s'est roulé en boule",
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def get_title():
|
||||||
|
return " ".join((
|
||||||
|
random.choice(P_TIME),
|
||||||
|
random.choice(P_ACTION),
|
||||||
|
random.choice(P_SUBJ),
|
||||||
|
random.choice(P_PLACE),
|
||||||
|
random.choice(P_COORD),
|
||||||
|
random.choice(P_ACTION2),
|
||||||
|
)).strip().capitalize()
|
||||||
|
|
||||||
|
|
||||||
|
class DoupslandPlugin(Plugin):
|
||||||
|
|
||||||
|
REQUIRED_CONFIGS = ["commands"]
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
super().__init__(bot)
|
||||||
|
|
||||||
|
def on_pubmsg(self, event):
|
||||||
|
if not self.should_handle_command(event.arguments[0]):
|
||||||
|
return False
|
||||||
|
|
||||||
|
reply = get_title()
|
||||||
|
self.bot.say(event.target, reply)
|
||||||
|
return True
|
32
edmond/plugins/plus.py
Normal file
32
edmond/plugins/plus.py
Normal file
|
@ -0,0 +1,32 @@
|
||||||
|
from edmond.plugin import Plugin
|
||||||
|
|
||||||
|
|
||||||
|
class PlusPlugin(Plugin):
|
||||||
|
"""Plugin to store additional content from other plugins.
|
||||||
|
|
||||||
|
This plugin does not do much on its own, it lets other plugins register additional
|
||||||
|
content to compute on the fly when asked, e.g. the Wikipedia plugin can store the
|
||||||
|
Web page of the definition they just gave so users wanting to know more about a
|
||||||
|
definition can use the "plus" function to get the URL to the Web page.
|
||||||
|
|
||||||
|
There can be only one handle registered at one time by target (so by channel, user,
|
||||||
|
etc). External plugins use the `add_handler` to set the current handler for a
|
||||||
|
target.
|
||||||
|
"""
|
||||||
|
|
||||||
|
def __init__(self, bot):
|
||||||
|
super().__init__(bot)
|
||||||
|
self.handlers = {}
|
||||||
|
|
||||||
|
def on_pubmsg(self, event):
|
||||||
|
if not self.should_handle_command(event.arguments[0], no_content=True):
|
||||||
|
return False
|
||||||
|
|
||||||
|
if handler := self.handlers.get(event.target):
|
||||||
|
handler(event)
|
||||||
|
else:
|
||||||
|
self.signal_failure(event.target)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def add_handler(self, target: str, handler):
|
||||||
|
self.handlers[target] = handler
|
|
@ -51,22 +51,30 @@ class WikipediaPlugin(Plugin):
|
||||||
self.bot.say(event.target, summary)
|
self.bot.say(event.target, summary)
|
||||||
|
|
||||||
def tell_definition(self, event):
|
def tell_definition(self, event):
|
||||||
summary = ""
|
page = None
|
||||||
|
reply = ""
|
||||||
retries = self.NUM_RETRIES
|
retries = self.NUM_RETRIES
|
||||||
while retries > 0:
|
while retries > 0:
|
||||||
try:
|
try:
|
||||||
summary = wikipedia.summary(self.command.content, sentences=1)
|
page = wikipedia.page(title=self.command.content)
|
||||||
break
|
break
|
||||||
except wikipedia.exceptions.DisambiguationError:
|
except wikipedia.exceptions.DisambiguationError:
|
||||||
summary = self.config["ambiguous_response"]
|
reply = self.config["ambiguous_response"]
|
||||||
break
|
break
|
||||||
except wikipedia.exceptions.PageError:
|
except wikipedia.exceptions.PageError:
|
||||||
summary = self.config["empty_response"]
|
reply = self.config["empty_response"]
|
||||||
break
|
break
|
||||||
except:
|
except:
|
||||||
summary = self.bot.config["error_message"]
|
reply = self.bot.config["error_message"]
|
||||||
# Keep trying after a slight delay.
|
# Keep trying after a slight delay.
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
retries -= 1
|
retries -= 1
|
||||||
if summary:
|
if page:
|
||||||
self.bot.say(event.target, summary)
|
reply = page.summary.split(". ", maxsplit=1)[0]
|
||||||
|
if len(reply) > 200:
|
||||||
|
reply = reply[:196] + " […]"
|
||||||
|
if plus_plugin := self.bot.get_plugin("plus"):
|
||||||
|
def handler(plus_event):
|
||||||
|
self.bot.say(plus_event.target, page.url)
|
||||||
|
plus_plugin.add_handler(event.target, handler)
|
||||||
|
self.bot.say(event.target, reply)
|
||||||
|
|
Loading…
Reference in a new issue