def click_view_job(self): weixin_user = WeixinService.get_weixin_user(openid=self.openid) ret = EVENT_KEY_MAP.get('KEY_VIEW_JOB').get('welcome_str') if weixin_user: # todo get commend info ret = EVENT_KEY_MAP.get('KEY_VIEW_JOB').get('success_str') feed_list = UserFeed2.objects.filter( username=weixin_user.user.username, is_deleted=False, ).order_by('-add_time').select_related()[:5] if len(feed_list) == 0: ret = EVENT_KEY_MAP.get('KEY_VIEW_JOB').get('no_data') return ret desc_list = [] count = 0 for feed_obj in feed_list: count += 1 desc_list.append( '{0}、<a href="{1}{2}/">{3}</a>, {4}, {5}'.format( count, RECOMMAND_URL, str(feed_obj.feed.id), feed_obj.feed.title if feed_obj.feed.title else feed_obj.feed.keywords, feed_obj.feed.expect_area.replace(',', '/'), feed_obj.feed.talent_level.replace(',', '/'))) ret = ret % ('\n\n'.join(desc_list)) return ret
def click_bind_account(self): weixin_user = WeixinService.get_weixin_user(openid=self.openid) if not weixin_user: ret = EVENT_KEY_MAP.get('KEY_BIND_ACCOUNT').get('welcome_str') else: ret = EVENT_KEY_MAP.get('KEY_BIND_ACCOUNT').get('success_str') ret = ret % (weixin_user.user.username) return ret
def click_bind_account(self): weixin_user = WeixinService.get_weixin_user( openid=self.openid ) if not weixin_user: ret = EVENT_KEY_MAP.get('KEY_BIND_ACCOUNT').get('welcome_str') else: ret = EVENT_KEY_MAP.get('KEY_BIND_ACCOUNT').get('success_str') ret = ret % (weixin_user.user.username) return ret
def process_event_msg(self): self.reply_msg = CHAT_MAP.get('subscribe').get('welcome_str') if self.msg_type == 'event' and self.msg_event == 'SCAN': event_key = self.event_key event_key_action = self.get_event_action(event_key) uid_key = event_key[1:] if event_key_action == 'qr_bind': ret = WeixinService.qrcode_bind_user(uid_key=uid_key, openid=self.openid) self.reply_msg = CHAT_MAP.get('subscribe').get(ret['msg']) if ret['status'] == 'ok': self.reply_msg = self.reply_msg % (ret.get('username')) if event_key_action == 'get_red_pack': ret = WeixinService.qrcode_get_red_pack(uid_key=uid_key, openid=self.openid) self.reply_msg = CHAT_MAP.get('get_red_pack').get(ret['msg']) if self.msg_type == 'event' and self.msg_event == 'subscribe': self.reply_msg = CHAT_MAP.get('subscribe').get('welcome_str') if self.event_key and 'qrscene' in self.event_key: event_key = self.event_key[8:] event_key_action = self.get_event_action(event_key) uid_key = event_key[1:] if event_key_action == 'qr_bind': ret = WeixinService.qrcode_bind_user(uid_key=uid_key, openid=self.openid) self.reply_msg = CHAT_MAP.get('subscribe').get(ret['msg']) if ret['status'] == 'ok': self.reply_msg = self.reply_msg % (ret.get('username')) if event_key_action == 'get_red_pack': ret = WeixinService.qrcode_get_red_pack(uid_key=uid_key, openid=self.openid) self.reply_msg = CHAT_MAP.get('get_red_pack').get( ret['msg']) WeixinService.update_weixin_user(openid=self.openid, is_subscribe=True) if self.msg_type == 'event' and self.msg_event == 'unsubscribe': WeixinService.update_weixin_user(openid=self.openid, is_subscribe=False) if self.msg_type == 'event' and self.msg_event == 'CLICK': ret = EVENT_KEY_MAP.get(self.event_key) self.reply_msg = self.do_str_to_fun(fun_name=ret.get('fun_name')) return self.reply_content(content=self.reply_msg)
def click_view_job(self): weixin_user = WeixinService.get_weixin_user( openid=self.openid ) ret = EVENT_KEY_MAP.get('KEY_VIEW_JOB').get('welcome_str') if weixin_user: # todo get commend info ret = EVENT_KEY_MAP.get('KEY_VIEW_JOB').get('success_str') feed_list = UserFeed2.objects.filter( username=weixin_user.user.username, is_deleted=False, ).order_by('-add_time').select_related()[:5] if len(feed_list) == 0: ret = EVENT_KEY_MAP.get('KEY_VIEW_JOB').get('no_data') return ret desc_list = [] count = 0 for feed_obj in feed_list: count += 1 desc_list.append('{0}、<a href="{1}{2}/">{3}</a>, {4}, {5}'.format( count, RECOMMAND_URL, str(feed_obj.feed.id), feed_obj.feed.title if feed_obj.feed.title else feed_obj.feed.keywords, feed_obj.feed.expect_area.replace(',', '/'), feed_obj.feed.talent_level.replace(',', '/')) ) ret = ret % ( '\n\n'.join(desc_list) ) return ret
def process_text_msg(self): self.reply_msg = EVENT_KEY_MAP.get('KEY_HELP').get('welcome_str') reply_doc = CHAT_MAP.get(self.recv_msg) if not reply_doc: return self.reply_content(content=self.reply_msg) if reply_doc.get('type') == 'show_text': self.reply_msg = reply_doc.get('welcome_str') if reply_doc.get('type') == 'show_text_fun': self.reply_msg = reply_doc.get('fun_name') if reply_doc.get('type') == 'reply_text_fun': self.reply_msg = self.do_str_to_fun( fun_name=reply_doc.get('fun_name')) return self.reply_content(content=self.reply_msg)
def process_text_msg(self): self.reply_msg = EVENT_KEY_MAP.get('KEY_HELP').get('welcome_str') reply_doc = CHAT_MAP.get(self.recv_msg) if not reply_doc: return self.reply_content( content=self.reply_msg ) if reply_doc.get('type') == 'show_text': self.reply_msg = reply_doc.get('welcome_str') if reply_doc.get('type') == 'show_text_fun': self.reply_msg = reply_doc.get('fun_name') if reply_doc.get('type') == 'reply_text_fun': self.reply_msg = self.do_str_to_fun( fun_name=reply_doc.get('fun_name') ) return self.reply_content( content=self.reply_msg )
def click_contact_us(self): return EVENT_KEY_MAP.get('KEY_CONTACT_US').get('welcome_str')
def click_help(self): return EVENT_KEY_MAP.get('KEY_HELP').get('welcome_str')
def process_event_msg(self): self.reply_msg = CHAT_MAP.get('subscribe').get('welcome_str') if self.msg_type == 'event' and self.msg_event == 'SCAN': event_key = self.event_key event_key_action = self.get_event_action(event_key) uid_key = event_key[1:] if event_key_action == 'qr_bind': ret = WeixinService.qrcode_bind_user( uid_key=uid_key, openid=self.openid ) self.reply_msg = CHAT_MAP.get('subscribe').get(ret['msg']) if ret['status'] == 'ok': self.reply_msg = self.reply_msg % (ret.get('username')) if event_key_action == 'get_red_pack': ret = WeixinService.qrcode_get_red_pack( uid_key=uid_key, openid=self.openid ) self.reply_msg = CHAT_MAP.get('get_red_pack').get(ret['msg']) if self.msg_type == 'event' and self.msg_event == 'subscribe': self.reply_msg = CHAT_MAP.get('subscribe').get('welcome_str') if self.event_key and 'qrscene' in self.event_key: event_key = self.event_key[8:] event_key_action = self.get_event_action(event_key) uid_key = event_key[1:] if event_key_action == 'qr_bind': ret = WeixinService.qrcode_bind_user( uid_key=uid_key, openid=self.openid ) self.reply_msg = CHAT_MAP.get('subscribe').get(ret['msg']) if ret['status'] == 'ok': self.reply_msg = self.reply_msg % (ret.get('username')) if event_key_action == 'get_red_pack': ret = WeixinService.qrcode_get_red_pack( uid_key=uid_key, openid=self.openid ) self.reply_msg = CHAT_MAP.get('get_red_pack').get(ret['msg']) WeixinService.update_weixin_user( openid=self.openid, is_subscribe=True ) if self.msg_type == 'event' and self.msg_event == 'unsubscribe': WeixinService.update_weixin_user( openid=self.openid, is_subscribe=False ) if self.msg_type == 'event' and self.msg_event == 'CLICK': ret = EVENT_KEY_MAP.get(self.event_key) self.reply_msg = self.do_str_to_fun( fun_name=ret.get('fun_name') ) return self.reply_content( content=self.reply_msg )