def new_warn(msg): user_id = msg.reply_to_message.from_user.id chat_id = msg.chat.id api.new_warn(user_id=user_id, chat_id=chat_id) curr = api.get_warns(user_id=user_id, chat_id=chat_id) kb = types.InlineKeyboardMarkup() kb.add( types.InlineKeyboardButton( text='Удалить предупреждения', callback_data='warns_del::{chat_id}::{user_id}'.format( user_id=user_id, chat_id=chat_id))) max_warns = int(api.get_group_params(msg.chat.id)['warns']['count']) bot.send_message(msg.chat.id, text.group_commands[get_group_lang( msg.chat.id)]['users']['warn'].format( user_id=user_id, user_name=api.replacer( msg.reply_to_message.from_user.first_name), current_warns=curr, max_warns=max_warns), parse_mode='HTML', reply_markup=kb) settings = api.get_group_params(chat_id)['warns']['action'] if curr >= max_warns: if settings == 0: pass elif settings == 1: kick_user_warns(msg, max_warns) elif settings == 2: ban_user_warns(msg, max_warns) elif settings == 3: ro_user_warns(msg, max_warns) api.zeroing_warns(user_id, chat_id)
def is_restricted(msg): chat_id = msg.chat.id try: return api.get_group_params(chat_id)['deletions']['files'][ msg.content_type] except Exception as e: print(e) print(api.get_group_params(chat_id))
def generate_rules_text(msg): example = api.get_group_params(msg.chat.id)['rules']['text'] example = example.format(new_user_id=msg.new_chat_member.id, new_user_firstname=api.replacer( msg.new_chat_member.first_name), new_user_username=msg.new_chat_member.username, chat_id=msg.chat.id, chat_title=api.replacer(msg.chat.title)) return example
def get_log_id(chat_id): return api.get_group_params(chat_id)['logs_channel']['chat_id']
def check_log(chat_id): return api.get_group_params(chat_id)['logs_channel']['is_on']
def get_group_lang(chat_id): r = api.get_group_params(chat_id) return r['language']
def change_state_main(chat_id, column): settings = api.get_group_params(chat_id) curr_state = settings[column] new_state = config.settings_states[curr_state] settings[column] = new_state api.change_group_params(chat_id, ujson.dumps(settings))
def change_state_deletions_files(chat_id, column): settings = api.get_group_params(chat_id) curr_state = settings['deletions']['files'][column] new_state = config.settings_states[curr_state] settings['deletions']['files'][column] = new_state api.change_group_params(chat_id, ujson.dumps(settings))
def set_rules(msg, rules): params = api.get_group_params(msg.chat.id) params['rules']['is_enabled'] = True params['rules']['text'] = rules api.change_group_params(msg.chat.id, ujson.dumps(params))
def need_greeting(msg): r = api.get_group_params(msg.chat.id) return r['greeting']['is_enabled']
def get_greeting(chat_id): r = api.get_group_params(chat_id) return r['greeting']['text']
def set_greeting(msg, greeting): params = api.get_group_params(msg.chat.id) params['greeting']['is_enabled'] = True params['greeting']['text'] = greeting api.change_group_params(msg.chat.id, ujson.dumps(params))
def get_group_lang(msg): r = api.get_group_params(msg.chat.id) return r['language']