-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e51f3a1
commit a2f3f64
Showing
6 changed files
with
106 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from .Command import Command | ||
from .strings import random_insult | ||
from .SlackArgumentParser import SlackArgumentParser, SlackArgumentParserException | ||
|
||
from argparse import REMAINDER | ||
|
||
|
||
class ClapCommand(Command): | ||
def __init__(self) -> None: | ||
parser = SlackArgumentParser(prog='kizuna clap', description='obnoxiously clap', add_help=False) | ||
self.add_help_command(parser) | ||
|
||
parser.add_argument('-s', | ||
'--separator', | ||
dest='separator', | ||
default=':clap:', | ||
help='defaults to :clap:') | ||
|
||
parser.add_argument('-a', | ||
'--at', | ||
dest='at', | ||
metavar='PERSON', | ||
help='a user to send this message to') | ||
|
||
parser.add_argument('message', | ||
metavar='MESSAGE', | ||
nargs=REMAINDER, | ||
help='the message to clappify') | ||
|
||
self.set_help_text(parser) | ||
self.parser = parser | ||
super().__init__('clap', 'clap (.*)', help_text=self.help_text, is_at=True) | ||
|
||
def respond(self, slack_client, message, matches): | ||
send = self.send_factory(slack_client, message['channel']) | ||
try: | ||
args = self.parser.parse_args(matches[0].split(' ')) | ||
except SlackArgumentParserException as err: | ||
# lol commented out for max sass | ||
# send(str(err)) | ||
return send(random_insult()) | ||
|
||
if args.help: | ||
return send(self.help_text) | ||
|
||
if not args.message: | ||
return send(random_insult()) | ||
|
||
new_message = ' {} '.format(args.separator).join(args.message) | ||
|
||
if args.at: | ||
new_message = '{} {}'.format(args.at, new_message) | ||
|
||
send(new_message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
from argparse import ArgumentParser | ||
|
||
|
||
class SlackArgumentParserException(Exception): | ||
pass | ||
|
||
|
||
class SlackArgumentParser(ArgumentParser): | ||
def error(self, message): | ||
raise SlackArgumentParserException(message) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,14 @@ | ||
import random | ||
|
||
HAI_DOMO = '\u306F\u3044\u3069\u3082\uFF01\u30AD\u30BA\u30CA\u30FB\u30A2\u30A4\u3067\u3059\uFF01' | ||
KIZUNA = '\u30AD\u30BA\u30CA' | ||
WAIT_A_SEC = '\u3061\u3087\u3063\u3068\u5F85\u3063\u3066\u304F\u3060\u3055\u3044' | ||
JAP_DOT = '\u3002' | ||
AHO = '\u3042\u307B' | ||
BAKA = '\u3070\u304B' | ||
INSULTS = [AHO, BAKA] | ||
|
||
|
||
def random_insult(): | ||
return random.choice(INSULTS) | ||
|