New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Subreddit.Posts.MonitorNew() starts in the same place every time #117
Comments
Looking at the source, it seems like Reddit.NET/src/Reddit.NET/Controllers/SubredditPosts.cs Lines 562 to 566 in ae1267b
I am wondering if modifying my run function to call
private void Run()
{
var _reddit = Client.create();
var sub = _reddit.Subreddit("PublicFreakout").About();
_ = sub.Posts.GetNew();
sub.Posts.NewUpdated += Posts_NewUpdated;
sub.Posts.MonitorNew();
} |
Follow up: yes, retrieving new, discarding, and then subscribing to the new feed has this working as intended. |
@kyleratti did you happen to experience the same post being monitored multiple times? |
Could you clarify what you mean or provide an example? Once I started retrieving all of the posts before monitoring, things worked as expected. |
@Alleyuuki hmmm - I can't say I have noticed that. The only thing I could think of is I am calling var sub = redditClient.Subreddit("MySub").About(); |
even with .About(); the same post comes trough multiple times, i might open an issue for this |
Calling About() is not required for monitoring to work; you should only
call it if you need to populate the Subreddit controller instance with that
subreddit's metadata, which is not required for monitoring.
Could you include the code you're using to generate that list of links?
Also, is the same post coming up twice in the same event or is it coming up
again in subsequent events? I've noticed that monitoring sorts like Hot
and Controversial can get tricky because the Reddit API will sometimes
return a different set of posts on one query, another slightly different
set the next, then back to the first or some third one. As a result, the
monitoring algo can be fooled into alerting the same post multiple times,
which I'm guessing is probably what's happening in your case.
This can be resolved by keeping track of permalinks that have already come
up and ignoring them on subsequent events. The monitoring was mainly
designed for the New sort, so at some point we'll probably want to make
some improvements to compensate for this on the other sorts.
…On Wed, Jan 13, 2021 at 6:40 AM Alleyuuki ***@***.***> wrote:
@Alleyuuki <https://github.com/Alleyuuki> hmmm - I can't say I have
noticed that. The only thing I could think of is I am calling .About() on
the subreddit controller before using it to monitor:
var sub = redditClient.Subreddit("MySub").About();
even with .About(); the same post comes trough multiple times, i might
open an issue for this
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#117 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFTJZL4PY2DAMOEQ6MHCNDSZWWGPANCNFSM4VSASNLQ>
.
|
hi @sirkris thanks for the explanation,
can the |
Nope it doesn't have to be static to consume the event. As for the class
var, I'd recommend going with a HashSet<string> instead of List<string> for
performance reasons.
…On Wed, Jan 13, 2021 at 7:12 AM Alleyuuki ***@***.***> wrote:
hi @sirkris <https://github.com/sirkris> thanks for the explanation,
here is my code
https://github.com/Alleyuuki/RedditToTelegram/blob/master/RedditToTelegram/Program.cs#L47
the multiple posts are coming in in different events, i tought of keeping
track of permalinks too, im fairly new with c# language soo my next
question might be silly but,
_ = sub.Posts.GetHot();
sub.Posts.HotUpdated += C_postsUpdated;
sub.Posts.MonitorHot();
can the C_postsUpdated function not be a static function? so i can access
a list of permaLinks that will be a class variable?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#117 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAFTJZMGO3HDVQ37K7W2YP3SZWZ4TANCNFSM4VSASNLQ>
.
|
I just merged in some changes that should fix this. I basically implemented the caching we discussed here. You don't have to do anything differently to make use of it. I made caching enabled by default. You can disable it by passing The latest changes are available on the develop branch. Could you check it out and let me know if this fixed your issue? Thanks! |
Linked against |
I am using Reddit.NET to monitor submissions to a subreddit. It seems, however, that every time my application starts it is retrieving a list of submissions from the same point in time and firing the
NewUpdated
event for each of them.Every time the application starts, it will immediately fire the
NewUpdated
event for the same reddit post.I suspect this isn't a bug and I am misunderstanding something and that is causing the bot to authenticate in a certain state/point of time wherein those posts are new, but I'd appreciate any guidance! I've been looking at this for a little while now and am stumped.
Thanks
PS - this is a wonderful library and I am grateful to your hard work on it!
The text was updated successfully, but these errors were encountered: