예제 #1
0
파일: xmpp.py 프로젝트: wade-fs/mud-fs
 def list_command(self, msg):
   """Handle /list commands."""
   lines = []
   q = Channel.all().order('-num_members').filter('num_members >', 0)
   channels = q.fetch(self._LIST_LIMIT + 1)
   if not len(channels):
     msg.reply(u'* 沒有任何頻道!')
     return
   if len(channels) <= self._LIST_LIMIT:
     # Show all, sorted by channel name.
     channels.sort(key=lambda c: c.name)
     lines.append('* 所有頻道清單如下:')
   else:
     # Show the top N channels, sorted by num_members.
     channels.pop()
     lines.append('* 頻道數超過 %d; 底下是最受歡迎的清單:' %
                  self._LIST_LIMIT)
   for c in channels:
     if c.num_members == 1:
       count = '1 個人'
     else:
       count = '%d 個人' % c.num_members
     s = '* - %s (%s)' % (c, count)
     lines.append(s)
   msg.reply(u'\n'.join(lines))
예제 #2
0
 def list_command(self, msg):
     """Handle /list commands."""
     lines = []
     q = Channel.all().order('-num_members').filter('num_members >', 0)
     channels = q.fetch(self._LIST_LIMIT + 1)
     if not len(channels):
         msg.reply('* No channels exist!')
         return
     if len(channels) <= self._LIST_LIMIT:
         # Show all, sorted by channel name.
         channels.sort(key=lambda c: c.name)
         lines.append('* All channels:')
     else:
         # Show the top N channels, sorted by num_members.
         channels.pop()
         lines.append(
             '* More than %d channels; here are the most popular:' %
             self._LIST_LIMIT)
     for c in channels:
         if c.num_members == 1:
             count = '1 person'
         else:
             count = '%d people' % c.num_members
         s = '* - %s (%s)' % (c, count)
         lines.append(s)
     msg.reply('\n'.join(lines))
예제 #3
0
 def list_command(self, msg):
   """Handle /list commands."""
   lines = []
   q = Channel.all().order('-num_members').filter('num_members >', 0)
   channels = q.fetch(self._LIST_LIMIT + 1)
   if not len(channels):
     msg.reply('* No channels exist!')
     return
   if len(channels) <= self._LIST_LIMIT:
     # Show all, sorted by channel name.
     channels.sort(key=lambda c: c.name)
     lines.append('* All channels:')
   else:
     # Show the top N channels, sorted by num_members.
     channels.pop()
     lines.append('* More than %d channels; here are the most popular:' %
                  self._LIST_LIMIT)
   for c in channels:
     if c.num_members == 1:
       count = '1 person'
     else:
       count = '%d people' % c.num_members
     s = '* - %s (%s)' % (c, count)
     lines.append(s)
   msg.reply('\n'.join(lines))
예제 #4
0
 def get(self, op):
   if op == 'channels':
     channels = Channel.all().order('-num_members').fetch(self._MAX_CHANNELS)
     self.Render('channels.html', {
         'channels': channels,
         'max': min(len(channels), self._MAX_CHANNELS),
     })
   elif op == 'transcript':
     self.RenderTranscript()
예제 #5
0
파일: tv.py 프로젝트: erdenezul/tv-feeder
 def get(self):
     global is_modified
     is_modified = True
     for ch in Channel.all():
         ch.delete()
     for c in CHANNELS_LIST:
         channel = Channel(img_url=c["img_url"], name=c["name"])
         channel.put()
         taskqueue.add(url="/tvfeed/update", method="POST", params={"key": channel.key(), "gogo_id": c["c_id"]})
     self.response.out.write("Started")
예제 #6
0
파일: api.py 프로젝트: uskr/notify-io
    def post(self, hash):
        hash = hash.lower()
        target = Account.all().filter('hash =', hash).get()
        if not target:
            target = Account.all().filter('hashes =', hash).get()
        source = Account.all().filter('api_key =',
                                      self.request.get('api_key')).get()

        channel = Channel.all().filter('target =',
                                       target).filter('source =',
                                                      source).get()
        approval_notice = None
        if not channel and source and target:
            channel = Channel(target=target,
                              source=source,
                              outlet=target.get_default_outlet())
            channel.put()
            approval_notice = channel.get_approval_notice()
            channel.send_activation_email()

        if channel:
            notice = Notification(channel=channel,
                                  text=strip_tags(self.request.get('text')),
                                  icon=source.source_icon)
            for arg in ['title', 'link', 'icon', 'sticky', 'tags']:
                value = strip_tags(self.request.get(arg, None))
                if value:
                    setattr(notice, arg, value)
            notice.put()

            # Increment the counter on the channel to represent number of notices sent
            channel.count += 1
            channel.put()

            if channel.status == 'enabled':
                notice.dispatch()
                self.response.out.write("OK\n")

            elif channel.status == 'pending':
                self.response.set_status(202)
                if approval_notice:
                    approval_notice.dispatch()
                    self.response.out.write("OK\n")
                else:
                    self.response.out.write("202 Pending approval")
            elif channel.status == 'disabled':
                self.response.set_status(202)
                self.response.out.write("202 Accepted but disabled")
        else:
            self.error(404)
            self.response.out.write("404 Target or source not found")
예제 #7
0
파일: tv.py 프로젝트: erdenezul/tv-feeder
 def get(self):
     global is_modified, cached_response
     if is_modified:
         response = ""
         for c in Channel.all():
             response += c.name + "#" + c.img_url + "\n"
             for i in range(1, 8):
                 programs = Program.gql("WHERE day = :day AND channel = :channel", day=i, channel=c)
                 response += "\t" + str(i) + "\n"
                 for p in programs:
                     response += "\t\t" + p.time + "#" + p.name + "\n"
         cached_response = response
         is_modified = False
         logging.info("cached response")
         self.response.out.write(response)
     else:
         logging.info("responding from cache")
         self.response.out.write(cached_response)
예제 #8
0
    def post(self, hash):
        hash = hash.lower()
        target = Account.all().filter("hash =", hash).get()
        if not target:
            target = Account.all().filter("hashes =", hash).get()
        source = Account.all().filter("api_key =", self.request.get("api_key")).get()

        channel = Channel.all().filter("target =", target).filter("source =", source).get()
        approval_notice = None
        if not channel and source and target:
            channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
            channel.put()
            approval_notice = channel.get_approval_notice()
            channel.send_activation_email()

        if channel:
            notice = Notification(channel=channel, text=strip_tags(self.request.get("text")), icon=source.source_icon)
            for arg in ["title", "link", "icon", "sticky", "tags"]:
                value = strip_tags(self.request.get(arg, None))
                if value:
                    setattr(notice, arg, value)
            notice.put()

            # Increment the counter on the channel to represent number of notices sent
            channel.count += 1
            channel.put()

            if channel.status == "enabled":
                notice.dispatch()
                self.response.out.write("OK\n")

            elif channel.status == "pending":
                self.response.set_status(202)
                if approval_notice:
                    approval_notice.dispatch()
                    self.response.out.write("OK\n")
                else:
                    self.response.out.write("202 Pending approval")
            elif channel.status == "disabled":
                self.response.set_status(202)
                self.response.out.write("202 Accepted but disabled")
        else:
            self.error(404)
            self.response.out.write("404 Target or source not found")
예제 #9
0
파일: api.py 프로젝트: DFectuoso/notify-io
 def post(self): 
     hash = self.request.path.split('/')[-1]
     target = Account.all().filter('hash =', hash).get()
     if not target:
         target = Account.all().filter('hashes =', hash).get()
     source = Account.all().filter('api_key =', self.request.get('api_key')).get()
     
     channel = Channel.all().filter('target =', target).filter('source =', source).get()
     approval_notice = None
     if not channel and source and target:
         channel = Channel(target=target, source=source, outlet=target.get_default_outlet())
         channel.put()
         approval_notice = channel.get_approval_notice()
         channel.send_activation_email()
         
     if channel:
         notice = Notification(channel=channel, text=strip_tags(self.request.get('text')), icon=source.source_icon)
         for arg in ['title', 'link', 'icon', 'sticky', 'tags']:
             value = strip_tags(self.request.get(arg, None))
             if value:
                 setattr(notice, arg, value)
         notice.put()
         
         # Increment the counter on the channel to represent number of notices sent
         channel.count += 1
         channel.put()
         
         if channel.status == 'enabled':
             self.response.out.write(notice.dispatch())
             
         elif channel.status == 'pending':
             self.response.set_status(202)
             if approval_notice:
                 self.response.out.write(":".join([channel.outlet.hash, approval_notice.to_json()]))
             else:
                 self.response.out.write("202 Pending approval")
         elif channel.status == 'disabled':
             self.response.set_status(202)
             self.response.out.write("202 Accepted but disabled")
     else:
         self.error(404)
         self.response.out.write("404 Target or source not found")
예제 #10
0
 def get(self):
     channels = [channel for channel in Channel.all().order('channel') 
                     if channel.channel.startswith('#')]
     self.response.out.write(render('templates/index.html', locals()))
예제 #11
0
 def get(self):
     self.render("admin.html", boards=Channel.all())
예제 #12
0
파일: cutils.py 프로젝트: qmacro/coffeeshop
def delete_all_channels():
    while Channel.all().fetch(CHUNK):
        db.delete(Channel.all().fetch(CHUNK))
예제 #13
0
def delete_all_channels():
  while Channel.all().fetch(CHUNK):
    db.delete(Channel.all().fetch(CHUNK))
예제 #14
0
 def get(self):
     self.render("admin.html", boards=Channel.all())
예제 #15
0
 def get(self):
     for chan in Channel.all().fetch(1000):
         channel.send_message(chan.key().name(),"hi")
         self.response.out.write(str(chan.key().name())+"<br>")
예제 #16
0
 def execute(self):
     self.response.update({
         'channel_list': Channel.all(),
     })