示例#1
0
# coding: utf-8

from bernard.engine import Tr, triggers as trg
from bernard.i18n import intents as its

from src.did_rocket_launch_yet.states import (Welcome, FirstFrame,
                                              RocketLaunched,
                                              RocketNotLaunched, LauchFound)
from src.did_rocket_launch_yet.triggers import Afirmation

transitions = [
    Tr(
        dest=Welcome,
        factory=trg.Text.builder(its.HELLO),
    ),
    Tr(
        dest=FirstFrame,
        origin=Welcome,
        factory=trg.Text.builder(its.START),
    ),
    Tr(
        dest=RocketNotLaunched,
        origin=FirstFrame,
        factory=Afirmation.builder(its.NO, is_found=False),
    ),
    Tr(
        dest=RocketNotLaunched,
        origin=RocketNotLaunched,
        factory=Afirmation.builder(its.NO, is_found=False),
    ),
    Tr(
# coding: utf-8
from bernard import (
    layers as lyr, )
from bernard.engine import (
    Tr,
    triggers as trg,
)
from bernard.platforms.telegram.layers import (BotCommand)

from .states import *
from .triggers import *

transitions = [
    Tr(
        dest=S001xWelcome,
        factory=trg.Equal.builder(BotCommand('/start')),
    ),
    Tr(
        dest=S002xDidTheRocketLaunchYetInitial,
        origin=S001xWelcome,
        factory=trg.Equal.builder(lyr.Postback('yes')),
    ),
    Tr(
        dest=S005xGoodbye,
        origin=S001xWelcome,
        factory=trg.Equal.builder(lyr.Postback('no')),
    ),
    Tr(
        dest=S003xDidTheRocketLaunchYetAgain,
        origin=S002xDidTheRocketLaunchYetInitial,
        factory=Bisection.builder(is_found=False),
示例#3
0
    Tr,
    triggers as trg,
)
from bernard.i18n import (
    intents as its, )

from .states import *
from .states import F001xStartCheckFrame
from .states import F002xRepeatCheckFrame
from .triggers import IsNumber, NumberGameTrigger, EqualStringTrigger
from .triggers import BisectFrameTrigger2
from .triggers import ListAppenderTrigger

transitions = [
    Tr(
        dest=Hello,
        factory=trg.Text.builder(its.HELLO),
    ),

    # start guessing at frames
    Tr(dest=F001xStartCheckFrame,
       factory=EqualStringTrigger.builder(string="begin")),

    # enter iteration of repeating frame questions
    Tr(dest=F002xRepeatCheckFrame,
       origin=F001xStartCheckFrame,
       factory=ListAppenderTrigger.builder()),

    # remain inside repeating frame questions
    Tr(dest=F002xRepeatCheckFrame,
       origin=F002xRepeatCheckFrame,
       factory=ListAppenderTrigger.builder())
# coding: utf-8

from bernard.engine import (
    Tr,
    triggers as trg,
)
from bernard.platforms.telegram.layers import BotCommand

from .states import StartState, PlayState, ReTryState
from .states.no_play import NoPlayState
from .states.win import WinState
from .trigger import GameTrigger

transitions = [
    Tr(
        dest=StartState,
        factory=trg.Equal.builder(BotCommand('/start')),
    ),
    Tr(
        dest=NoPlayState,
        factory=trg.Action.builder('no_play')
    ),
    Tr(
        dest=PlayState,
        factory=trg.Action.builder('play')
    ),
    Tr(
        dest=ReTryState,
        origin=PlayState,
        factory=GameTrigger.builder(is_win=False)
    ),
    Tr(
示例#5
0
from bernard.engine import (
    Tr,
    triggers as trg,
)
from bernard.platforms.telegram.layers import (
    BotCommand, )
from bernard.i18n import (
    intents as its, )

from .states import *
from .triggers import *

transitions = [
    Tr(
        dest=S000xInitial,
        factory=CustomText.builder(its.WELCOME),
    ),
    Tr(
        dest=S000xInitial,
        factory=trg.Equal.builder(BotCommand('/start')),
    ),
    Tr(
        origin=S000xInitial,
        dest=S000xInitial,
        factory=Loop.builder(when='no'),
    ),
    Tr(
        origin=S000xInitial,
        dest=S001xPrelude,
        factory=CustomChoice.builder('yes'),
    ),
示例#6
0
# coding: utf-8

from bernard.engine import (
    Tr,
    triggers,
)
from bernard.i18n import (
    intents, )

from .states import (
    Great,
    Hello,
    HowAreYou,
    TooBad,
)

# noinspection PyTypeChecker
transitions = [
    Tr(Hello, triggers.Text.builder(intents.HELLO)),
    Tr(HowAreYou, triggers.Anything.builder(), Hello, internal=True),
    Tr(Great, triggers.Choice.builder(when='yes'), HowAreYou),
    Tr(TooBad, triggers.Choice.builder(when='no'), HowAreYou),
]
示例#7
0
# coding: utf-8

from bernard.engine import (
    Tr,
    triggers as trg,
)
from bernard.platforms.telegram.layers import BotCommand

from .states import *
from .triggers import *

transitions = [
    Tr(
        dest=F001xWelcome,
        factory=trg.Equal.builder(BotCommand('/start')),
    ),
    Tr(
        dest=F002xGuess,
        origin=F001xWelcome,
        factory=trg.Action.builder('guess'),
    ),
    Tr(
        dest=E001xInitialize,
        origin=F001xWelcome,
        factory=trg.Action.builder('ok'),
    ),
    Tr(
        dest=F002xGuess,
        origin=E001xInitialize,
        factory=trg.Action.builder('guess'),
    ),
示例#8
0
from bernard.engine import (
    Tr,
    triggers as trg,
)
from bernard.i18n import (
    intents as its, )

from .states import *
from .triggers import *

from bernard.platforms.telegram.layers import (BotCommand)

transitions = [
    Tr(
        dest=S001xStart,
        factory=trg.Equal.builder(BotCommand('/start')),
    ),
    Tr(
        dest=S002xFirstLaunchingFrame,
        factory=trg.Equal.builder(BotCommand('/play')),
    ),
    Tr(
        dest=S003xIsRocketLaunchedInFrame,
        origin=S002xFirstLaunchingFrame,
        factory=Frame.builder(is_search_finished=False),
    ),
    Tr(
        dest=S003xIsRocketLaunchedInFrame,
        origin=S003xIsRocketLaunchedInFrame,
        factory=Frame.builder(is_search_finished=False),
    ),
示例#9
0
# coding: utf-8

from bernard.engine import (
    Tr,
    triggers as trg,
)
from bernard.i18n import (
    intents as its, )

from .states import *
from .triggers import *

transitions = [
    Tr(
        dest=S001xWelcome,
        factory=trg.Action.builder('get_started'),
    ),
    Tr(
        dest=S002xGuessANumber,
        factory=trg.Action.builder('guess'),
    ),
    Tr(
        dest=S002xGuessANumber,
        origin=S001xWelcome,
        factory=trg.Choice.builder('play'),
    ),
    Tr(
        dest=S003xGuessAgain,
        origin=S002xGuessANumber,
        factory=Number.builder(is_right=False),
    ),
示例#10
0
# coding: utf-8

from bernard.engine import (
    Tr,
    triggers as trg,
)
from bernard.i18n import (
    intents as its,
)

from .states import *

transitions = [
    Tr(
        dest=Hello,
        factory=trg.Text.builder(its.HELLO),
    ),
]
示例#11
0
# coding: utf-8

from bernard.engine import Tr, triggers
from bernard.i18n import intents
from .states import Hello, Great, TooBad

# noinspection PyTypeChecker
transitions = [
    Tr(Hello, triggers.Text.builder(intents.HELLO)),
    Tr(Great, triggers.Choice.builder(when='yes'), Hello),
    Tr(TooBad, triggers.Choice.builder(when='no'), Hello),
]
示例#12
0
# coding: utf-8

from bernard.engine import (
    Tr,
    triggers as trg,
)

from bernard.platforms.telegram import layers

from .state import S001xWelcome, S002xGuessANumber, S003xGuessAgain, S004xCongrats
from .trigger import Number

transitions = [
    Tr(
        dest=S001xWelcome,
        factory=trg.Equal.builder(layers.BotCommand('/start')),
    ),
    Tr(
        dest=S002xGuessANumber,
        origin=S001xWelcome,
        factory=trg.Action.builder('play'),
    ),
    Tr(
        dest=S003xGuessAgain,
        origin=S002xGuessANumber,
        factory=Number.builder(is_right=False),
    ),
    Tr(
        dest=S003xGuessAgain,
        origin=S003xGuessAgain,
        factory=Number.builder(is_right=False),
示例#13
0
)
from bernard.i18n import (
    intents as its,
)

from bernard.platforms.telegram import (
    layers as tl,
)

from .states import *
from .trigger import RocketLaunched

transitions = [
    # Entry point for the /start command
    Tr(
        dest=Welcome,
        factory=trg.Equal.builder(tl.BotCommand('/start')),
    ),
    # The user starts guessing
    Tr(
        dest=Guess,
        origin=Welcome,
        factory=trg.Action.builder('start'),
    ),
    # The user decides not to play
    Tr(
        dest=Quit,
        origin=Welcome,
        factory=trg.Action.builder('no_start'),
    ),
    # After the guessing first step, it goes to Check_again
    Tr(