r/ModCoord • • Jun 12 '23

Here's a Python Modmail Auto Responder to declutter your modmail.

Edit: This bot is now on github so it can be improved by the community. https://github.com/notesbot/auto_respond

import praw
import time

# Create a Reddit instance
reddit = praw.Reddit(
    client_id="",
    client_secret="",
    password="",
    user_agent="",
    username=""
)



sub_name = "YOUR_SUBREDDIT"
keywords = ['private', 'blackout', 'dark', 'closed', 'join',  'shut down']
response_message = "Hello and thank you for your message.  It appears that you are writing in about the Reddit wide blackout to protest API changes. We would like to direct you to [this post](https://www.reddit.com/r/Save3rdPartyApps/comments/1476ioa/reddit_blackout_2023_save_3rd_party_apps/) where you can find, among other information, a list of participating subreddits. While we appreciate your interest in this topic, at this time we are not commenting via modmail on this. Please help us keep our modmail clear for urgent information.  Thank you for your cooperation.\n\nIf your issue was resolved, please just ignore this message.\n\n- If your issue was not resolved, we apologize.  Please respond to this message to send it back to the top of our queue.  Neither Reddit's modmail system nor Reddit's moderators are perfect, so sometimes we overlook modmail tickets.\n\n Thank you" 



processed_mail = []

while True:
try:
	print("Fetching modmail conversations...")
	conversations = reddit.subreddit(sub_name).mod.stream.modmail_conversations(skip_existing=True)

	for conv in conversations:
		if len([author for author in conv.authors if author.is_admin]) > 0:
				reddit.redditor("mod_mailer").message(subject=f"{conv.owner}", message =f"New Admin modmail in r/{conv.owner}\n\n---\n\nNew modmail message from admins https://mod.reddit.com/mail/all/{conv.id}\n\nSubject: {conv.subject}")
				conv.archive()

		if conv.id not in processed_mail:		
			for message in conv.messages:
				body = message.body_markdown.lower()
				if any(keyword in body for keyword in keywords):
					print(f"Found modmail in r/{conv.owner} - keyword in message with ID {conv.id} from user {conv.user.name}")
					
					conv.reply(body=response_message, author_hidden=True)
					conv.archive()
					processed_mail.append(conv.id)
					print(f"Replied to message ID {conv.id} from user {conv.user.name} with the preset response\n")
					#print(processed_mail)
except Exception as e:
	print(f"An error occurred: {e}")
	print("Sleeping for 60 seconds before retrying...")
	time.sleep(60)
151 Upvotes

96 comments sorted by

View all comments

0

u/[deleted] Jun 12 '23

[deleted] — view deleted comment

17

u/patman21 Jun 12 '23

Same here. It's interesting...

0

u/[deleted] Jun 12 '23

[deleted] — view deleted comment

11

u/CirrusVision20 Jun 12 '23

Getting them too. The VAST majority of them are bot-like users.

→ More replies (3)

16

u/Hydroquake_Vortex Jun 12 '23

I think these are lurkers. Probably 90% of subreddits are lurkers, with 9% being commenters, and 1% being posters

0

u/[deleted] Jun 12 '23

[deleted] — view deleted comment

7

u/Hydroquake_Vortex Jun 12 '23

It’s possible they could be bots, but maybe they just made an account thinking they had to to access the subreddit. On r/humblebundles, we’ve seen several people request access, but they all have accounts that were made awhile ago.

0

u/[deleted] Jun 12 '23

[deleted] — view deleted comment

4

u/Hydroquake_Vortex Jun 12 '23

Yeah no problem, hopefully other subs aren’t having a similar problem with seemingly bot requests.

On another note, seeing requests from (real) people that normally say nothing is pretty nice. It really shows that our communities are appreciated beyond just the comments or even the upvotes.

→ More replies (5)

4

u/[deleted] Jun 12 '23

It’s likely a mix of both. Some users being confused as well as bots trying to guilt trip mods into reopening.

3

u/TheSheDM Jun 12 '23

Depending on the sub's content, I suspect the wording might look weird on some because of non-english speakers using google translate and whatnot. I'm mod on a 200k sub for a niche hobby. We don't usually get a lot of bots. We're now getting lots of join requests from obvious lurker accounts (low karma, multiple years old) as well as new accounts. Some of them have specifically mentioned to us that they are not native english speakers are are using translate to inquire what happened.

My sub shares just images mostly without text and is popular worldwide so it makes sense to me that our sub has lots of non-english lurkers. Apps like RIF don't require an account to just browse so it also makes sense some folks have never bothered to sign up until they couldn't access the sub and didn't know what was happening because they couldn't read the announcement posts.

→ More replies (3)
→ More replies (1)

8

u/LogicWavelength Jun 12 '23 edited Jun 12 '23

r/watches mod here. SO MANY are bot accounts with 1 karma, no posts, no comments. Most were created in 2020 or 2022. The usernames follow “word_word_number” schema, mostly with underscores or hyphens but sometimes not:

I really wonder if they are comment bots that just parse all of Reddit, or if this is some sort of campaign going on. It’s literally thousands of accounts at this point and we’ve only been dark for like 4 hours. We are in the top 500 subs, and have 1.83 million subscribers, so I think our sub is attracting a substantial number of these.

If anyone is interested in collecting all this for some sort of investigation, I’m all about it.

7

u/chaseoes Jun 12 '23

Those are just the default usernames suggested by reddit. Try to sign up for a new account and you'll see.

0

u/[deleted] Jun 12 '23

[deleted] — view deleted comment

5

u/LogicWavelength Jun 12 '23

That naming scheme is just some Reddit feature where when people signup now it suggest a username.

I figured that was it, but does it switch between hyphen and underscore? And use varying amounts of words (some are 3 words, some are two)?

And like I said, the majority we’ve been getting the past few hours have been at least 1-3 years old - but the last 45 mins or so it’s been mostly brand new (like, minutes old) accounts.

→ More replies (3)
→ More replies (11)

4

u/MangyCanine Jun 12 '23

Sadly, it makes you wonder how many of our members are bots ...

→ More replies (4)

6

u/WhoKnowsWho2 Jun 12 '23

Yup, the bots can't post spam if they aren't accepted lol

4

u/heartofcoal Jun 12 '23

yes, several bot requests, but i've never closed the sub before so i don't know if it's normal or not

→ More replies (1)

3

u/[deleted] Jun 12 '23

Maybe spammers that bought old accounts

2

u/verydumbbell Jun 12 '23

yeah same here, probably people finding the subs right now due to protest or making new accounts thinking they’re banned. happened quite a lot in modmail

2

u/PM_MeYourEars Jun 12 '23 edited Jun 12 '23

Same issue. A lot of them are accounts which don’t seem to be very active and rarely post, some don’t seem to have posted on our sub before now, both newer and older accounts.

We are directing everyone elsewhere, but they dont seem to be actually going to those other places so far. Nor have any of them replied to the message from the team.

I think a big big part of this is, shocker, the reddit app and mobile site. Since desktop will display the messages we have all put for our community and in the community description. But mobile gets:

”The moderators of have set this community as private. Only approved members can view and take part in its discussions.”

In other words, mobile users are still left in the dark. They cant actually see whats going on, this is probably part of the cause here and just further proves why we need either the api’s back or a better mobile/app.

3

u/PentaOwl Jun 12 '23

Another reason why the Reddit app sucks balls lol

Can't even see what happened to a sub

→ More replies (1)

3

u/FizixMan Jun 12 '23

I think a big big part of this is, shocker, the reddit app and mobile site. Since desktop will display the messages we have all put for our community and in the community description. But mobile gets:

Even on desktop, the "new" GUI message is garbage. It truncates the message (for some STUPID reason given it has all the space in the world) like this: https://i.imgur.com/ukh6rlx.png

Then even if you click on it to expand the text, it IGNORES the markdown formatting and doesn't even give you clickable links: https://i.imgur.com/QMVLnAu.png

This is how it looks in "old" reddit: https://i.imgur.com/YRSnb7K.png

And even then, we had to limit our formatting and URL links because of that "new" GUI garbage, it would just show all the markdown formatting. (Also edited for length... why such a ridiculously small limit on characters?)

Screw the Reddit leadership and how they completely half-ass everything they do.

→ More replies (10)
→ More replies (26)