Skip to content

Commit

Permalink
Help and Announce Improvements (#13)
Browse files Browse the repository at this point in the history
* Improved help commands
* Announcements.py has some (inactive) examples
* UNSURE replies now append specific help instructions for Slack in that backend's IO
  • Loading branch information
Chalta committed Jul 20, 2018
1 parent 5782110 commit 24f60ce
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 6 deletions.
18 changes: 17 additions & 1 deletion plugins/pco/announcements.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
from will.plugin import WillPlugin
from will.decorators import respond_to, periodic, hear, randomly, route, rendered_template, require_settings
from plugins.pco import birthday, address, phone_numbers, checkins, msg_attachment, authenticate
from plugins.pco import birthday, address, phone_numbers, checkins, msg_attachment, authenticate, pcoservices


class SchedulePlugin(WillPlugin):
# @hear("announce")
def announce_banana(self, message, channel="general"):
self.say("announcing in: %s" % channel, channel=channel)
AnnouncementPlugin.banana(self, message, channel=channel)


class AnnouncementPlugin(WillPlugin):
# @periodic(hour='14', minute='10') # at a certain time
# @periodic(second=0) # every minute at 0 seconds
def announcetime(self):
self.say("Announcement!", channel="general")

# @hear("banana")
def banana(self, message, channel=None):
self.say("Bananaaaaa! %s" % channel, channel=channel)

# @hear("this channel")
def this_channel(self, message, channel=None):
self.say("This channel's name is %s" % self.message.data.channel.name, channel=channel)
self.say("This channel's id is %s" % self.message.data.channel.id, channel=channel)
1 change: 0 additions & 1 deletion plugins/pco/pcoservices.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def pco_song_lookup(self, message, pco_song):
self.reply("Sorry I don't find " + song + "in services.")
self.reply("", message=message, attachments=attachment)


# Test your setup by running this file.
# If you add functions in this file please add a test below.

Expand Down
3 changes: 2 additions & 1 deletion will/backends/io_adapters/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,8 @@ def handle_outgoing_event(self, event):
event.data.is_direct and
event.data.will_said_it is False
):
event.content = random.choice(UNSURE_REPLIES)
self.people # get the object that contains bot's handle
event.content = random.choice(UNSURE_REPLIES) + " Try `@%s help`" % self.me.handle
self.send_message(event)

def handle_request(self, r, data):
Expand Down
9 changes: 9 additions & 0 deletions will/plugins/help/help.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,15 @@
from will.decorators import respond_to, periodic, hear, randomly, route, rendered_template, require_settings


class PublicHelpPlugin(WillPlugin):

# If a user posts the single word `help` in chat, we'll help them.
@hear("help")
def public_help(self, message):
HelpPlugin.help(self, message, plugin=None)
self.say("And remember %s, I'll always respond when you message me directly!" % message.sender.first_name, color="yellow")


class HelpPlugin(WillPlugin):

@respond_to("^help(?: (?P<plugin>.*))?$")
Expand Down
6 changes: 3 additions & 3 deletions will/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@


UNSURE_REPLIES = [
"Hmm. I'm not sure what to say.)",
"I didn't understand that. Message me directly with the word *help* to see what I can do.",
"I heard you, but I'm not sure what to do. Direct message me *help* to see my commands.",
"Hmm. I'm not sure what to say.",
"I didn't understand that.",
"I heard you, but I'm not sure what to do.",
"I'm not sure what that means.",
]

Expand Down

0 comments on commit 24f60ce

Please sign in to comment.