Imports Newtonsoft.Json.Linq
Public Class PostsProcessor
Private ReadOnly ApiHandler As New ApiHandler
'''
''' Fetches Reddit posts based on the given parameters and returns them as a JObject.
'''
''' The subreddit to fetch posts from.
''' The type of listing (e.g., "new", "top", etc.).
''' The maximum number of posts to fetch.
''' The timeframe to consider for the posts (e.g., "day", "week", "month", "year", "all").
''' A JObject containing the fetched Reddit posts.
Public Function FetchPosts(subreddit As String, listing As String, limit As Integer, timeframe As String) As JObject
Dim posts As JObject = ApiHandler.ScrapeReddit(subreddit, listing, limit, timeframe)
Return posts
End Function
'''
''' Checks if the given Reddit post contains the given keyword in its text.
'''
''' The Reddit post to check.
''' The keyword to check for.
''' True if the post contains the keyword, False otherwise.
Public Shared Function PostContainsKeyword(post As JObject, keyword As String) As Boolean
Return post("data")("selftext").ToString.ToLower(Globalization.CultureInfo.InvariantCulture).Contains(keyword.ToLower(System.Globalization.CultureInfo.InvariantCulture))
End Function
End Class