Пример #1
0
  def get(self):
    phonecode = self.request.get('phonecode')
    keyword = self.request.get('keyword')
    location = self.request.get('location')
    carrier = self.request.get('carrier')
    self.content = self.request.get('content')
    self.phoneno = self.request.get('msisdn')
    if self.phoneno == None or self.content == None:
      self.response.out.write("Please provide both msisdn and content")
      return

    # Check if the phoneno is registerd and is active
    tuser = TwitterUser.get_by_phonenumber(self.phoneno)
    r = re.compile('^\s*twe*t\s*',re.I)
    self.content = r.sub('',self.content)
    if tuser and tuser.active:
      if len(self.content) == 0:
        self.response.out.write("Dude !! where is the message to be sent? Hit the send message too fast")
        return

      if re.match("^register", self.content, re.I): # if content starts with register
        self.response.out.write("Your message cannot start with register as it is a keyword\n")
        return

      updated = False
      status = self.content[0:139]  # makes sure status is 140 chars long
      self.updateStatuswithToken(tuser, status)

      try:
        dstat = DailyStat.get_by_date()
        dstat.new_tweet()

        tuser.incr_counter(location,carrier)

        tuser.fetch_mentions_and_dms()
        Stats.updateCounter(tuser.user)
        
      except Timeout, e:
        logging.warning("Timed out logging the stats !! never mind")
      except DeadlineExceededError, e:
        logging.error("Deadline exceeded while logging the stats !! never mind")
Пример #2
0
    def get(self):
        stats = Stats.singleton()

        values = {"counter": intWithCommas(stats.counter), "recentTweeters": stats.recentTweeters, "current": "about"}

        self.response.out.write(template.render("about.html", values))
Пример #3
0
                    # case 2.1
                    ph = tuser.phonenumber
                    message = (
                        "<p>You are tweeting currently using phone number <span class='nos'>%s</span></p><p>Would you like to change this number?</p><form action='/' method='post'><label for='phoneno'>New Phone Number: +91</label><input type=text name='phoneno' value=''></input><input id='formsubmit' type='submit' value='Change'></form>"
                        % ph
                    )
                else:
                    # case 2.2
                    message = "<p>Please provide the phone number using which you would like to tweet</p><form action='/' method='post'> <label for='phoneno'>Phone Number : +91</label><input type=text name='phoneno' value=''></input><input id='formsubmit' type='submit' value='Add'></form>"

        # if user_name:
        #  message = "Dear %s,<br>%s" % (user_name, message)
        # else:
        #  message = self.response.out.write('<a href="/oauth/twitter/login">Login via Twitter</a>')

        stats = Stats.singleton()

        if server_error:
            user_name = "dummy"
            message = "<p>Twitter is having it's Fail Whale moment. Please try again after some time. Hopefully things should be back up.</p>"

        flash = Flash()

        values = {
            "user_name": user_name,
            "message": message,
            "counter": intWithCommas(stats.counter),
            "recentTweeters": stats.recentTweeters,
            "flash": flash,
        }
        self.response.out.write(template.render("main.html", values))