We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
reddit: shortlinks are not handled
Reddit supports (and promotes in the comments page sidebar) a short link format for threads, `http(s)://redd.it/{id}`, where the `id` comes from here in a full-size link: `https://www.reddit.com/r/subreddit/comments/{id}/slugified_thread_title/`.

It should be trivial to add detection and handling of these links in the `reddit` module.

Not assigning to a milestone immediately, because I'd like to release this in a hypothetical version 6.7.0 *if* one happens before 7.0 (but none is planned). It does seem slightly more significant a change than would belong in one of the planned 6.6.x releases, unfortunately.

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `sopel/modules/reddit.py`
Content:
```
1 # coding=utf-8
2 # Author: Elsie Powell, embolalia.com
3 from __future__ import unicode_literals, absolute_import, print_function, division
4 
5 from sopel.module import commands, rule, example, require_chanmsg, NOLIMIT, OP
6 from sopel.formatting import bold, color, colors
7 from sopel.web import USER_AGENT
8 from sopel.tools import time
9 import datetime as dt
10 import praw
11 import re
12 import sys
13 if sys.version_info.major >= 3:
14     unicode = str
15     if sys.version_info.minor >= 4:
16         from html import unescape
17     else:
18         from html.parser import HTMLParser
19         unescape = HTMLParser().unescape
20 else:
21     from HTMLParser import HTMLParser
22     unescape = HTMLParser().unescape
23 
24 
25 domain = r'https?://(?:www\.|old\.|pay\.|ssl\.|[a-z]{2}\.)?reddit\.com'
26 post_url = r'%s/r/(.*?)/comments/([\w-]+)' % domain
27 user_url = r'%s/u(ser)?/([\w-]+)' % domain
28 post_regex = re.compile(post_url)
29 user_regex = re.compile(user_url)
30 spoiler_subs = [
31     'stevenuniverse',
32     'onepunchman',
33 ]
34 
35 
36 def setup(bot):
37     bot.register_url_callback(post_regex, rpost_info)
38     bot.register_url_callback(user_regex, redditor_info)
39 
40 
41 def shutdown(bot):
42     bot.unregister_url_callback(post_regex)
43     bot.unregister_url_callback(user_regex)
44 
45 
46 @rule('.*%s.*' % post_url)
47 def rpost_info(bot, trigger, match=None):
48     match = match or trigger
49     try:
50         r = praw.Reddit(
51             user_agent=USER_AGENT,
52             client_id='6EiphT6SSQq7FQ',
53             client_secret=None,
54         )
55         s = r.submission(id=match.group(2))
56     except Exception:
57         r = praw.Reddit(user_agent=USER_AGENT)
58         s = r.get_submission(submission_id=match.group(2))
59 
60     message = ('[REDDIT] {title} {link}{nsfw} | {points} points ({percent}) | '
61                '{comments} comments | Posted by {author} | '
62                'Created at {created}')
63 
64     subreddit = s.subreddit.display_name
65     if s.is_self:
66         link = '(self.{})'.format(subreddit)
67     else:
68         link = '({}) to r/{}'.format(s.url, subreddit)
69 
70     if s.over_18:
71         if subreddit.lower() in spoiler_subs:
72             nsfw = bold(color(' [SPOILERS]', colors.RED))
73         else:
74             nsfw = bold(color(' [NSFW]', colors.RED))
75 
76         sfw = bot.db.get_channel_value(trigger.sender, 'sfw')
77         if sfw:
78             link = '(link hidden)'
79             bot.write(['KICK', trigger.sender, trigger.nick,
80                        'Linking to NSFW content in a SFW channel.'])
81     else:
82         nsfw = ''
83 
84     if s.author:
85         author = s.author.name
86     else:
87         author = '[deleted]'
88 
89     tz = time.get_timezone(bot.db, bot.config, None, trigger.nick,
90                            trigger.sender)
91     time_created = dt.datetime.utcfromtimestamp(s.created_utc)
92     created = time.format_time(bot.db, bot.config, tz, trigger.nick,
93                                trigger.sender, time_created)
94 
95     if s.score > 0:
96         point_color = colors.GREEN
97     else:
98         point_color = colors.RED
99 
100     percent = color(unicode(s.upvote_ratio * 100) + '%', point_color)
101 
102     title = unescape(s.title)
103     message = message.format(
104         title=title, link=link, nsfw=nsfw, points=s.score, percent=percent,
105         comments=s.num_comments, author=author, created=created)
106 
107     bot.say(message)
108 
109 
110 # If you change this, you'll have to change some other things...
111 @commands('redditor')
112 @example('.redditor poem_for_your_sprog')
113 def redditor_info(bot, trigger, match=None):
114     """Show information about the given Redditor"""
115     commanded = re.match(bot.config.core.prefix + 'redditor', trigger)
116     r = praw.Reddit(
117         user_agent=USER_AGENT,
118         client_id='6EiphT6SSQq7FQ',
119         client_secret=None,
120     )
121     match = match or trigger
122     try:
123         u = r.get_redditor(match.group(2))
124     except Exception:  # TODO: Be specific
125         if commanded:
126             bot.say('No such Redditor.')
127             return NOLIMIT
128         else:
129             return
130         # Fail silently if it wasn't an explicit command.
131 
132     message = '[REDDITOR] ' + u.name
133     now = dt.datetime.utcnow()
134     cakeday_start = dt.datetime.utcfromtimestamp(u.created_utc)
135     cakeday_start = cakeday_start.replace(year=now.year)
136     day = dt.timedelta(days=1)
137     year_div_by_400 = now.year % 400 == 0
138     year_div_by_100 = now.year % 100 == 0
139     year_div_by_4 = now.year % 4 == 0
140     is_leap = year_div_by_400 or ((not year_div_by_100) and year_div_by_4)
141     if (not is_leap) and ((cakeday_start.month, cakeday_start.day) == (2, 29)):
142         # If cake day is 2/29 and it's not a leap year, cake day is 1/3.
143         # Cake day begins at exact account creation time.
144         is_cakeday = cakeday_start + day <= now <= cakeday_start + (2 * day)
145     else:
146         is_cakeday = cakeday_start <= now <= cakeday_start + day
147 
148     if is_cakeday:
149         message = message + ' | 13Cake day'
150     if commanded:
151         message = message + ' | https://reddit.com/u/' + u.name
152     if u.is_gold:
153         message = message + ' | 08Gold'
154     if u.is_mod:
155         message = message + ' | 05Mod'
156     message = message + (' | Link: ' + str(u.link_karma) +
157                          ' | Comment: ' + str(u.comment_karma))
158 
159     bot.say(message)
160 
161 
162 # If you change the groups here, you'll have to change some things above.
163 @rule('.*%s.*' % user_url)
164 def auto_redditor_info(bot, trigger):
165     redditor_info(bot, trigger)
166 
167 
168 @require_chanmsg('.setsfw is only permitted in channels')
169 @commands('setsafeforwork', 'setsfw')
170 @example('.setsfw true')
171 @example('.setsfw false')
172 def update_channel(bot, trigger):
173     """
174     Sets the Safe for Work status (true or false) for the current
175     channel. Defaults to false.
176     """
177     if bot.channels[trigger.sender].privileges[trigger.nick] < OP:
178         return
179     else:
180         param = 'true'
181         if trigger.group(2) and trigger.group(3):
182             param = trigger.group(3).strip().lower()
183         sfw = param == 'true'
184         bot.db.set_channel_value(trigger.sender, 'sfw', sfw)
185         if sfw:
186             bot.reply('Got it. %s is now flagged as SFW.' % trigger.sender)
187         else:
188             bot.reply('Got it. %s is now flagged as NSFW.' % trigger.sender)
189 
190 
191 @commands('getsafeforwork', 'getsfw')
192 @example('.getsfw [channel]')
193 def get_channel_sfw(bot, trigger):
194     """
195     Gets the preferred channel's Safe for Work status, or the current
196     channel's status if no channel given.
197     """
198     channel = trigger.group(2)
199     if not channel:
200         channel = trigger.sender
201         if channel.is_nick():
202             return bot.say('.getsfw with no channel param is only permitted in channels')
203 
204     channel = channel.strip()
205 
206     sfw = bot.db.get_channel_value(channel, 'sfw')
207     if sfw:
208         bot.say('%s is flagged as SFW' % channel)
209     else:
210         bot.say('%s is flagged as NSFW' % channel)
211
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/sopel/modules/reddit.py b/sopel/modules/reddit.py
--- a/sopel/modules/reddit.py
+++ b/sopel/modules/reddit.py
@@ -23,9 +23,11 @@
 
 
 domain = r'https?://(?:www\.|old\.|pay\.|ssl\.|[a-z]{2}\.)?reddit\.com'
-post_url = r'%s/r/(.*?)/comments/([\w-]+)' % domain
+post_url = r'%s/r/.*?/comments/([\w-]+)' % domain
+short_post_url = r'https?://redd.it/([\w-]+)'
 user_url = r'%s/u(ser)?/([\w-]+)' % domain
 post_regex = re.compile(post_url)
+short_post_regex = re.compile(short_post_url)
 user_regex = re.compile(user_url)
 spoiler_subs = [
     'stevenuniverse',
@@ -35,15 +37,18 @@
 
 def setup(bot):
     bot.register_url_callback(post_regex, rpost_info)
+    bot.register_url_callback(short_post_regex, rpost_info)
     bot.register_url_callback(user_regex, redditor_info)
 
 
 def shutdown(bot):
     bot.unregister_url_callback(post_regex)
+    bot.unregister_url_callback(short_post_regex)
     bot.unregister_url_callback(user_regex)
 
 
 @rule('.*%s.*' % post_url)
+@rule('.*%s.*' % short_post_url)
 def rpost_info(bot, trigger, match=None):
     match = match or trigger
     try:
@@ -52,10 +57,10 @@
             client_id='6EiphT6SSQq7FQ',
             client_secret=None,
         )
-        s = r.submission(id=match.group(2))
+        s = r.submission(id=match.group(1))
     except Exception:
         r = praw.Reddit(user_agent=USER_AGENT)
-        s = r.get_submission(submission_id=match.group(2))
+        s = r.get_submission(submission_id=match.group(1))
 
     message = ('[REDDIT] {title} {link}{nsfw} | {points} points ({percent}) | '
                '{comments} comments | Posted by {author} | '

{"golden_diff": "diff --git a/sopel/modules/reddit.py b/sopel/modules/reddit.py\n--- a/sopel/modules/reddit.py\n+++ b/sopel/modules/reddit.py\n@@ -23,9 +23,11 @@\n \n \n domain = r'https?://(?:www\\.|old\\.|pay\\.|ssl\\.|[a-z]{2}\\.)?reddit\\.com'\n-post_url = r'%s/r/(.*?)/comments/([\\w-]+)' % domain\n+post_url = r'%s/r/.*?/comments/([\\w-]+)' % domain\n+short_post_url = r'https?://redd.it/([\\w-]+)'\n user_url = r'%s/u(ser)?/([\\w-]+)' % domain\n post_regex = re.compile(post_url)\n+short_post_regex = re.compile(short_post_url)\n user_regex = re.compile(user_url)\n spoiler_subs = [\n     'stevenuniverse',\n@@ -35,15 +37,18 @@\n \n def setup(bot):\n     bot.register_url_callback(post_regex, rpost_info)\n+    bot.register_url_callback(short_post_regex, rpost_info)\n     bot.register_url_callback(user_regex, redditor_info)\n \n \n def shutdown(bot):\n     bot.unregister_url_callback(post_regex)\n+    bot.unregister_url_callback(short_post_regex)\n     bot.unregister_url_callback(user_regex)\n \n \n @rule('.*%s.*' % post_url)\n+@rule('.*%s.*' % short_post_url)\n def rpost_info(bot, trigger, match=None):\n     match = match or trigger\n     try:\n@@ -52,10 +57,10 @@\n             client_id='6EiphT6SSQq7FQ',\n             client_secret=None,\n         )\n-        s = r.submission(id=match.group(2))\n+        s = r.submission(id=match.group(1))\n     except Exception:\n         r = praw.Reddit(user_agent=USER_AGENT)\n-        s = r.get_submission(submission_id=match.group(2))\n+        s = r.get_submission(submission_id=match.group(1))\n \n     message = ('[REDDIT] {title} {link}{nsfw} | {points} points ({percent}) | '\n                '{comments} comments | Posted by {author} | '\n", "issue": "reddit: shortlinks are not handled\nReddit supports (and promotes in the comments page sidebar) a short link format for threads, `http(s)://redd.it/{id}`, where the `id` comes from here in a full-size link: `https://www.reddit.com/r/subreddit/comments/{id}/slugified_thread_title/`.\n\nIt should be trivial to add detection and handling of these links in the `reddit` module.\n\nNot assigning to a milestone immediately, because I'd like to release this in a hypothetical version 6.7.0 *if* one happens before 7.0 (but none is planned). It does seem slightly more significant a change than would belong in one of the planned 6.6.x releases, unfortunately.\n", "before_files": [{"content": "# coding=utf-8\n# Author: Elsie Powell, embolalia.com\nfrom __future__ import unicode_literals, absolute_import, print_function, division\n\nfrom sopel.module import commands, rule, example, require_chanmsg, NOLIMIT, OP\nfrom sopel.formatting import bold, color, colors\nfrom sopel.web import USER_AGENT\nfrom sopel.tools import time\nimport datetime as dt\nimport praw\nimport re\nimport sys\nif sys.version_info.major >= 3:\n    unicode = str\n    if sys.version_info.minor >= 4:\n        from html import unescape\n    else:\n        from html.parser import HTMLParser\n        unescape = HTMLParser().unescape\nelse:\n    from HTMLParser import HTMLParser\n    unescape = HTMLParser().unescape\n\n\ndomain = r'https?://(?:www\\.|old\\.|pay\\.|ssl\\.|[a-z]{2}\\.)?reddit\\.com'\npost_url = r'%s/r/(.*?)/comments/([\\w-]+)' % domain\nuser_url = r'%s/u(ser)?/([\\w-]+)' % domain\npost_regex = re.compile(post_url)\nuser_regex = re.compile(user_url)\nspoiler_subs = [\n    'stevenuniverse',\n    'onepunchman',\n]\n\n\ndef setup(bot):\n    bot.register_url_callback(post_regex, rpost_info)\n    bot.register_url_callback(user_regex, redditor_info)\n\n\ndef shutdown(bot):\n    bot.unregister_url_callback(post_regex)\n    bot.unregister_url_callback(user_regex)\n\n\n@rule('.*%s.*' % post_url)\ndef rpost_info(bot, trigger, match=None):\n    match = match or trigger\n    try:\n        r = praw.Reddit(\n            user_agent=USER_AGENT,\n            client_id='6EiphT6SSQq7FQ',\n            client_secret=None,\n        )\n        s = r.submission(id=match.group(2))\n    except Exception:\n        r = praw.Reddit(user_agent=USER_AGENT)\n        s = r.get_submission(submission_id=match.group(2))\n\n    message = ('[REDDIT] {title} {link}{nsfw} | {points} points ({percent}) | '\n               '{comments} comments | Posted by {author} | '\n               'Created at {created}')\n\n    subreddit = s.subreddit.display_name\n    if s.is_self:\n        link = '(self.{})'.format(subreddit)\n    else:\n        link = '({}) to r/{}'.format(s.url, subreddit)\n\n    if s.over_18:\n        if subreddit.lower() in spoiler_subs:\n            nsfw = bold(color(' [SPOILERS]', colors.RED))\n        else:\n            nsfw = bold(color(' [NSFW]', colors.RED))\n\n        sfw = bot.db.get_channel_value(trigger.sender, 'sfw')\n        if sfw:\n            link = '(link hidden)'\n            bot.write(['KICK', trigger.sender, trigger.nick,\n                       'Linking to NSFW content in a SFW channel.'])\n    else:\n        nsfw = ''\n\n    if s.author:\n        author = s.author.name\n    else:\n        author = '[deleted]'\n\n    tz = time.get_timezone(bot.db, bot.config, None, trigger.nick,\n                           trigger.sender)\n    time_created = dt.datetime.utcfromtimestamp(s.created_utc)\n    created = time.format_time(bot.db, bot.config, tz, trigger.nick,\n                               trigger.sender, time_created)\n\n    if s.score > 0:\n        point_color = colors.GREEN\n    else:\n        point_color = colors.RED\n\n    percent = color(unicode(s.upvote_ratio * 100) + '%', point_color)\n\n    title = unescape(s.title)\n    message = message.format(\n        title=title, link=link, nsfw=nsfw, points=s.score, percent=percent,\n        comments=s.num_comments, author=author, created=created)\n\n    bot.say(message)\n\n\n# If you change this, you'll have to change some other things...\n@commands('redditor')\n@example('.redditor poem_for_your_sprog')\ndef redditor_info(bot, trigger, match=None):\n    \"\"\"Show information about the given Redditor\"\"\"\n    commanded = re.match(bot.config.core.prefix + 'redditor', trigger)\n    r = praw.Reddit(\n        user_agent=USER_AGENT,\n        client_id='6EiphT6SSQq7FQ',\n        client_secret=None,\n    )\n    match = match or trigger\n    try:\n        u = r.get_redditor(match.group(2))\n    except Exception:  # TODO: Be specific\n        if commanded:\n            bot.say('No such Redditor.')\n            return NOLIMIT\n        else:\n            return\n        # Fail silently if it wasn't an explicit command.\n\n    message = '[REDDITOR] ' + u.name\n    now = dt.datetime.utcnow()\n    cakeday_start = dt.datetime.utcfromtimestamp(u.created_utc)\n    cakeday_start = cakeday_start.replace(year=now.year)\n    day = dt.timedelta(days=1)\n    year_div_by_400 = now.year % 400 == 0\n    year_div_by_100 = now.year % 100 == 0\n    year_div_by_4 = now.year % 4 == 0\n    is_leap = year_div_by_400 or ((not year_div_by_100) and year_div_by_4)\n    if (not is_leap) and ((cakeday_start.month, cakeday_start.day) == (2, 29)):\n        # If cake day is 2/29 and it's not a leap year, cake day is 1/3.\n        # Cake day begins at exact account creation time.\n        is_cakeday = cakeday_start + day <= now <= cakeday_start + (2 * day)\n    else:\n        is_cakeday = cakeday_start <= now <= cakeday_start + day\n\n    if is_cakeday:\n        message = message + ' | \u0002\u000313Cake day\u0003\u0002'\n    if commanded:\n        message = message + ' | https://reddit.com/u/' + u.name\n    if u.is_gold:\n        message = message + ' | \u0002\u000308Gold\u0003\u0002'\n    if u.is_mod:\n        message = message + ' | \u0002\u000305Mod\u0003\u0002'\n    message = message + (' | Link: ' + str(u.link_karma) +\n                         ' | Comment: ' + str(u.comment_karma))\n\n    bot.say(message)\n\n\n# If you change the groups here, you'll have to change some things above.\n@rule('.*%s.*' % user_url)\ndef auto_redditor_info(bot, trigger):\n    redditor_info(bot, trigger)\n\n\n@require_chanmsg('.setsfw is only permitted in channels')\n@commands('setsafeforwork', 'setsfw')\n@example('.setsfw true')\n@example('.setsfw false')\ndef update_channel(bot, trigger):\n    \"\"\"\n    Sets the Safe for Work status (true or false) for the current\n    channel. Defaults to false.\n    \"\"\"\n    if bot.channels[trigger.sender].privileges[trigger.nick] < OP:\n        return\n    else:\n        param = 'true'\n        if trigger.group(2) and trigger.group(3):\n            param = trigger.group(3).strip().lower()\n        sfw = param == 'true'\n        bot.db.set_channel_value(trigger.sender, 'sfw', sfw)\n        if sfw:\n            bot.reply('Got it. %s is now flagged as SFW.' % trigger.sender)\n        else:\n            bot.reply('Got it. %s is now flagged as NSFW.' % trigger.sender)\n\n\n@commands('getsafeforwork', 'getsfw')\n@example('.getsfw [channel]')\ndef get_channel_sfw(bot, trigger):\n    \"\"\"\n    Gets the preferred channel's Safe for Work status, or the current\n    channel's status if no channel given.\n    \"\"\"\n    channel = trigger.group(2)\n    if not channel:\n        channel = trigger.sender\n        if channel.is_nick():\n            return bot.say('.getsfw with no channel param is only permitted in channels')\n\n    channel = channel.strip()\n\n    sfw = bot.db.get_channel_value(channel, 'sfw')\n    if sfw:\n        bot.say('%s is flagged as SFW' % channel)\n    else:\n        bot.say('%s is flagged as NSFW' % channel)\n", "path": "sopel/modules/reddit.py"}], "after_files": [{"content": "# coding=utf-8\n# Author: Elsie Powell, embolalia.com\nfrom __future__ import unicode_literals, absolute_import, print_function, division\n\nfrom sopel.module import commands, rule, example, require_chanmsg, NOLIMIT, OP\nfrom sopel.formatting import bold, color, colors\nfrom sopel.web import USER_AGENT\nfrom sopel.tools import time\nimport datetime as dt\nimport praw\nimport re\nimport sys\nif sys.version_info.major >= 3:\n    unicode = str\n    if sys.version_info.minor >= 4:\n        from html import unescape\n    else:\n        from html.parser import HTMLParser\n        unescape = HTMLParser().unescape\nelse:\n    from HTMLParser import HTMLParser\n    unescape = HTMLParser().unescape\n\n\ndomain = r'https?://(?:www\\.|old\\.|pay\\.|ssl\\.|[a-z]{2}\\.)?reddit\\.com'\npost_url = r'%s/r/.*?/comments/([\\w-]+)' % domain\nshort_post_url = r'https?://redd.it/([\\w-]+)'\nuser_url = r'%s/u(ser)?/([\\w-]+)' % domain\npost_regex = re.compile(post_url)\nshort_post_regex = re.compile(short_post_url)\nuser_regex = re.compile(user_url)\nspoiler_subs = [\n    'stevenuniverse',\n    'onepunchman',\n]\n\n\ndef setup(bot):\n    bot.register_url_callback(post_regex, rpost_info)\n    bot.register_url_callback(short_post_regex, rpost_info)\n    bot.register_url_callback(user_regex, redditor_info)\n\n\ndef shutdown(bot):\n    bot.unregister_url_callback(post_regex)\n    bot.unregister_url_callback(short_post_regex)\n    bot.unregister_url_callback(user_regex)\n\n\n@rule('.*%s.*' % post_url)\n@rule('.*%s.*' % short_post_url)\ndef rpost_info(bot, trigger, match=None):\n    match = match or trigger\n    try:\n        r = praw.Reddit(\n            user_agent=USER_AGENT,\n            client_id='6EiphT6SSQq7FQ',\n            client_secret=None,\n        )\n        s = r.submission(id=match.group(1))\n    except Exception:\n        r = praw.Reddit(user_agent=USER_AGENT)\n        s = r.get_submission(submission_id=match.group(1))\n\n    message = ('[REDDIT] {title} {link}{nsfw} | {points} points ({percent}) | '\n               '{comments} comments | Posted by {author} | '\n               'Created at {created}')\n\n    subreddit = s.subreddit.display_name\n    if s.is_self:\n        link = '(self.{})'.format(subreddit)\n    else:\n        link = '({}) to r/{}'.format(s.url, subreddit)\n\n    if s.over_18:\n        if subreddit.lower() in spoiler_subs:\n            nsfw = bold(color(' [SPOILERS]', colors.RED))\n        else:\n            nsfw = bold(color(' [NSFW]', colors.RED))\n\n        sfw = bot.db.get_channel_value(trigger.sender, 'sfw')\n        if sfw:\n            link = '(link hidden)'\n            bot.write(['KICK', trigger.sender, trigger.nick,\n                       'Linking to NSFW content in a SFW channel.'])\n    else:\n        nsfw = ''\n\n    if s.author:\n        author = s.author.name\n    else:\n        author = '[deleted]'\n\n    tz = time.get_timezone(bot.db, bot.config, None, trigger.nick,\n                           trigger.sender)\n    time_created = dt.datetime.utcfromtimestamp(s.created_utc)\n    created = time.format_time(bot.db, bot.config, tz, trigger.nick,\n                               trigger.sender, time_created)\n\n    if s.score > 0:\n        point_color = colors.GREEN\n    else:\n        point_color = colors.RED\n\n    percent = color(unicode(s.upvote_ratio * 100) + '%', point_color)\n\n    title = unescape(s.title)\n    message = message.format(\n        title=title, link=link, nsfw=nsfw, points=s.score, percent=percent,\n        comments=s.num_comments, author=author, created=created)\n\n    bot.say(message)\n\n\n# If you change this, you'll have to change some other things...\n@commands('redditor')\n@example('.redditor poem_for_your_sprog')\ndef redditor_info(bot, trigger, match=None):\n    \"\"\"Show information about the given Redditor\"\"\"\n    commanded = re.match(bot.config.core.prefix + 'redditor', trigger)\n    r = praw.Reddit(\n        user_agent=USER_AGENT,\n        client_id='6EiphT6SSQq7FQ',\n        client_secret=None,\n    )\n    match = match or trigger\n    try:\n        u = r.get_redditor(match.group(2))\n    except Exception:  # TODO: Be specific\n        if commanded:\n            bot.say('No such Redditor.')\n            return NOLIMIT\n        else:\n            return\n        # Fail silently if it wasn't an explicit command.\n\n    message = '[REDDITOR] ' + u.name\n    now = dt.datetime.utcnow()\n    cakeday_start = dt.datetime.utcfromtimestamp(u.created_utc)\n    cakeday_start = cakeday_start.replace(year=now.year)\n    day = dt.timedelta(days=1)\n    year_div_by_400 = now.year % 400 == 0\n    year_div_by_100 = now.year % 100 == 0\n    year_div_by_4 = now.year % 4 == 0\n    is_leap = year_div_by_400 or ((not year_div_by_100) and year_div_by_4)\n    if (not is_leap) and ((cakeday_start.month, cakeday_start.day) == (2, 29)):\n        # If cake day is 2/29 and it's not a leap year, cake day is 1/3.\n        # Cake day begins at exact account creation time.\n        is_cakeday = cakeday_start + day <= now <= cakeday_start + (2 * day)\n    else:\n        is_cakeday = cakeday_start <= now <= cakeday_start + day\n\n    if is_cakeday:\n        message = message + ' | \u0002\u000313Cake day\u0003\u0002'\n    if commanded:\n        message = message + ' | https://reddit.com/u/' + u.name\n    if u.is_gold:\n        message = message + ' | \u0002\u000308Gold\u0003\u0002'\n    if u.is_mod:\n        message = message + ' | \u0002\u000305Mod\u0003\u0002'\n    message = message + (' | Link: ' + str(u.link_karma) +\n                         ' | Comment: ' + str(u.comment_karma))\n\n    bot.say(message)\n\n\n# If you change the groups here, you'll have to change some things above.\n@rule('.*%s.*' % user_url)\ndef auto_redditor_info(bot, trigger):\n    redditor_info(bot, trigger)\n\n\n@require_chanmsg('.setsfw is only permitted in channels')\n@commands('setsafeforwork', 'setsfw')\n@example('.setsfw true')\n@example('.setsfw false')\ndef update_channel(bot, trigger):\n    \"\"\"\n    Sets the Safe for Work status (true or false) for the current\n    channel. Defaults to false.\n    \"\"\"\n    if bot.channels[trigger.sender].privileges[trigger.nick] < OP:\n        return\n    else:\n        param = 'true'\n        if trigger.group(2) and trigger.group(3):\n            param = trigger.group(3).strip().lower()\n        sfw = param == 'true'\n        bot.db.set_channel_value(trigger.sender, 'sfw', sfw)\n        if sfw:\n            bot.reply('Got it. %s is now flagged as SFW.' % trigger.sender)\n        else:\n            bot.reply('Got it. %s is now flagged as NSFW.' % trigger.sender)\n\n\n@commands('getsafeforwork', 'getsfw')\n@example('.getsfw [channel]')\ndef get_channel_sfw(bot, trigger):\n    \"\"\"\n    Gets the preferred channel's Safe for Work status, or the current\n    channel's status if no channel given.\n    \"\"\"\n    channel = trigger.group(2)\n    if not channel:\n        channel = trigger.sender\n        if channel.is_nick():\n            return bot.say('.getsfw with no channel param is only permitted in channels')\n\n    channel = channel.strip()\n\n    sfw = bot.db.get_channel_value(channel, 'sfw')\n    if sfw:\n        bot.say('%s is flagged as SFW' % channel)\n    else:\n        bot.say('%s is flagged as NSFW' % channel)\n", "path": "sopel/modules/reddit.py"}]}