def detector(self, message, au_post, auth, db_path=path['lots']): lot, log_text = None, 'None' lot_split = message['text'].split('/') print_text = f"{self.server['link: channel']}{lot_split[0]}" if int(lot_split[0]) >= au_post: db = SQLighter(db_path) lot = self.form(message['text']) lot_in_db = secure_sql(db.get_lot, lot['au_id']) html_link = objects.html_link(print_text, f"№{lot['lot_id']}") log_text = f"#Рассылка лота #{lot['lot_id']} {html_link} с айди #{lot['base']} разошелся по " log_text += f"{bold('{}')} адресатам " + code(f"id:{lot['au_id']}") if lot_in_db is False: secure_sql(db.merge, lot) if lot['base'] != 'None': if lot['status'] != '#active': print_text += ' Не активен, в базу добавлен' else: auth.send_dev_message( print_text + code('\nЭтого куска говна нет в константах'), tag=None) else: print_text += ' Уже в базе' else: print_text += ' Старый, lot_updater() разберется' objects.printer(print_text) return lot, log_text
def callbacks(call): try: if call.data == 'post': search = re.search('🔎(.*?)🔎', call.message.text) if search: site_search = re.search(r'tut\.by|hh\.ru', search.group(1)) if site_search: post = tut_quest(search.group(1)) else: post = praca_quest(search.group(1)) poster(idMain, former(post[1], 'MainChannel', post[0])) text = call.message.text + code('\n✅ опубликован ✅') bot.edit_message_text(chat_id=call.message.chat.id, text=text, message_id=call.message.message_id, reply_markup=None, parse_mode='HTML', disable_web_page_preview=True) else: ExceptAuth.send_json( call.message.text, 'callbacks', code('Не нашел в посте ссылку на вакансию')) elif call.data == 'viewed': text = call.message.text + code('\n👀 просмотрен 👀') bot.edit_message_text(chat_id=call.message.chat.id, text=text, message_id=call.message.message_id, reply_markup=None, parse_mode='HTML', disable_web_page_preview=True) except IndexError and Exception: executive(str(call))
def sender(text, date, channel): global last_date, mini_post_id, main_post_id bot.send_message(idChannel, text, parse_mode='HTML', disable_web_page_preview=True) sleep(4) if channel == 'main': main_post_id += 1 else: mini_post_id += 1 last_date = date try: start_editing = \ bold('CW3: ') + code(main_post_id) + bold(' :CW3\n') + \ bold('mini: ') + code(mini_post_id) + bold(' :mini\n') + \ bold('d: ') + code(last_date) + bold(' :d\n') bot.edit_message_text(start_editing, -1001471643258, 4, parse_mode='HTML') except IndexError and Exception as error: executive(str(error))
def commands(message): global block try: if message.chat.id == idMe or message.chat.id == idAndre: if message.text.startswith('/disable'): new_block = 'True' else: new_block = 'False' if block != new_block: block = new_block start_editing = code('Последний пост на канале jobsrb\n') + \ bold('d: ') + objects.log_time(last_date + 3 * 60 * 60, code, form='channel') + bold(' :d') + \ bold('\nblock: ') + block + bold(' :block') try: bot.edit_message_text(start_editing, -1001471643258, start_post, parse_mode='HTML') if block == 'True': text = 'Посты на канале не публикуются' else: text = 'Посты на канале публикуются в штатном режиме' ExceptAuth.send_dev_message('block changed, block = ' + block) bot.send_message(message.chat.id, 'Установлено новое значение:\n' + bold(text), parse_mode='HTML') except IndexError and Exception as error: error = bold('Проблемы с изменением стартового сообщения на канале ') + \ start_address + '\n\n' + start_editing + '\n' + str(error) ExceptAuth.send_dev_message(error, None) else: if block == 'True': text = 'Посты на канале не публикуются' else: text = 'Посты на канале публикуются в штатном режиме' ExceptAuth.send_dev_message('block not changed, block = ' + block) bot.send_message(message.chat.id, 'Уже установлено данное значение:\n' + bold(text), parse_mode='HTML') except IndexError and Exception: executive(str(message))
def poster(id_forward, array): global last_date if array[0] != array[2]: message = bot.send_message(id_forward, array[0], reply_markup=array[1], parse_mode='HTML') pic_text = instagram_former(array[3]) instagram_image(pic_text, 1080, idInstagram) try: instagram_image(pic_text, 1920, idTikTok) except IndexError and Exception as e: bot.send_message(idMe, str(e)) if id_forward == idMain: if last_date < message.date: last_date = message.date start_editing = code('Последний пост на канале jobsrb\n') + \ bold('d: ') + objects.log_time(last_date + 3 * 60 * 60, code, form='channel') + bold(' :d') + \ bold('\nblock: ') + block + bold(' :block') try: bot.edit_message_text(start_editing, -1001471643258, start_post, parse_mode='HTML') except IndexError and Exception as error: error = bold('Проблемы с изменением стартового сообщения на канале ') + \ start_address + '\n\n' + start_editing + '\n' + str(error) ExceptAuth.send_dev_message(error, None) else: text = array[3]['tag_picture'] + 'Что-то пошло не так: {\n' + \ objects.under(bold('link')) + ': ' + array[2] + '\n' for i in array[3]: if i == 'short_place' or i == 'money' or i == 'title': text += objects.under(bold(i)) + ': ' + re.sub( '<', '<', str(array[3].get(i))) + '\n' elif i != 'description': text += str(i) + ': ' + re.sub('<', '<', str(array[3].get(i))) + '\n' bot.send_message(idMe, text + '}', parse_mode='HTML')
def poster(id_forward, array): global last_date if array[0] != array[2]: message = bot.send_message(id_forward, array[0], reply_markup=array[1], parse_mode='HTML') if id_forward == idMain: if last_date < message.date: last_date = message.date start_editing = code('Последний пост на канале Superwork\n') + \ bold('d: ') + log_time(last_date + 3 * 60 * 60, code, 0, 'channel') + bold(' :d') try: bot.edit_message_text(start_editing, -1001471643258, start_link, parse_mode='HTML') except IndexError and Exception: error = '<b>Проблемы с измением стартового ' \ 'сообщения на канале @UsefullCWLinks</b>\n\n' + start_editing bot.send_message(idMe, error, parse_mode='HTML', disable_web_page_preview=True) else: if array[3]: text = array[3]['tag_picture'] + 'Что-то пошло не так: {\n' + under(bold('link')) + ': ' + array[2] + '\n' for i in array[3]: if i == 'short_place' or i == 'money' or i == 'title': text += under(bold(i)) + ': ' + re.sub('<', '<', str(array[3].get(i))) + '\n' elif i != 'description': text += str(i) + ': ' + re.sub('<', '<', str(array[3].get(i))) + '\n' bot.send_message(idMe, text + '}', parse_mode='HTML')
def lot_title(self, lot, title, depth='hard', generate=False): if generate: title = objects.html_secure(title) title = re.sub('️', '', title).replace('\'', ''') for key in properties_title_list: lot[key] = 'None' item_name = re.sub(r' \+\d+.', '', title) enchant_search = re.search(r'\+(\d+) ', item_name) for parameter in re.findall(r' \+\d+.', title): if lot['params'] == 'None': lot['params'] = '' lot['params'] += parameter if enchant_search: lot['enchant'] = enchant_search.group(1) item_name = re.sub(r'(\+\d+ )|(⚡)', '', item_name) item_emoji = re.sub(self.server['non_emoji_symbols'], '', item_name) if len(item_emoji) > 0: lot['item_emoji'] = item_emoji item_name = re.sub(item_emoji, '', item_name) item_name = lot['item_name'] = item_name.strip() if item_name in self.const_base: lot['base'] = self.const_base[item_name] if lot['params'] != 'None' and lot['base'][0] not in allowed_lists[ 'params']: lot['base'] = 'None' else: if re.search(r'lvl\.\d+', lot['item_name']): # Search mystery items if re.search('amulet', lot['item_name']): lot['base'] = 'amt' if re.search('ring', lot['item_name']): lot['base'] = 'rng' if lot['params'] != 'None' and lot[ 'base'] == 'None' and depth == 'hard': print('драсте') allowed = ['params'] db = SQLighter(path['lots']) params_item_names = secure_sql(db.get_dist_base, [lot, allowed]) if len(params_item_names) > 1: allowed = ['params', 'quality'] params_item_names = secure_sql(db.get_dist_base, [lot, allowed]) if len(params_item_names) > 1: allowed = ['params', 'quality', 'enchant'] params_item_names = secure_sql(db.get_dist_base, [lot, allowed]) for item_name in params_item_names: if item_name in lot['item_name']: lot = self.engrave(item_name, lot) if lot['base'] == 'None' and depth == 'hard': item_names = [] for item_name in self.const_base: if item_name in lot['item_name'] \ and self.const_base[item_name][0] in allowed_lists['engrave']: item_names.append(item_name) if len(item_names) >= 1: item_name = item_names[0] for temp_name in item_names: if temp_name > item_name: item_name = temp_name lot = self.engrave(item_name, lot) if generate: text = '' if lot['item_name'] != 'None': enchant_emoji = '⚡' if lot['item_emoji'] != 'None': text += lot['item_emoji'] enchant_emoji = '' if lot['enchant'] != 'None': text += bold(f"{enchant_emoji}+{lot['enchant']} ") if lot['engrave'] != 'None': engraved = code(re.sub('[✒🖋]', '', lot['engrave'])) if lot['engrave'].startswith('✒'): text += f"{bold(lot['item_name'])} {engraved}" else: text += f"{engraved} {bold(lot['item_name'])}" else: text += bold(lot['item_name']) if lot['params'] != 'None': text += bold(lot['params']) if lot['base'] != 'None': text += f" {code('[')}/{lot['base']}{code(']')}" if len(text) > 0: lot['generate'] = text return lot
def former(growing, kind, pub_link): text = '' if growing['title'] != 'none': text_to_image = re.sub('/', ' / ', growing['title']) text_to_image = re.sub(r'\(.*?\)|[+.,]|г\.', '', text_to_image) text_to_image = re.sub('e-mail', 'email', re.sub(r'\s+', ' ', text_to_image)) growing['tag_picture'] = image( re.sub(r'[\s-]', ' ', text_to_image.strip())) text = growing['tag_picture'] + '👨🏻💻 ' + bold(growing['title']) + '\n' if growing['short_place'] != 'none': text += '🏙 ' + growing['short_place'] + '\n' if growing['experience'] != 'none': text += '🏅 Опыт работы ➡ ' + growing['experience'].capitalize() + '\n' if growing['education'] != 'none': text += '👨🎓 Образование ➡ ' + growing['education'].capitalize() + '\n' if growing['money'] != 'none': more = '' if growing['money'][1] != 'none': more += '+' text += '💸 ' + bold( 'З/П ') + growing['money'][0] + more + ' руб.' + '\n' text += bold('\n📔 Контакты\n') if growing['org_name'] != 'none': text += growing['org_name'] + '\n' if growing['contact'] != 'none': text += growing['contact'] + '\n' if growing['numbers'] != 'none': text += growing['numbers'] + '\n' if growing['email'] != 'none': text += growing['email'] + ' ➡ Резюме\n' if growing['place'] != 'none': text += bold('\n🏘 Адрес\n') + growing['place'] + '\n' if growing['metro'] != 'none': text += '🚇 ' + growing['metro'] + '\n' if kind == 'MainChannel': keys = None if growing['geo'].lower() != 'none': text += '\n📍 <a href="http://maps.yandex.ru/?text=' + growing[ 'geo'] + '">На карте</a>\n' text += '\n🔎 <a href="' + pub_link + '">Источник</a>\n' else: keys = keyboard text += code('-------------------\n') if growing['geo'].lower() != 'none': text += '📍http://maps.yandex.ru/?text=' + growing['geo'] + '\n' text += '🔎' + pub_link + '🔎\n' text += code('-------------------\n') if growing['tags'] != 'none': text += objects.italic('\n💼ТЕГИ: ') for i in growing['tags']: text += '#' + re.sub('_+', '_', i) + ' ' text = text[:-1] + '\n' if growing['short_place'] == 'none' or growing[ 'money'] == 'none' or growing['title'] == 'none': text = pub_link if growing['title'] != 'none': search_restricted = re.search('водитель|яндекс|такси|уборщи', growing['title'].lower()) if search_restricted: text = pub_link if growing['org_name'] != 'none': search_restricted = re.search('доброном', growing['org_name'].lower()) if search_restricted: text = pub_link if growing['experience'] != 'none': search_restricted = re.search('6', growing['experience'].capitalize()) if search_restricted: text = pub_link return [text, keys, pub_link, growing]