This repository has been archived by the owner on Oct 1, 2022. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
support intents in separated classes
- Loading branch information
Stephan Dilly
committed
Jan 12, 2017
1 parent
ed23d55
commit 188ea1f
Showing
5 changed files
with
116 additions
and
14 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
module ask.baseintent; | ||
|
||
import ask.alexaskill; | ||
import ask.locale; | ||
import ask.types; | ||
|
||
/// | ||
abstract class BaseIntent | ||
{ | ||
/// | ||
immutable string name; | ||
/// | ||
ITextManager texts; | ||
|
||
/// | ||
this() | ||
{ | ||
import std.array:split; | ||
|
||
TypeInfo_Class info = cast(TypeInfo_Class)typeid(this); | ||
auto fullnameParts = info.name.split("."); | ||
this.name = fullnameParts[$-1]; | ||
} | ||
|
||
/// | ||
string getText(int _key) const pure nothrow | ||
{ | ||
return texts.getText(_key); | ||
} | ||
|
||
/// | ||
AlexaResult onIntent(AlexaEvent, AlexaContext); | ||
} | ||
|
||
/// | ||
unittest | ||
{ | ||
class TestIntent : BaseIntent{ | ||
override AlexaResult onIntent(AlexaEvent, AlexaContext){ | ||
AlexaResult res; | ||
res._version = "v3"; | ||
return res; | ||
} | ||
} | ||
|
||
class TestSkill : AlexaSkill!TestSkill{ | ||
this(){ | ||
super([]); | ||
addIntent(new TestIntent); | ||
} | ||
} | ||
|
||
auto skill = new TestSkill(); | ||
AlexaEvent ev; | ||
ev.request.type = AlexaRequest.Type.IntentRequest; | ||
ev.request.intent.name = "TestIntent"; | ||
auto res = skill.executeEvent(ev,AlexaContext()); | ||
assert(res._version == "v3"); | ||
} |
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