Documentation

SubReddit
in package

Table of Contents

BaseURL  = 'https://www.reddit.com/r/'
The base reddit.com URL for SubReddit(s)
URLAppendix  = '/new.json?sort=new&limit='
The final part of the reddit.com API(s)
$LastTitle  : string
The title of the last sent post
$SubRedditName  : string
The SubReddit name you want to track
$Bot  : Bot
The Novagram\Bot object instance
$ChatID  : int
The Telegram ChatID of a chat (group|channel)
$limit  : int|null
The number of posts to retrieve
$RequestURL  : string
The actual URL that will be used to perform requests to Reddit API(s)
__construct()  : mixed
SubReddit constructor
Poll()  : void
Checks for new posts, and if so, send them
SetSubRedditPostsLimit()  : void
Set the amount of posts to retrieve from a subreddit
CheckNewPost()  : bool
Check whether there's a new post
GetJSON()  : array<string|int, mixed>
Do a request to reddit api(s) and get a json
PostIsPhoto()  : bool
Check if post is a photo
PostIsVideo()  : bool
Check if post is a video
SendPost()  : void
Send post to the Telegram chat (group/channel)

Constants

BaseURL

The base reddit.com URL for SubReddit(s)

private string BaseURL = 'https://www.reddit.com/r/'

URLAppendix

The final part of the reddit.com API(s)

private string URLAppendix = '/new.json?sort=new&limit='

Properties

$LastTitle

The title of the last sent post

public string $LastTitle = " "

$SubRedditName

The SubReddit name you want to track

public string $SubRedditName

$Bot

The Novagram\Bot object instance

private Bot $Bot

$ChatID

The Telegram ChatID of a chat (group|channel)

private int $ChatID

$limit

The number of posts to retrieve

private int|null $limit

$RequestURL

The actual URL that will be used to perform requests to Reddit API(s)

private string $RequestURL

Methods

__construct()

SubReddit constructor

public __construct(string $SubRedditName, Bot $Bot, int $ChatID) : mixed
Parameters
$SubRedditName : string

The subreddit name

$Bot : Bot

The NovaGram\Bot instance

$ChatID : int

The Relegram ChatID where posts will be sent

Return values
mixed

Poll()

Checks for new posts, and if so, send them

public final Poll(int $seconds) : void
Parameters
$seconds : int

The amount of seconds to wait before checking for new posts

Return values
void

SetSubRedditPostsLimit()

Set the amount of posts to retrieve from a subreddit

public final SetSubRedditPostsLimit(int $limit) : void
Parameters
$limit : int

The number of posts to retrieve

Return values
void

CheckNewPost()

Check whether there's a new post

private CheckNewPost(int $i) : bool
Parameters
$i : int
Tags
throws
JsonException
Return values
bool

GetJSON()

Do a request to reddit api(s) and get a json

private GetJSON(int $i) : array<string|int, mixed>
Parameters
$i : int
Tags
throws
JsonException
Return values
array<string|int, mixed>

PostIsPhoto()

Check if post is a photo

private PostIsPhoto(int $i) : bool
Parameters
$i : int
Tags
throws
JsonException
Return values
bool

PostIsVideo()

Check if post is a video

private PostIsVideo(int $i) : bool
Parameters
$i : int
Tags
throws
JsonException
Return values
bool

SendPost()

Send post to the Telegram chat (group/channel)

private SendPost() : void
Tags
throws
JsonException
Return values
void

Search results