Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions sopel/cli/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,7 @@ def find_config(config_dir: str, name: str, extension: str = '.cfg') -> str:
'/home/username/.sopel/extra.ini'

.. versionchanged:: 8.0

Files in the ``config_dir`` are now preferred, and files without the
requested extension are no longer returned.

Expand Down
23 changes: 23 additions & 0 deletions sopel/modules/reddit.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import requests

from sopel import plugin
from sopel.config import types
from sopel.formatting import bold, color, colors
from sopel.tools import time
from sopel.tools.web import USER_AGENT
Expand All @@ -39,6 +40,11 @@
gallery_url = r'https?://(?:www\.)?reddit\.com/gallery/([\w-]+)'


class RedditSection(types.StaticSection):
slash_info = types.BooleanAttribute('slash_info', True)
"""Expand inline references to users (u/someone) and subreddits (r/subname) in chat."""


def setup(bot):
if 'reddit_praw' not in bot.memory:
# Create a PRAW instance just once, at load time
Expand All @@ -48,6 +54,19 @@ def setup(bot):
client_secret=None,
check_for_updates=False,
)
bot.config.define_section('reddit', RedditSection)


def configure(config):
"""
| name | example | purpose |
| ---- | ------- | ------- |
| slash\\_info | off | Whether the bot should expand inline references to users (`u/someone`) or subreddits (`r/subname`) |
"""
config.define_section('reddit', RedditSection)
config.reddit.configure_setting(
'slash_info', "Expand references like u/someone or r/subname in chat?"
)


def shutdown(bot):
Expand Down Expand Up @@ -457,6 +476,10 @@ def get_channel_spoiler_free(bot, trigger):
def reddit_slash_info(bot, trigger):
searchtype = trigger.group('prefix').lower()
match = trigger.group('id')

if not bot.config.reddit.slash_info:
return

if searchtype == "r":
return subreddit_info(bot, trigger, match, commanded=False)
elif searchtype == "u":
Expand Down