Beispiel #1
0
def send_welcome(message):
    chat_id = message.chat.id
    bot.send_chat_action(chat_id, 'typing')
    time.sleep(0.5)
    markup = InlineKeyboardMarkup()
    sections = db.get_sections()
    i = 0
    btn = []
    limit = int(len(sections) / 2)
    for section in sections:
        if i != 2:
            btn.append(
                InlineKeyboardButton(text=section[1],
                                     callback_data="option" + "-" +
                                     str(section[0])))
            i += 1
        if i == 2:
            markup.add(btn[0], btn[1])
            limit -= 1
            i = 0
            btn = []
        elif limit == 0:
            markup.add(
                InlineKeyboardButton(text=section[1],
                                     callback_data="option" + "-" +
                                     str(section[0])))
    bot.send_message(message.chat.id,
                     "مقطع خود را انتخاب کنید؟",
                     reply_markup=markup)
Beispiel #2
0
def send_field(call):
    chat_id = call.message.chat.id
    bot.send_chat_action(chat_id, 'typing')
    time.sleep(0.5)
    try:
        bot.delete_message(call.message.chat.id, call.message.message_id)
    except Exception:
        pass
    markup = InlineKeyboardMarkup()
    sections = db.get_sections()
    i = 0
    btn = []
    limit = int(len(sections) / 2)
    for section in sections:
        if i != 2:
            btn.append(
                InlineKeyboardButton(section[1],
                                     callback_data="option" + "-" +
                                     str(section[0])))
            i += 1
        if i == 2:
            markup.add(btn[0], btn[1])
            limit -= 1
            i = 0
            btn = []
        elif limit == 0:
            markup.add(
                InlineKeyboardButton(section[1],
                                     callback_data="option" + "-" +
                                     str(section[0])))
    bot.send_message(call.message.chat.id,
                     "در چه زمینه ای سوال دارید؟",
                     reply_markup=markup)
Beispiel #3
0
 def get(self):
     sections = db.get_sections()
     action = self.get_argument('action', None)
     warning = self.get_argument('warning', None)
     if action == 'logout':
         self.set_secure_cookie('user', '')
     self.render('t_signin.html', title='Ran - Sign In', sections=sections, warning=warning)
Beispiel #4
0
 def get(self):
     uid = self.get_secure_cookie('user')
     user = db.get_user(uid)
     sections = db.get_sections()
     forum = db.get_forum()
     wealthList = db.get_wealth_list()
     warning = self.get_argument('warning', None)
     self.render(
             't_config.html', title='Ran - Config',
             user=user, setions=sections, forum=forum,
             warning=warning, wealthList=wealthList,
             )
Beispiel #5
0
 def get(self):
     sections = db.get_sections()
     forum = db.get_forum()
     wealthList = db.get_wealth_list()
     uid = self.get_secure_cookie('user')
     if uid:
         user = db.get_user(uid)
     self.render(
             't_new.html', title='Ran - New',
             sections=sections, forum=forum, user=user,
             wealthList=wealthList,
             )
     pass
Beispiel #6
0
 def get(self):
     sections = db.get_sections()
     uid = self.get_secure_cookie('user')
     print 'uid: ', uid
     forum = db.get_forum()
     allPosts = db.get_all_posts_split_by_section()
     wealthList = db.get_wealth_list()
     if uid:
         user = db.get_user(uid)
     else:
         user = {}
     self.render(
             't_home.html', title='Ran - Home',
             user=user, forum=forum, sections=sections,
             allPosts=allPosts, wealthList=wealthList,
             )
Beispiel #7
0
 def get(self):
     sections = db.get_sections()
     self.render('t_signup.html', title='Ran - Sign Up', sections=sections)