コード例 #1
0
ファイル: app.py プロジェクト: sh3hz/reddit2telegram
#encoding:utf-8

from utils import weighted_random_subreddit

subreddit = weighted_random_subreddit({
    'thedivision': 1.0,
})
t_channel = '@r_thedivision'

def send_post(submission, r2t):
    return r2t.send_simple(submission,
        min_upvotes_limit=20,
        text=True,
        gif=True,
        img=True,
        album=True,
        other=False
    )
コード例 #2
0
ファイル: app.py プロジェクト: zephray/reddit2telegram
    'ImaginaryAirships', 'ImaginaryAviation', 'ImaginaryArmor',
    'ImaginaryCybernetics', 'ImaginaryCyberpunk', 'ImaginaryFutureWar',
    'ImaginaryFuturism', 'ImaginaryMechs', 'ImaginaryPortals',
    'ImaginaryRobotics', 'ImaginaryStarships', 'ImaginarySteampunk',
    'ImaginaryVehicles', 'ImaginaryVessels', 'ImaginaryWarships',
    'ImaginaryWeaponry', 'ImaginaryAww', 'ImaginaryBestOf',
    'ImaginaryColorscapes', 'ImaginaryFeels', 'ImaginaryHistory',
    'ImaginaryMaps', 'ImaginaryPets', 'ImaginarySliceofLife',
    'ImaginaryNetwork', 'ImaginaryTurtleWorlds', 'ImaginaryUnofficial',
    'ImaginaryWTF'
]

weight = 1. / len(opts)

# Subreddit that will be a source of content
subreddit = weighted_random_subreddit({k: weight for k in opts})

t_channel = '@r_imaginary_network'

# r_imaginary_wastelands


def send_post(submission, r2t):
    return r2t.send_simple(submission,
                           min_upvotes_limit=20,
                           text=False,
                           gif=False,
                           img=True,
                           album=False,
                           other=False)
コード例 #3
0
#encoding:utf-8

from utils import weighted_random_subreddit

subreddit = weighted_random_subreddit({
    'raspberry_pi': 1.0,
})
t_channel = '@r_raspberry_pi'


def send_post(submission, r2t):
    return r2t.send_simple(submission,
                           min_upvotes_limit=5,
                           text=True,
                           gif=True,
                           video=True,
                           img=True,
                           album=True,
                           other=False)
コード例 #4
0
ファイル: app.py プロジェクト: dahongpa0/reddit2telegram
#encoding:utf-8

from utils import weighted_random_subreddit

# Subreddit that will be a source of content
subreddit = weighted_random_subreddit({
    'grandorder': 1.0,
    # If we want get content from several subreddits
    # please provide here 'subreddit': probability
    # 'any_other_subreddit': 0.02
})
# Telegram channel with @reddit2telegram_bot as an admin
t_channel = '@r_grandorder'


def send_post(submission, r2t):
    return r2t.send_simple(
        submission,
        # Submission should have at least min_upvotes_limit upvotes.
        min_upvotes_limit=10,
        # If you do not want text submissions, just pass False.
        text=True,
        # If you want gifs, just pass True or text you want under gif.
        gif='{title}\n{short_link}',
        # If you want images, just pass True or text you want under image.
        img='{title}\n{short_link}',
        # If you want albums, just pass True or text you want under albums.
        album=True,
        # If you do not want othe submissions, just pass False.
        other=True)
コード例 #5
0
ファイル: app.py プロジェクト: aaronayalew/reddit2telegram
#encoding:utf-8

from utils import weighted_random_subreddit


subreddit = weighted_random_subreddit({
    'theofficememes': 1.0,
})
t_channel = '@r_theofficememes


def send_post(submission, r2t):
    return r2t.send_simple(submission,
        min_upvotes_limit=50,
        text=False,
        gif=True,
        video=True,
        img=True,
        album=True,
        other=False
    )
コード例 #6
0
subreddit = weighted_random_subreddit({
    'AbandonedPorn': 593,
    'AdPorn': 90,
    'AdrenalinePorn': 146,
    'AerialPorn': 20,
    'AgriculturePorn': 12,
    'AlbumArtPorn': 50,
    'AnimalPorn': 85,
    'ApocalypsePorn': 14,
    'ArchitecturePorn': 205,
    'ArtPorn': 177,
    'ArtefactPorn': 202,
    'AutumnPorn': 18,
    'Beachporn': 9,
    'BonsaiPorn': 9,
    'BotanicalPorn': 38,
    'CabinPorn': 59,
    'CemeteryPorn': 23,
    'CityPorn': 328,
    'ClimbingPorn': 22,
    'ComicBookPorn': 7,
    'ConcertPorn': 2,
    'CulinaryPorn': 18,
    'DesignPorn': 355,
    'DessertPorn': 46,
    'DestructionPorn': 58,
    'EarthPorn': 7000,
    'EarthlingPorn': 5,
    'ExposurePorn': 194,
    'F1Porn': 24,
    'FirePorn': 31,
    'FoodPorn': 868,
    'FossilPorn': 11,
    'FractalPorn': 24,
    'GamerPorn': 11,
    'GeekPorn': 34,
    'GunPorn': 81,
    'HellscapePorn': 9,
    'HistoryPorn': 894,
    'Houseporn': 54,
    'HumanPorn': 176,
    'InfraredPorn': 6,
    'InfrastructurePorn': 73,
    'InstrumentPorn': 17,
    'Knifeporn': 11,
    'MachinePorn': 189,
    'MacroPorn': 89,
    'MapPorn': 451,
    'MegalithPorn': 12,
    'MetalPorn': 11,
    'MicroPorn': 34,
    'MilitaryPorn': 173,
    'MotorcyclePorn': 17,
    'MoviePosterPorn': 96,
    'MushroomPorn': 8,
    'NewsPorn': 28,
    'OrganizationPorn': 22,
    'QuotesPorn': 200,
    'RetroGamePorn': 4,
    'RidesPorn': 5,
    'RoomPorn': 721,
    'SkyPorn': 65,
    'SportsPorn': 5,
    'SpringPorn': 5,
    'StarshipPorn': 21,
    'StreetArtPorn': 28,
    'SummerPorn': 5,
    'TeaPorn': 12,
    'TechnologyPorn': 22,
    'TelevisionPosterPorn': 6,
    'ThingsCutInHalfPorn': 234,
    'VideoPorn': 11,
    'ViewPorn': 10,
    'VillagePorn': 60,
    'WeatherPorn': 16,
    'avporn': 12,
    'boatporn': 15,
    'bookporn': 48,
    'bridgeporn': 7,
    'carporn': 362,
    'churchporn': 8,
    'desertporn': 6,
    'fashionporn': 14,
    'futureporn': 106,
    'geologyporn': 26,
    'lakeporn': 5,
    'lavaporn': 8,
    'mtgporn': 13,
    'policeporn': 15,
    'powerwashingporn': 301,
    'retailporn': 4,
    'ruralporn': 24,
    'seaporn': 20,
    'spaceflightporn': 10,
    'spaceporn': 543,
    'stadiumporn': 5,
    'steamporn': 4,
    'toolporn': 16,
    'uniformporn': 8,
    'waterporn': 73,
    'winterporn': 47
})
コード例 #7
0
ファイル: app.py プロジェクト: zephray/reddit2telegram
#encoding:utf-8

from utils import weighted_random_subreddit

t_channel = '@news756'
subreddit = weighted_random_subreddit({'politics': 0.5, 'news': 0.5})


def send_post(submission, r2t):
    return r2t.send_simple(
        submission,
        text='{title}\n\n{self_text}\n\n/r/{subreddit_name}\n{short_link}',
        gif='{title}\n\n/r/{subreddit_name}\n{short_link}',
        img='{title}\n\n/r/{subreddit_name}\n{short_link}',
        album='{title}\n{link}\n\n/r/{subreddit_name}\n{short_link}',
        other='{title}\n{link}\n\n/r/{subreddit_name}\n{short_link}')
コード例 #8
0
#encoding:utf-8

from utils import weighted_random_subreddit

subreddit = weighted_random_subreddit({
    'CoolGithubProjects': 1,
    'coolcstechtalks': 1
})
t_channel = '@r_CoolGithubProjects'


def send_post(submission, r2t):
    return r2t.send_simple(submission)
コード例 #9
0
ファイル: app.py プロジェクト: Fillll/reddit2telegram
#encoding:utf-8

from urllib.parse import urlparse

from utils import get_url, weighted_random_subreddit
from utils import SupplyResult


t_channel = '@ya_metro'
subreddit = weighted_random_subreddit({'Subways': 0.6,
    'LondonUnderground': 0.4,
    'Trams': 0.3
})


def send_post(submission, r2t):
    what, url = get_url(submission)
    title = submission.title
    link = submission.shortlink
    text = '{}\n{}'.format(title, link)

    if what == 'text':
        if submission.score >= 4:
            punchline = submission.selftext
            text = '{title}\n\n{body}\n\n{link}'.format(
                title=title, body=punchline, link=link)
            return r2t.send_text(text, disable_web_page_preview=True)
        else:
            return SupplyResult.DO_NOT_WANT_THIS_SUBMISSION
    elif what == 'album':
        base_url = submission.url
コード例 #10
0
#encoding:utf-8

from utils import get_url, weighted_random_subreddit

subreddit = weighted_random_subreddit({
    'Cinemagraphs': 0.25,
    'BetterEveryLoop': 0.25,
    'interestingasfuck': 0.25,
    'gifs': 0.25
})
t_channel = '@rddit'


def send_post(submission, r2t):
    what, url, ext = get_url(submission)

    title = submission.title
    link = submission.shortlink
    text = '{}\n{}'.format(title, link)

    if what == 'text':
        return False
    elif what == 'other':
        return False
    elif what == 'album':
        base_url = submission.url
        text = '{}\n{}\n\n{}'.format(title, base_url, link)
        r2t.send_text(text)
        r2t.send_album(url)
        return True
    elif what in ('gif', 'img'):
コード例 #11
0
subreddit = weighted_random_subreddit({
    'HistoryPorn': 0.5,
    'ArchivePorn': 0.01,
    # /r/ADifferentEra
    'BattlePaintings': 0.02,
    'BiographyFilms': 0.005,
    'Castles': 0.04,
    'Colorization': 0.1,
    'ColorizedHistory': 0.02,
    # /r/CombatFootage
    'FortPorn': 0.01,
    # /r/History
    # /r/HistoryNetwork
    'ImagesOfHistory': 0.005,
    'ImaginaryHistory': 0.005,
    'ImaginaryPolitics': 0.005,
    # /r/MapIt
    'MegalithPorn': 0.005,
    'OldIndia': 0.005,
    'OldSchoolCool': 0.15,
    'OldSchoolCreepy': 0.005,
    'Presidents': 0.005,
    'PropagandaPosters': 0.1,
    'RedditThroughHistory': 0.005,
    # /r/RestofHistoryPorn
    'TheWayWeWere': 0.01,
    'WarshipPorn': 0.02,
    'WWIIPics': 0.02,
    # /r/WWIIPlanes
    'ColdWarPosters': 0.005
})
コード例 #12
0
#encoding:utf-8

from utils import weighted_random_subreddit

t_channel = '@pythondaily'
subreddit = weighted_random_subreddit({
    'flask': 3,
    'Python': 6,
    'django': 4,
    'MachineLearning': 1,
    'djangolearning': 1,
    'IPython': 5,
    'pystats': 4,
    'JupyterNotebooks': 3
})


def send_post(submission, r2t):
    info = submission.selftext
    lwords = info.split(' ')[:200]
    words = ' '.join(lwords)
    return r2t.send_simple(
        submission,
        text='{title}\n\n' + words + '\n\n/r/{subreddit_name}\n{short_link}',
        gif='{title}\n\n/r/{subreddit_name}\n{short_link}',
        img='{title}\n\n/r/{subreddit_name}\n{short_link}',
        album='{title}\n{link}\n\n/r/{subreddit_name}\n{short_link}',
        other='{title}\n{link}\n\n/r/{subreddit_name}\n{short_link}')
コード例 #13
0
ファイル: app.py プロジェクト: zephray/reddit2telegram
#encoding:utf-8

from utils import weighted_random_subreddit

t_channel = '@r_bitcoin'
subreddit = weighted_random_subreddit({'btc': 0.0, 'bitcoin': 1.0})


def send_post(submission, r2t):
    return r2t.send_simple(submission)
コード例 #14
0
ファイル: app.py プロジェクト: zephray/reddit2telegram
#encoding:utf-8

from urllib.parse import urlparse

from utils import get_url, weighted_random_subreddit
from utils import SupplyResult

t_channel = '@denpasong'
subreddit = weighted_random_subreddit({
    'denpa': 0.5,
    'denpasong': 0.5,
})


def send_post(submission, r2t):
    what, url, ext = get_url(submission)
    title = submission.title
    link = submission.shortlink
    text = '{}\n{}'.format(title, link)

    if what == 'text':
        return SupplyResult.DO_NOT_WANT_THIS_SUBMISSION
    elif what == 'album':
        return SupplyResult.DO_NOT_WANT_THIS_SUBMISSION
    elif what == 'other':
        domain = urlparse(url).netloc
        if domain in ('www.youtube.com', 'youtu.be'):
            text = '{}\n{}\n\n{}'.format(title, url, link)
            return r2t.send_text(text)
        else:
            return SupplyResult.DO_NOT_WANT_THIS_SUBMISSION