示例#1
0
def delete_bot(bot_id):
    """Delete an bot object"""
    bot = BotModel.get_by_id(bot_id)
    try:
        bot.delete()
        flash(u'Bot %s successfully deleted.' % bot.bot_username, 'success')
        return redirect(url_for('list_bots'))
    except CapabilityDisabledError:
        flash(u'App Engine Datastore is currently in read-only mode.', 'info')
        return redirect(url_for('list_bots'))
示例#2
0
def list_bots():
    """List all bots"""
    bots = BotModel.all()
    form = BotForm()
    if form.validate_on_submit():
        keywords = form.keywords.data.split(',')
        bot = BotModel(
            bot_username=form.bot_username.data,
            consumer_key=form.consumer_key.data,
            consumer_secret=form.consumer_secret.data,
            access_token=form.access_token.data,
            access_token_secret=form.access_token_secret.data,
            keywords=keywords
        )
        try:
            bot.put()
            bot_id = bot.key().id()
            flash(u'Bot %s successfully saved.' % bot.bot_username, 'success')
            return redirect(url_for('list_bots'))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('list_bots'))
    return render_template('list_bots.html', bots=bots, form=form)