def send(request): """网页发送信息。 """ if request.method == 'POST': try: msg = request.POST.get('content') # 发送到机器人 user = db.users.get_current_user() if user: blog = Blog.all().filter('user ='******'%s|%s: %s' % (user, blog.name, msg) else: msg = '%s|%s: %s' % (user, 'blog', msg) grouptalk.send(msg, user.email()) else: msg = 'web: ' + msg grouptalk.send(msg) # 发送到web客户端 grouptalk.channel_send(msg) except: logging.error('error web send msg!') return http.HttpResponse()
def invite_all_users(request): """邀请所有用户。""" blogs = Blog.all().fetch(limit=1000) for blog in blogs: grouptalk.invite(blog.user.email()) return http.HttpResponse()
def init_talkstatus(request): """管理员专用!慎用!初始化TalkStatus数据模型。""" db.delete(talk_models.TalkStatus.all().fetch(limit=1000)) blogs = Blog.all().fetch(limit=1000) for blog in blogs: talk_models.TalkStatus.add(user=blog.user, blog=blog) return http.HttpResponse()
def hosts(request): links = (blog.link[7:].encode('utf8').split('/')[0] for blog in Blog.all().fetch(limit=1000) if 'appspot.com' in blog.link) template = loader.get_template('tools/templates/hosts.html') context = RequestContext(request, { 'links': links, 'ip': IP, }) return http.HttpResponse(template.render(context))
def recieve(request): """机器人接收消息,信息转发。""" try: message = xmpp.Message(request.POST) if grouptalk.is_command(message.body): grouptalk.exec_command(message, message.body) return http.HttpResponse() sender_mail = message.sender.split('/')[0] blog = Blog.all().filter('user ='******'@')[0] if blog: msg = '%s|%s: %s' % (sender_user, blog.name, message.body) else: msg = '%s|%s: %s' % (sender_user, 'blog', message.body) grouptalk.send(msg, sender_mail) grouptalk.channel_send(msg) except: logging.error('error send msg!') return http.HttpResponse()
def blogname(self): blog = Blog.all().filter('user ='******''