Exemplo n.º 1
0
  def start_command(self, message=None):
    """process /start command"""
    # add to database and reply
    user,trigger,desc=parse_user_command(message)
    stats=Statistics.all().get()
    stats.chats+=1;
    #total number of allowed rows
    if stats.row_total >= MAX_ROWS:
      message.reply(MAX_ROWS_MSG)
      logging.info("start_command: Max rows reached %s" % (user))
      return
    #check number of triggers user has already
    if Trigger.all().filter("user ="******"start_command: too many triggers %s" % (user))
      return
    #limits on trigger length
    if len(trigger)<TRIGGER_LEN[0] or len(trigger)>TRIGGER_LEN[1]:
      message.reply(TRIGGER_LEN_MSG % (TRIGGER_LEN[0],TRIGGER_LEN[1]))
      return

    # limits on desc length
    desc=desc[0:DESC_LEN]

    result=Trigger.all().filter("user ="******"trigger =",trigger).get()
    if result:
      if result.desc != desc:
        result.desc=desc
        result.put()
    else:
      if not Trigger.all().filter("user ="******"start_command: %s, [%s] %s" % (user,trigger,desc))
    message.reply(START_MSG % (self.request.host_url,trigger,desc,trigger))
    stats.put()