def add_message(message): ''' Set of functions to ADD PLACE in BASE ''' user=str(message.from_user.id) insert_user(user,message.from_user.first_name, message.from_user.last_name,'telegram') if isAdmin(str(message.from_user.id)): keyboard1=telebot.types.ReplyKeyboardMarkup(True,True) keyboard1.row('battery') bot.send_message(message.chat.id,'Привет, что сдаем?',reply_markup=keyboard1) bot.register_next_step_handler(message, get_type)
def admin_start_message(message): if isAdmin(str(message.from_user.id)): greeting=''' Админские функции: /add - добавить место /user_list - список пользователей /set_admin - изменить роль пользователя /log - показать логи ''' bot.send_message(message.chat.id,greeting)
def admin_page(): ip = get_client_ip() if not db.isAdmin(ip): log.warning( 'Client {} tried to access admin page but is not drifter'.format( ip)) return redirect('/') data = db.getUserList() banned = db.getBanList() return render_template('admin.html', data=data, banned=banned)
def ban_request(): user = request.form['user'] ip = get_client_ip() if not db.isAdmin(ip): log.warning('Client {} tried to ban user {} but is not drifter'.format( ip, user)) return abort(status=403) if ban_user(user): log.info('Banned user {}'.format(user)) flash('Ban successful.', 'success') return redirect('/admin') else: log.error('Banning of user {} failed'.format(user)) flash('Ban failed.', 'danger') return redirect('/admin')
def ask_admin_message(message): if isAdmin(str(message.from_user.id)): bot.send_message(message.chat.id,'Введите идентификатор пользователя.') bot.register_next_step_handler(message, set_admin_message)
def admin_log_stat(message): if isAdmin(str(message.from_user.id)): logs= select_log_stats() for l in logs: bot.send_message(message.chat.id, '{} {}'.format(l,logs[l]))
def admin_log_message(message): if isAdmin(str(message.from_user.id)): logs= select_log() if len(logs)>5: logs=logs[-5:] for l in logs: bot.send_message(message.chat.id, '{} {} {}'.format(l['user_id'],l['date'],l['place_id']))
def admin_userlist_message(message): if isAdmin(str(message.from_user.id)): users= select_users() for u in users: bot.send_message(message.chat.id, '{} {} {} {} {}'.format(u['id'],u['username'],u['fio'],u['role'],u['messanger']))