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

Show parent comment

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

2

u/PM_MeYourEars Jun 12 '23

You cant even fully view the sub rules on the app anymore.

You could swipe across to view them, or you had tabs at the top, both options are gone and instead you get a tiny ‘click here for more info’ where the description is.

This is a train wreck.

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.

0

u/[deleted] Jun 12 '23

[deleted] — view deleted comment

3

u/Umlautica Jun 12 '23

It's visible on the desktop site. Check these in an incognito tab:

Reddit's private subreddit feature is half-baked for mobile. Our team is getting a modmail every couple of minutes.

2

u/PM_MeYourEars Jun 12 '23

Yes its just for mods

0

u/[deleted] Jun 12 '23

[deleted] — view deleted comment

1

u/AutoModerator Jun 12 '23

This comment has been removed because the userping is considered harassing. If you wish to have this comment be visible, please re-comment without the /u/ aspect. Thank you

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

1

u/telchii Jun 13 '23

Wait, are you actually able to see private subs on the mobile app? I tried checking a couple subs I don't mod on the Android app and couldn't even find them.

1

u/PM_MeYourEars Jun 13 '23

Nope. Not unless you mod that specific sub.