-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #130 from LanceMaverick/getargsdecorators
⚠️ All decorators now use factory pattern
- Loading branch information
Showing
28 changed files
with
315 additions
and
128 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
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
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
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 @@ | ||
A beard named askfor for skybeard-2. |
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,36 @@ | ||
from skybeard.beards import BeardChatHandler | ||
from skybeard.decorators import onerror, askfor, getargsorask, getargs | ||
|
||
|
||
class Askfor(BeardChatHandler): | ||
|
||
__userhelp__ = """Default help message.""" | ||
|
||
__commands__ = [ | ||
# command, callback coro, help text | ||
("getargs", 'get_args', 'Gets two arguments and sends then back.'), | ||
("askforstuff", 'ask_for_stuff', 'Asks for two arguments and echos them back.'), | ||
("optionalargsdemo", 'optional_args_demo', 'Asks for arguments if not provided (2 args.)'), | ||
] | ||
|
||
# __init__ is implicit | ||
|
||
@onerror() | ||
@getargs() | ||
async def get_args(self, msg, var_x, var_y): | ||
await self.sender.sendMessage("1) {}\n2) {}".format( | ||
var_x, var_y)) | ||
|
||
@onerror() | ||
@askfor([('var_x', "What's your first variable?"), | ||
('var_y', "What's your second variable?")]) | ||
async def ask_for_stuff(self, msg, var_x, var_y): | ||
await self.sender.sendMessage("1) {}\n2) {}".format( | ||
var_x, var_y)) | ||
|
||
@onerror() | ||
@getargsorask([('var_x', "What's your first variable?"), | ||
('var_y', "What's your second variable?")]) | ||
async def optional_args_demo(self, msg, var_x, var_y): | ||
await self.sender.sendMessage("1) {}\n2) {}".format( | ||
var_x, var_y)) |
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,5 @@ | ||
from skybeard.utils import setup_beard | ||
|
||
setup_beard( | ||
"askfor", | ||
) |
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 @@ | ||
A beard named debugonlyexample for skybeard-2. |
20 changes: 20 additions & 0 deletions
20
examples/debugonlyexample/python/debugonlyexample/__init__.py
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,20 @@ | ||
from skybeard.beards import BeardChatHandler | ||
from skybeard.decorators import onerror, debugonly | ||
|
||
|
||
class DebugOnlyExample(BeardChatHandler): | ||
|
||
__userhelp__ = """Default help message.""" | ||
|
||
__commands__ = [ | ||
("debugonlytest", 'debug_only_test', | ||
'Tests if skybeard is in debug mode.') | ||
] | ||
|
||
# __init__ is implicit | ||
|
||
@onerror() | ||
@debugonly("Skybeard is not in debug mode.") | ||
async def debug_only_test(self, msg): | ||
# This message will only be sent if skybeard is run in debug mode | ||
await self.sender.sendMessage("You are in debug mode!") |
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,5 @@ | ||
from skybeard.utils import setup_beard | ||
|
||
setup_beard( | ||
"debugonlyexample", | ||
) |
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
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
from .admin import admin | ||
from .onerror import onerror | ||
from .getargs import getargs | ||
from .askfor import askfor | ||
from .getargsorask import getargsorask | ||
from .debugonly import debugonly |
Oops, something went wrong.