Пример #1
0
def send_post(submission, r2t):
    channels_list = get_all_public_channels(r2t)
    newly_active = get_newly_active(r2t, channels_list)
    top_growers = get_top_growers_for_last_week(r2t, channels_list)

    text_to_send = '<b>Weekend news</b>\n\n'
    if len(newly_active) > 0:
        text_to_send += '🎉 Welcome to newly active channels: {channels_list}. 🎈🎈\n\n'.format(
            channels_list=', '.join(newly_active))
    text_to_send += '🏆 Channel of the week: {channel_name}. Join and enjoy!\n\n'.format(
        channel_name=random.choice(channels_list))
    if len(top_growers) > 0:
        text_to_send += '🔥 Hottest channels of the week: {channels}.\n\n'.format(
            channels=', '.join(top_growers))
    list_of_channels = generate_list_of_channels(channels_list,
                                                 random_permutation=False)
    text_to_send += default_ending()
    r2t.send_text(text_to_send, parse_mode='HTML')
    time.sleep(2)
    text_to_send = '⬇️ All active channels:\n{list_of_channels}\n\n'.format(
        list_of_channels='\n'.join(list_of_channels))
    r2t.send_text(text_to_send, parse_mode='HTML')
    time.sleep(2)
    text_to_send = '#️⃣ All tags:\n'
    list_of_tags = list(get_all_tags())
    # random.shuffle(list_of_tags)
    text_to_send += ' '.join(sorted(list_of_tags))
    r2t.send_text(text_to_send, parse_mode='HTML')
    # It's not a proper supply, so just stop.
    return SupplyResult.STOP_THIS_SUPPLY
Пример #2
0
def send_post(submission, r2t):
    channels_list = get_all_public_channels()

    for channel in channels_list:
        bd_party, years = is_birthday_today(r2t, channel)
        if bd_party and years > 0:
            time.sleep(10)
            r2t.t_channel = get_dev_channel()
            plural = 's' if years != 1 else ''
            r2t.send_text('{channel} is {years} year{s} old.'.format(
                channel=channel, years=years, s=plural))
            time.sleep(10)
            r2t.t_channel = channel
            text_to_send = '🎂🎂🎂\nToday {channel} is {years_cnt} year{s} old. '.format(
                channel=channel, years_cnt=years, s=plural)
            text_to_send += 'Congratulations! 🎈🎉🎉\n\n'
            list_of_channels = generate_list_of_channels(
                channels_list, random_permutation=True)
            text_to_send += 'Other channels powered by @r_channels:\n{list_of_channels}\n\n'.format(
                list_of_channels='\n'.join(list_of_channels))
            text_to_send += default_ending()
            r2t.send_text(text_to_send)
            time.sleep(10)
            r2t.t_channel = get_dev_channel()
            r2t.send_text(text_to_send)

    # It's not a proper supply, so just stop.
    return SupplyResult.STOP_THIS_SUPPLY
Пример #3
0
def send_post(submission, r2t):
    channels_list = get_all_public_channels(r2t)

    for submodule_name in get_all_public_submodules():
        submodule = importlib.import_module(
            'channels.{}.app'.format(submodule_name))
        channel = submodule.t_channel
        bd_party, years = is_birthday_today(r2t, channel)
        if bd_party and years > 0:
            plural = 's' if years != 1 else ''
            # To the @r_channels
            long_sleep()
            r2t.t_channel = '@r_channels'
            cakes = '🎂' * years
            text_to_send = '{cake}\n🎁 Today {channel} is {years_cnt} year{s} old.\n🎉 Congratulations! 🎈'.format(
                channel=channel, years_cnt=years, s=plural, cake=cakes)
            r2t.send_text(text_to_send)
            # To the dev channel
            long_sleep()
            r2t.t_channel = get_dev_channel()
            r2t.send_text(text_to_send)
            # To the channels itself
            long_sleep()
            r2t.t_channel = channel
            text1_to_send = text_to_send
            list_of_channels = generate_list_of_channels(
                channels_list, random_permutation=True)
            text3_to_send = default_ending()
            r2t.send_text(text1_to_send)
            short_sleep()
            text2_to_send = 'Other @reddit2telegram channels powered by @r_channels:\n'
            for l in chunker(list_of_channels, 100):
                text2_to_send += '\n'.join(l)
                r2t.send_text(text2_to_send)
                text2_to_send = ''
                short_sleep()
            r2t.send_text(text3_to_send)
            long_sleep()
            if channel != '@reddit2telegram':
                config = get_config()
                send_to_channel_from_subreddit(
                    how_to_post=make_nice_submission,
                    channel_to_post='@reddit2telegram',
                    subreddit=submodule.subreddit,
                    submodule_name_to_promte=submodule_name,
                    submissions_ranking='top',
                    submissions_limit=1000,
                    config=config,
                    extra_args=True,
                    extra_ending=text_to_send)
                long_sleep()
    # It's not a proper supply, so just stop.
    return SupplyResult.STOP_THIS_SUPPLY
Пример #4
0
def send_post(submission, r2t):
    channels_list = get_all_public_channels(r2t)

    for channel in channels_list:
        bd_party, years = is_birthday_today(r2t, channel)
        if bd_party and years > 0:
            plural = 's' if years != 1 else ''
            # To the @r_channels
            time.sleep(10)
            r2t.t_channel = '@r_channels'
            text_to_send = '🎂🎂🎂\nToday {channel} is {years_cnt} year{s} old.\nCongratulations! 🎁'.format(
                channel=channel, years_cnt=years, s=plural)
            r2t.send_text(text_to_send)
            # To the dev channel
            time.sleep(10)
            r2t.t_channel = get_dev_channel()
            r2t.send_text(text_to_send)
            # To the channels itself
            time.sleep(10)
            r2t.t_channel = channel
            text1_to_send = '🎂🎂🎂\nToday {channel} is {years_cnt} year{s} old. '.format(
                channel=channel, years_cnt=years, s=plural)
            text1_to_send += 'Congratulations! 🎈🎉🎉\n\n'
            list_of_channels = generate_list_of_channels(channels_list, random_permutation=True)
            text3_to_send = default_ending()
            r2t.send_text(text1_to_send)
            time.sleep(2)
            text2_to_send = 'Other @reddit2telegram channels powered by @r_channels:\n'
            for l in chunker(list_of_channels, 100):
                text2_to_send += '\n'.join(l)
                r2t.send_text(text2_to_send)
                text2_to_send = ''
                time.sleep(2)
            r2t.send_text(text3_to_send)
            # To the dev channel again
            time.sleep(10)
            r2t.t_channel = get_dev_channel()
            r2t.send_text(text1_to_send)
            time.sleep(2)
            text2_to_send = 'Other @reddit2telegram channels powered by @r_channels:\n'
            for l in chunker(list_of_channels, 100):
                text2_to_send += '\n'.join(l)
                r2t.send_text(text2_to_send)
                text2_to_send = ''
                time.sleep(2)
            r2t.send_text(text3_to_send)

    # It's not a proper supply, so just stop.
    return SupplyResult.STOP_THIS_SUPPLY