def list(self, body, message): '''列出最新工作,通过「job list 2」来翻页或者「job list 中南 2」来筛选学校并翻页哦''' user = get_user_by_weixin(message.From) sp = body.split(' ', 1) page = 1 fid = None if sp and len(sp) == 1: s = sp[0] if s.isdigit(): page = int(s) else: fid = s elif sp and len(sp) >= 2: fid, page = sp[:2] else: return '命令不正确哦~请用job help list查看如何使用' try: page = int(page) if fid: fid = int(fid) except Exception: page = 1 fid = None ret = self.job.list_jobs(user.id, page, fid) if not ret: return '没有了哦' items = ['把-id之后的数字组合成命令「job detail 1234」则可以看到详细信息\n'] for item in ret['rs']: items.append('-id %d\n%s\n%s\n在 %s\n' % (item['aid'], item['title'], \ item['date'], item['place'])) return '-----------------------\n'.join(items)
def unbind(self, body, message): '''解除校门口账号绑定''' user = get_user_by_weixin(message.From) if not user: return '似乎你之前并未绑定过哦' user.remove_weixin() clear_user_cache(user) return '解除绑定成功'
def detail(self, body, message): '''显示工作详细信息,通过「job detail 1234」来查看''' sp = body.split(' ', 1) user = get_user_by_weixin(message.From) if sp and len(sp) == 1 and sp[0].isdigit(): aid = int(sp[0]) else: return '这不是合法的工作id哦' ret = self.job.detail(user.id, aid) if not ret: return '找不到这个工作的详细信息哦' return '学校: %s\n时间: %s\n地点: %s\n详细: %s' % (ret['feed'], ret['date'], ret['place'], ret['url'])
def who(self, body, message): '''我是谁''' user = get_user_by_weixin(message.From) if not user: return '你存在么' return 'email: %s' % user.email