예제 #1
0
    def post(self):
        """Creates a bot"""
        error_status = 0
        user = users.get_current_user()
        if not user:
            self.response.out.write("not registered in google")
        name = self.request.get('name')
        password = self.request.get('password')
        feed = self.request.get('feed')

        # Verify the account information
        gae_twitter = GAETwitter(username=name, password=password)
        verify_result = gae_twitter.verify()
        if (verify_result != True):
            error_status = error_status + 1

        # Verify the feed URL
        d = feedparser.parse(feed)

        if (d.bozo > 0):
            error_status = error_status + 2
        server_error = ""
        if (error_status == 0):
            bot = Bot(name=name, password=password, feed=feed)
            bot.user = user
            try:
                bot.put()
            except Exception, e:
                error_status |=  4
                server_error = str(e)
예제 #2
0
파일: __init__.py 프로젝트: motord/banter
def populate():
    q=Channel.gql("WHERE id=:1", 'koan')
    channel=q.get()
    code="""
__author__ = 'peter'

from application import settings
import logging

MSG_TYPE_TEXT = u'text'
MSG_TYPE_LOCATION = u'location'
MSG_TYPE_IMAGE = u'image'

def process_text(remark, retort):
    if remark['content']:
        retort['content']='Bot Spawned!'
        retort['msgType']=MSG_TYPE_TEXT
        retort['funcFlag']=0
    return retort

def process_location(remark, retort):
    return retort

def process_image(remark, retort):
    return retort
    """
    bot=Bot(name=u'spawn', code=code, channel=channel.key)
    bot.put()
    return 'populated.'
예제 #3
0
파일: __init__.py 프로젝트: motord/banter
def create_bot(channel):
    form = BotForm()
    if form.validate_on_submit():
        bot = Bot(
            name = form.name.data,
            activated = form.activated.data,
            code = form.code.data,
            channel = channel.key
        )
        try:
            bot.put()
            flash(u'Bot %s successfully saved.' % bot.name, 'success')
            return redirect(url_for('qq.edit_bot', channel=channel.id, bot=bot.name))
        except CapabilityDisabledError:
            flash(u'App Engine Datastore is currently in read-only mode.', 'info')
            return redirect(url_for('qq.list_bots', channel=channel.id))
    return render_template("new_bot.html", channel=channel, form=form)