def repeat_all_messages(message): try: if message.chat.id == idMe or message.chat.id == idAndre: if message.text.startswith( 'https://praca.by/vacancy/') or message.text.startswith( 'https://'): site_search = re.search(r'tut\.by|hh\.ru', message.text) if site_search: post = tut_quest(message.text) else: post = praca_quest(message.text) poster(message.chat.id, former(post[1], 'Private', post[0])) elif message.text.startswith('/pic'): subbed = re.sub('/pic', '', message.text).strip() bot.send_message(message.chat.id, image(subbed), parse_mode='HTML') elif message.text.startswith('/log'): bot.send_document(message.chat.id, open('log.txt', 'r')) else: bot.send_message(message.chat.id, bold('ссылка не подошла'), parse_mode='HTML') except IndexError and Exception: executive(str(message))
def repeat_all_messages(message): try: if message.chat.id in allowed_persons: if message.text.startswith('https://'): site_search = re.search(r'hh\.ru', message.text) if site_search: post = hh_quest(message.text) else: post = hh_quest(message.text) poster(message.chat.id, former(post[0], post[1], str(random.randint(1, 2)))) elif message.text.startswith('/pic'): subbed = re.sub('/pic', '', message.text).strip() split = subbed.split('/') if len(split) > 1: background_coefficient = str(random.randint(1, 2)) text = image(split[0], split[1], background_coefficient) else: text = 'Или блять нормально вводи или блять иди нахуй просто уебан' bot.send_message(message.chat.id, text, parse_mode='HTML') elif message.text.startswith('/base'): doc = open('log.txt', 'rt') bot.send_document(message.chat.id, doc) doc.close() else: bot.send_message(message.chat.id, bold('ссылка не подошла, пошел нахуй'), parse_mode='HTML') except IndexError and Exception: executive(str(message))
def form_mash(au_id, lot): from timer import timer text = '' price = 0 lot_id = '' channel = 'au' status = 'None' modifiers = 'None' stamp_now = time_now() - 24 * 60 * 60 stamp = stamp_now - 10 for g in lot.split('\n'): for i in search_array: search = re.search(search_array.get(i), g) if search: if i == 'Лот #': text += i + search.group(1) + ' : ' + objects.bold( search.group(2)) + '\n' lot_id = search.group(1) elif i == 'Модификаторы:': text += i + '\n{0}' modifiers = '' elif i == 'Цена: ': text += i + search.group(1) + ' 👝\n' price = int(search.group(1)) elif i == 'cw3': price = int(search.group(1)) channel = i elif i == 'Срок: ': stamp = timer(search) text += i + str(time_mash(stamp)) + '\n' elif i == 'Статус: ': text += i if search.group(1) in ['Cancelled', 'Failed', 'Отменен']: status = 'Отменен' elif search.group(1) == '#активен': status = '#активен' elif search.group(1) == '#active': if stamp < stamp_now: status = 'Закончился' else: status = '#активен' else: status = 'Закончился' text += status if status == '#активен': text += '\n\n/bet_{1} /l_{1}' else: if search.group(1) == 'None': text += i + 'Нет\n' else: text += i + search.group(1) + '\n' if modifiers != 'None' and g.startswith(' '): modifiers += g + '\n' if channel == 'au': text = text.format(modifiers, lot_id) return [au_id, text, price, status] else: return [au_id, price, status]
async def repeat_channel_messages(message: types.Message): global start_message try: if str(message['chat']['id']) == digest_channel: battle = None search = re.search(r'Битва (\d{2}/\d{2}/\d{4} \d{2}:\d{2})', message['text']) if search: battle_stamp = objects.stamper(search.group(1), delta=3, pattern='%d/%m/%Y %H:%M') if (time_now() - battle_stamp) < 1800 and ( time_now() - dict(message).get('date')) < 1800: battle = Auth.time(battle_stamp, form='normal', sep='/', tag=italic, seconds=None) if battle: db = SQL(db_path) users = db.get_users() stamp = datetime.now(tz).timestamp() db.close() coroutines = [ sender(message, user=user, func=bot.forward_message, id=user['id']) for user in users ] await asyncio.gather(*coroutines) text = bold( chats_to_human( len(users), round(datetime.now(tz).timestamp() - stamp, 3))) start_message = Auth.message( old_message=start_message, text=f"\n\nСводки {battle}:\n{text}") else: if str(message['chat']['id']) not in channels: db = SQL(db_path) text, log_text = None, None user = db.get_user(message['chat']['id']) if user is None: text, log_text = first_start(message), ' [#Впервые]' await sender(message, user=user, text=text, log_text=log_text) db.close() except IndexError and Exception: await Auth.dev.async_except(message)
def repeat_all_messages(message): try: if message.chat.id in allowed_persons: if message.text.startswith('https://t.me/'): post = posting(message.text, int(datetime.now().timestamp())) post_media(post, idChannelFilter, likes(white_like, 0, 0)) elif message.text.startswith('/mem'): search = re.search(r'(\d+) (\d+)', message.text) if search: goodies( int(datetime.now().timestamp()) - int(search.group(1)) * 60 * 60, int(search.group(2))) bot.send_message(message.chat.id, bold('Выполнено успешно ✅'), parse_mode='HTML') else: bot.send_message(message.chat.id, bold('херня какая-то ❌'), parse_mode='HTML') elif message.text == '/update': global main1, channels, channels_post main1 = gspread.service_account('person1.json').open( 'memes').worksheet('main') channels_post = main1.col_values(2) channels = main1.col_values(1) bot.send_message(message.chat.id, bold('Обновлено успешно ✅'), parse_mode='HTML') elif message.text.startswith('/log'): bot.send_document(idMe, open('log.txt', 'rt')) else: bot.send_message(message.chat.id, bold('ссылка не подошла'), 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') 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 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 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 goodies(stamp, number): global main1 goodies_raw = [] empty_channels = '' for i in channels: imp = 0 channel_db = [] post_channel = i limiter_point = 0 post_stamp = stamp post_id = int(channels_post[channels.index(i)]) post_stag = copy.copy(post_id) post_last = copy.copy(post_id) post_stag_limiter = post_id * 0.01 if post_stag_limiter < 40: post_stag_limiter = 40 elif post_stag_limiter > 70: post_stag_limiter = 70 while imp <= 10: post = posting(post_channel + str(post_id), stamp) if post['links'] != [] and post['viewers'] != 'None' and post[ 'stamp'] != 'None': if post['stamp'] != -1: channel_db.append(post) post_last = post_id imp = 0 elif post['links'] == [] and post['viewers'] == 'None' and post[ 'stamp'] == 'None': if post_stag == post_id: post_last -= 1 imp += 1 post_id += 1 post_last += 1 if post_stag != post_last: try: main1.update_cell(channels.index(i) + 1, 2, post_last) except IndexError and Exception: main1 = gspread.service_account('person1.json').open( 'memes').worksheet('main') main1.update_cell(channels.index(i) + 1, 2, post_last) while post_stamp >= stamp: post_stag -= 1 post_back = posting(post_channel + str(post_stag), stamp) if post_back['links'] != [] and post_back[ 'viewers'] != 'None' and post_back['stamp'] != 'None': limiter_point = 0 if post_back['stamp'] != 'None': post_stamp = post_back['stamp'] if post_back['stamp'] != -1: channel_db.append(post_back) else: limiter_point += 1 if limiter_point > post_stag_limiter: break channel_db.sort(key=lambda arr: arr['viewers']) if len(channel_db) % 2 == 0 and len(channel_db) != 0: lot1 = channel_db[len(channel_db) // 2]['viewers'] lot2 = channel_db[len(channel_db) // 2 - 1]['viewers'] median = int(round((lot1 + lot2) / 2, 2)) elif len(channel_db) == 0: median = 0 else: median = channel_db[len(channel_db) // 2]['viewers'] if len(channel_db) > 0: good_post = channel_db[len(channel_db) - 1] if median != 0: good_post['median'] = good_post['viewers'] / median else: good_post['median'] = 0 goodies_raw.append(good_post) else: empty_channels += '\n' + post_channel goodies_raw.sort(key=lambda arr: arr['median']) good_posting = list(reversed(goodies_raw)) if len(good_posting) <= number: for i in good_posting: post_media(i, idChannelFilter, likes(white_like, 0, 0)) else: for i in range(0, number): post_media(good_posting[i], idChannelFilter, likes(white_like, 0, 0)) if len(empty_channels) > 0: bot.send_message(idMe, bold('Никаких постов от:') + empty_channels, parse_mode='HTML')
def tut_quest(pub_link): req = requests.get(pub_link, headers=headers) soup = BeautifulSoup(req.text, 'html.parser') growing = {} for i in starting: growing[i] = 'none' title = soup.find('div', class_='vacancy-title') if title is not None: if title.find('h1') is not None: tag = '' headline = re.sub(r'\s+', ' ', title.find('h1').get_text()) growing['title'] = headline headline = re.sub('/', ' / ', headline) headline = re.sub(r'\(.*?\)|[+.,/]|г\.', '', headline.lower()) headline = re.sub('e-mail', 'email', re.sub(r'\s+', ' ', headline)) headline = re.sub(r'[\s-]', '_', headline.strip().capitalize()) for i in re.split('(_)', headline): if len(tag) <= 20: tag += i if tag.endswith('_'): tag = tag[:-1] growing['tags'] = [tag] place = soup.find('div', class_='vacancy-address-text') if place is not None: metro = '' metro_array = place.find_all('span', class_='metro-station') for i in metro_array: metro += re.sub(r'\s+', ' ', i.get_text().strip() + ', ') if metro != '': growing['metro'] = metro[:-2] growing['place'] = re.sub( metro, '', re.sub(r'\s+', ' ', place.get_text()).strip()) short_place = soup.find_all('span') if short_place is not None: for i in short_place: if str(i).find('vacancy-view-raw-address') != -1: search = re.search('<!-- -->(.*?)<!-- -->', str(i)) if search: growing['short_place'] = re.sub( r'\s+', ' ', search.group(1).capitalize().strip()) break if growing['short_place'] == 'none': short_place = soup.find('div', class_='vacancy-company') if short_place is not None: short_place = short_place.find('p') if short_place is not None: growing['short_place'] = re.sub( r'\s+', ' ', short_place.get_text().capitalize().strip()) geo_search = re.search('{"lat": (.*?), "lng": (.*?), "zoom"', str(soup)) if geo_search: growing['geo'] = re.sub(r'\s', '', geo_search.group(1)) + ',' + re.sub( r'\s', '', geo_search.group(2)) money = soup.find('p', class_='vacancy-salary') if money is not None: money_array = [] money = re.sub(r'\s', '', money.get_text().lower()) search_ot = re.search(r'от(\d+)', money) search_do = re.search(r'до(\d+)', money) if search_do: money_array.append(search_do.group(1)) money_array.append('none') elif search_ot: money_array.append(search_ot.group(1)) money_array.append('more') else: money_array = 'none' growing['money'] = money_array org_name = soup.find('a', {'data-qa': 'vacancy-company-name'}) if org_name is not None: growing['org_name'] = re.sub(r'\s+', ' ', org_name.get_text().strip()) description = soup.find('div', class_='g-user-content') if description is not None: description = description.find_all(['p', 'ul', 'strong']) tempering = [] main = '' prev = '' for i in description: text = '' lists = i.find_all('li') if len(lists) != 0: for g in lists: text += '🔹 ' + re.sub('\n', '', g.get_text().capitalize()) + '\n' else: temp = i.get_text().strip() if prev != temp: if temp.endswith(':'): text += '\n✅ ' + bold(temp) + '\n' else: tempering.append(temp) prev = temp main += text main = main[:-1] if len(tempering) > 0: main += '\n\n' for i in tempering: main += i + '\n' growing['description'] = main numbers = '' items = soup.find_all(['p', 'a', 'span']) for i in items: search = re.search('data-qa="vacancy-view-employment-mode"', str(i)) if search: schedule_text = '' schedule = i.find('span') if schedule is not None: schedule_text = re.sub(r'\s+', ' ', schedule.get_text().strip()) growing['schedule'] = re.sub( 'график', '', schedule_text).strip().capitalize() employment = re.sub(r'\s+', ' ', i.get_text().lower()) employment = re.sub(',|занятость|' + schedule_text, '', employment).strip().capitalize() growing['employment'] = employment search = re.search('data-qa="vacancy-experience"', str(i)) if search: growing['experience'] = re.sub(r'\s+', ' ', i.get_text().strip()) search = re.search('data-qa="vacancy-contacts__fio"', str(i)) if search: growing['contact'] = re.sub(r'\s+', ' ', i.get_text().strip()) search = re.search('data-qa="vacancy-contacts__email"', str(i)) if search: growing['email'] = re.sub(r'\s+', ' ', i.get_text().strip()) search = re.search('data-qa="vacancy-contacts__phone"', str(i)) if search: if numbers.find(re.sub(r'\s+', ' ', i.get_text().strip())) == -1: numbers += re.sub(r'\s+', ' ', i.get_text().strip()) + '\n' if numbers != '': growing['numbers'] = numbers[:-1] return [pub_link, growing]
def hh_quest(pub_link): req = requests.get(pub_link, headers=headers) soup = BeautifulSoup(req.text, 'html.parser') growing = {} for i in starting: growing[i] = 'none' title = soup.find('div', class_='vacancy-title') if title is not None: if title.find('h1') is not None: tag = '' headline = re.sub(r'\s+', ' ', title.find('h1').get_text()) growing['title'] = headline headline = re.sub('/', ' / ', headline) headline = re.sub(r'\(.*?\)|[+.,/]|г\.', '', headline.lower()) headline = re.sub('e-mail', 'email', re.sub(r'\s+', ' ', headline)) headline = re.sub(r'[\s-]', '_', headline.strip().capitalize()) headline = re.sub('_+', '_', headline) for i in re.split('(_)', headline): if len(tag) <= 20: tag += i if tag.endswith('_'): tag = tag[:-1] growing['tags'] = [tag] place = soup.find('div', class_='vacancy-address-text') if place is not None: metro = '' metro_array = place.find_all('span', class_='metro-station') for i in metro_array: metro += re.sub(r'\s+', ' ', i.get_text().strip() + ', ') if metro != '': growing['metro'] = metro[:-2] growing['place'] = re.sub(metro, '', re.sub(r'\s+', ' ', place.get_text()).strip()) short_place = soup.find_all('span') if short_place is not None: for i in short_place: if str(i).find('vacancy-view-raw-address') != -1: search = re.search('<!-- -->(.*?)<!-- -->', str(i)) if search: growing['short_place'] = re.sub(r'\s+', ' ', search.group(1).capitalize().strip()) break if growing['short_place'] == 'none': short_place = soup.find('div', class_='vacancy-company') if short_place is not None: short_place = short_place.find('p') if short_place is not None: growing['short_place'] = re.sub(r'\s+', ' ', short_place.get_text().capitalize().strip()) geo_search = re.search('{"lat": (.*?), "lng": (.*?), "zoom"', str(soup)) if geo_search: growing['geo'] = re.sub(r'\s', '', geo_search.group(1)) + ',' + re.sub(r'\s', '', geo_search.group(2)) money = soup.find('p', class_='vacancy-salary') if money is not None: money_array = [] money = re.sub(r'\s', '', money.get_text().lower()) search_currency = re.search(r'(usd|eur|бел\.)', money) search_ot = re.search(r'от(\d+)', money) search_do = re.search(r'до(\d+)', money) if search_do: money_array.append(search_do.group(1)) money_array.append('none') elif search_ot: money_array.append(search_ot.group(1)) money_array.append('more') else: money_array = 'none' if search_currency: if search_currency.group(1) == 'eur': money_array.append(' евро.') elif search_currency.group(1) == 'usd': money_array.append(' долларов.') else: money_array.append(' бел. руб.') else: money_array.append(' руб.') growing['money'] = money_array org_name = soup.find('a', {'data-qa': 'vacancy-company-name'}) if org_name is not None: growing['org_name'] = re.sub(r'\s+', ' ', org_name.get_text().strip()) description = soup.find('div', class_='g-user-content') if description is not None: description = description.find_all(['p', 'ul', 'strong']) memory = [] main = '' for i in description: text = '' lists = i.find_all('li') if len(lists) != 0 and len(memory) != 0: if memory[len(memory) - 1] in allowed_head_elements: for g in lists: list_element = re.sub('\n', '', g.get_text()) if len(list_element) > 1: text += '🔹 ' list_element = re.sub(',', ', ', list_element) list_element = re.sub('<', '<', list_element) list_element = re.sub(r'\s+', ' ', list_element).strip() list_element = re.sub(r'\s*?,\s*?', ',', list_element) list_element = re.sub(r'\s*?;\s*?', ';', list_element) list_element = re.sub(r'\s*?\.\s*?', '.', list_element) list_element = list_element[:1].capitalize() + list_element[1:] if list_element.endswith(';') is False: list_element += ';' if list_element not in memory: text += list_element + '\n' memory.append(list_element) text = re.sub(r'\.+', '.', text[:-2] + '.\n') else: head_element = re.sub(r'\s', '_', i.get_text()).lower() head_element = re.sub(r'\W', '', head_element) head_element = re.sub('_+', ' ', head_element) head_element = re.sub('<', '<', head_element) if head_element in allowed_head_elements and head_element not in memory: text += '\n✅ ' + bold(head_element.capitalize() + ':\n') memory.append(head_element) main += text growing['description'] = main numbers = '' items = soup.find_all(['p', 'a', 'span']) for i in items: search = re.search('data-qa="vacancy-view-employment-mode"', str(i)) if search: schedule_text = '' schedule = i.find('span') if schedule is not None: schedule_text = re.sub(r'\s+', ' ', schedule.get_text().strip()) growing['schedule'] = re.sub('график', '', schedule_text).strip().capitalize() employment = re.sub(r'\s+', ' ', i.get_text().lower()) employment = re.sub(',|занятость|' + schedule_text, '', employment).strip().capitalize() growing['employment'] = employment search = re.search('data-qa="vacancy-experience"', str(i)) if search: growing['experience'] = re.sub(r'\s+', ' ', i.get_text().strip()) search = re.search('data-qa="vacancy-contacts__fio"', str(i)) if search: growing['contact'] = re.sub(r'\s+', ' ', i.get_text().strip()) search = re.search('data-qa="vacancy-contacts__email"', str(i)) if search: growing['email'] = re.sub(r'\s+', ' ', i.get_text().strip()) search = re.search('data-qa="vacancy-contacts__phone"', str(i)) if search: if numbers.find(re.sub(r'\s+', ' ', i.get_text().strip())) == -1: numbers += re.sub(r'\s+', ' ', i.get_text().strip()) + '\n' if numbers != '': growing['numbers'] = numbers[:-1] return [growing, pub_link]
def former(growing, pub_link, background_coefficient): text = '' money = None keys = post_keys(e_post) 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)) if growing['money'] != 'none': more = '' if growing['money'][1] != 'none': more += '+' money = numeric_replace(int(growing['money'][0])) + more if growing['money'][2] == ' евро.': money += u' \u20AC ' elif growing['money'][2] == ' бел. руб.': money += ' бел. руб. ' elif growing['money'][2] == ' долларов.': money += u' \u0024 ' else: money += u' \u20BD ' growing['tag_picture'] = image(re.sub(r'[—\s-]', ' ', text_to_image.strip()), money, background_coefficient) text = growing['tag_picture'] + '👨🏻💻 ' + bold(growing['title']) + '\n' if growing['experience'] != 'none': text += '🏅 Опыт работы ➡ ' + growing['experience'].capitalize() + '\n' if growing['education'] != 'none': text += '👨🎓 Образование ➡ ' + growing['education'].capitalize() + '\n' if money: text += '💸 ' + bold('З/П ') + str(money) + '\n' if growing['description'] != 'none': text += '{}\n' text += bold('📔 Контакты\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['metro'] != 'none': text += '🚇 ' + growing['metro'] + '\n' if growing['geo'].lower() != 'none': text += '\n📍 http://maps.yandex.ru/?text=' + growing['geo'] + '\n' text += '\n🔎 ' + pub_link + '\n' if growing['tags'] != 'none': text += objects.italic('\n💼ТЕГИ: ') for i in growing['tags']: text += '#' + i + ' ' text = text[:-1] + '\n' if growing['description'] != 'none': len_text = 4094 - len(text) if len_text - len(growing['description']) >= 0: text = text.format(growing['description']) else: text = text.format(growing['description'][:len_text]) text += '————\nРазместить вакансию @Superworksbot' text += instagram_image(instagram_former(growing), background_coefficient) if growing['short_place'] == 'none' or growing['money'] == 'none' or growing['title'] == 'none': text = pub_link return [text, keys, pub_link, growing]
else: values = None sleep(1) return values start_search = objects.query('https://t.me/UsefullCWLinks/' + str(start_link), 'd: (.*) :d') used_array = google('moscow-growing', 'col_values', 1) Auth = objects.AuthCentre(os.environ['TOKEN']) bot = Auth.start_main_bot('non-sync') executive = Auth.thread_exec if start_search: last_date = stamper(start_search.group(1)) - 3 * 60 * 60 Auth.start_message(stamp1) else: last_date = '\nОшибка с нахождением номера поста. ' + bold('Бот выключен') Auth.start_message(stamp1, last_date) _thread.exit() # ==================================================================================== def hour(): return int(datetime.utcfromtimestamp(objects.time_now() + 3 * 60 * 60).strftime('%H')) def post_keys(em): posts_row = types.InlineKeyboardMarkup(row_width=1) button = [types.InlineKeyboardButton(text=em, callback_data='post')] posts_row.add(*button) return posts_row
async def repeat_all_messages(message: types.Message): try: db = SQL(db_path) user = db.get_user(message['chat']['id']) if user: keyboard = keys.folders() text, response, log_text = None, None, True if message['text'].startswith('/'): if message['text'].lower().startswith('/st'): text = 'Добро пожаловать, снова' if message['chat']['id'] == idMe: if message['text'].lower().startswith('/info'): text = '' images = db.get_images() now = Auth.logs.time(form='iso', tag=bold) for image in images: name = re.sub('images/', '', image['path']) last_update = Auth.logs.time(image['last_update'], tag=bold, form='iso') text += f'{name}: {last_update}\n' text += f"{code('-' * 30)}\nСейчас: {now}" elif message['text'].lower().startswith('/logs'): text = Auth.logs.text() elif message['text'].lower().startswith('/reboot'): text, log_text = Auth.logs.reboot(dispatcher) elif message['text'].lower().startswith('/new'): response = True await Auth.async_message(bot.send_photo, id=message['chat']['id'], path='images/alt.jpg') elif message['text'].lower().startswith('/reload'): text = 'Успешно отправлено:' query = "SELECT id FROM users WHERE reaction = '✅' AND NOT id = 0" users = db.request(query) for target_user in users: text += f"\n{target_user['id']}" await Auth.async_message(bot.send_message, id=target_user['id'], text=bold('Бот обновлен'), keyboard=keys.folders()) if message['text'].lower().startswith('/remove'): await bot.send_message( message['chat']['id'], bold('Окей'), reply_markup=types.ReplyKeyboardRemove(True), parse_mode='HTML') elif message['text'].lower().startswith('f'): text = bold('Пример сообщения') elif message['text'].lower().startswith('h'): text = 'Выбор таймфрейма' keyboard = keys.frames() await sender(message, user, text, keyboard, log_text=log_text) if text is None and response is None: task = Auth.async_bot.forward_message await Auth.logs.async_message(task, id=Auth.logs.dump_chat_id, message=message) else: text, keyboard = first_start(message) await sender(message, user, text, keyboard, log_text=' [#Впервые]') db.close() except IndexError and Exception: await Auth.dev.async_except(message)
import os import re import objects import _thread import requests from time import sleep from bs4 import BeautifulSoup from objects import bold, code, italic, stamper, printer, html_link stamp1 = objects.time_now() title = objects.bold('⛳Сводки с полей:') + '\n' main_address = 'https://t.me/ChatWarsDigest/' mini_address = 'https://t.me/CWDigest/' castles = '(🐢|☘|🌹|🍁|🦇|🖤|🍆)' idChannel = -1001492730228 idMe = 396978030 e_trident = '🔱' battle_emoji = { 'со значительным преимуществом': '⚔😎', 'разыгралась настоящая бойня, но все-таки силы атакующих были ': '⚔⚡', 'легко отбились от': '🛡👌', 'героически отразили ': '🛡⚡', 'скучали, на них ': '🛡😴', 'успешно отбились от': '🛡', 'успешно атаковали защитников': '⚔' } start_search = objects.query('https://t.me/UsefullCWLinks/4?embed=1', r'CW3: (\d+) :CW3.mini: (\d+) :mini.d: (.*) :d') Auth = objects.AuthCentre(os.environ['TOKEN']) bot = Auth.start_main_bot('non-async')
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]