Example #1
0
            },
            {
                'Remind me in 5 min': a(States.NOT_IMPLEMENTED)
            },
        ],
        'prepare':
        parse_notif
    },
    States.NOTIF_POMO: {
        't':
        ps(lambda s, **d: d.get('NotifText')),
        'b': [
            {
                'Stop': a(stop_pomodoro, update_msg=False)
            },
            {
                'Delay for 2 min': a(States.NOT_IMPLEMENTED)
            },
        ],
        'prepare':
        parse_notif
    },
    States.POMODORO: {
        't': h.st("WORKING on %s :)", 'GoalName'),
        'b': [{
            'Stop': a(stop_pomodoro, update_msg=False)
        }],
    }
}
print(inspect.getargspec(start_pomodoro))
Example #2
0
            {'Start activity':a(States.ACTIVITY,update_msg=False)},
            {'View Stats':a(States.NOT_IMPLEMENTED)},
            {'Add new goal':a(States.NOT_IMPLEMENTED)},
            ],
        #'kb_txt':"Welcome!",
        #'kb':h.obj(home_kb)
      },
    States.START:{
        't':'Notification polling started',
        'b':[
            { 'to home':tgf.action(States.HOME)}
        ],
        'prepare':start_notifications_longpoll
    },
    States.ACTIVITY:{
        't':"Here are your Goals",
        'b':[
            ps(lambda s,**d: d.get('GoalButtons')),
            {}
        ],
        'prepare':get_activities
    },
    States.GOAL:{
        't':h.st("You are about to work on Goal %s",'GoalName'),
        'b':[
            {'Start pomodoro':a(start_pomodoro)}
        ]
        }
}
 
Example #3
0
            # This h.post will return an array of buttons

            # tgflow will automatically add the persistent button to
            # ones that are returned by h.post!
        ]
    },
    States.MODIFY_BUT: {
        't': 'Send me the name of button',
        'b': [{
            'cancel': tgf.action(States.START)
        }],
        # now every time user sends us some text, upd_kb will be called
        'react': h.action(upd_kb, react_to='text'),
    },
    States.THANKS: {
        't': h.st('Youve modified, new name is %s', 'upd_id'),
        'b': [
            {
                'back to start': tgf.action(States.START)
            },
        ],
        # this is to stop triggering the previously defibed actiion for upd_kb
        'clear_trig': 'text'
    },
}

tgf.configure(
    token=key,
    state=States.START,
)
tgf.start(UI)
Example #4
0
from tgflow.coffee_ui import CoffeeUI

ps = h.post
a = h.action


def set_name(i, s, **d):
    d['name'] = i.from_user.first_name
    return d


UI = {
    States.START: {
        't':
        h.st(("Hey %s, nice to meet you! "
              "I'm a GoalNet bot!"
              "What would you like to do?"), 'name'),
        'b': [{
            'Log in': a(States.TG)
        }, {
            'Explore GoalNet': a(States.NOT_IMPLEMENTED)
        }, {
            'Register': a(States.NOT_IMPLEMENTED)
        }],
        'prepare':
        set_name,
    },
    States.CONTACT: {
        't': ("Tell me what's on your mind, and I'll pass it over to"
              "the rest of GoalNet team. We'll get back to you shortly"),
        'b': [{
Example #5
0
     }, {
         'set my favourite': h.action(States.FAV)
     }]
 },
 States.INFO: {
     't':
     'Please send me name of your favourite thing',
     'b': [{
         'set foo': (lambda input, data: (States.THANKS, {
             'foo': 'var' + data['foo']
         }))
     }]
 },
 States.FAV: {
     't':
     h.st('Your fav is %s', 'fav'),
     'react':
     h.action(lambda i: (States.THANKS, {
         'fav': i.text
     }), react_to='text'),
 },
 States.THANKS: {
     't':
     h.st('Thanks! I will remember it foo %s', 'foo'),
     'b': [{
         'show info': h.action(States.INFO, update_msg=True)
     }, {
         'set another favourite': h.action(States.FAV, update_msg=True)
     }],
     'clear_trig':
     'text'
Example #6
0
 States.FAV: {
     't':
     'Please send me name of your favourite thing',
     'b': [{
         'my favourite is star': (lambda input, data: (States.THANKS, {
             'fav': 'star'
         }))
     }],
     'react':
     h.action(lambda i: (States.THANKS, {
         'fav': i.text
     }), react_to='text'),
 },
 States.INFO: {
     't':
     h.st('Your fav is %s', 'fav'),
     'b': [{
         'back to start': tgf.action(States.START)
     }, {
         'overwrite favourite': h.action(States.FAV)
     }]
 },
 States.THANKS: {
     't':
     h.st('Thanks! I will remember your %s', 'fav'),
     'b': [{
         'show info': h.action(States.INFO, update_msg=True)
     }, {
         'set another favourite': h.action(States.FAV, update_msg=True)
     }],
     'clear_trig':
Example #7
0
            {
                'back to start': tgf.action(States.START)
            },
        ]
    },
    States.VOICE: {
        't': 'Record a message and i will send a link',
        'b': [
            {
                'back to start': tgf.action(States.START)
            },
        ],
        'react': tgf.action(get_voice_link, react_to='all')
    },
    States.LINK: {
        't': h.st('here\'s your link: %s', 'link'),
        'b': [
            {
                'back to start': tgf.action(States.START)
            },
        ]
    },
}
tgf.configure(token=key,
              state=States.START,
              apiModel=vkAPI,
              data={"foo": 'bar'},
              group_id=group)
tgf.start(ui)
"""
UI = {
Example #8
0
    return new_state, d


login_kb = [{
    'Send contact': a(contact_check, react_to='contact'),
    'kwargs': {
        'request_contact': True
    }
}, {
    '<- Back': a(States.START)
}]

UI = {
    States.TG: {
        't':
        h.st(("%s, Please share your contact details"
              "so I can recognize you"), 'name'),
        'kb':
        h.obj(login_kb)
    },
    States.TG_ERR: {
        't':
        h.st(("%s, I'm afraid this is not your contact. "
              "Please share your contact"), 'name'),
        'kb':
        h.obj(login_kb)
    },
    States.NOT_REG: {
        't': ("It seems that you are "
              "not currently registered in GoalNet."
              "Would you like to register now?"
              "Or contact GoalNet if you think "
Example #9
0
     't': 'Hi! You can set up a reminder here.',
     'kb': [
         {
             'Set up a reminder': tgf.action(States.REMIND)
         },
     ]
 },
 States.REMIND: {
     't': 'Please send me a delay in seconds:',
     'b': [{
         'Back': tgf.action(States.START)
     }],
     'react': h.action(handle_delay, react_to='text'),
 },
 States.SET: {
     't': h.st('Delay is %s', 'delay'),
     'b': [
         {
             'back to start': tgf.action(States.START)
         },
     ],
     'clear_trig': 'text',
 },
 States.NOTIF: {
     't': h.st('Hey! time\'s up! delay was: %s', 'delay'),
     'b': [
         {
             'back to start': tgf.action(States.START)
         },
     ],
     'clear_trig': 'text'