Skip to content

Commit 7bd455d

Browse files
committed
General reformat
1 parent 93331b4 commit 7bd455d

1 file changed

Lines changed: 7 additions & 5 deletions

File tree

plugins/reddit_info.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
user_url = "http://reddit.com/user/{}/"
1212
subreddit_url = "http://reddit.com/r/{}/"
1313
# This agent should be unique for your cloudbot instance
14-
agent = {"User-Agent":"gonzobot a cloudbot (IRCbot) implementation for snoonet.org by /u/bloodygonzo"}
14+
agent = {"User-Agent": "gonzobot a cloudbot (IRCbot) implementation for snoonet.org by /u/bloodygonzo"}
1515

1616

1717
def two_lines(bigstring, chan):
@@ -30,9 +30,9 @@ def smart_truncate(content, length=355, suffix='...\n'):
3030
else:
3131
return content[:length].rsplit(' \u2022 ', 1)[0]+ suffix + content[:length].rsplit(' \u2022 ', 1)[1] + smart_truncate(content[length:])
3232

33+
3334
def statuscheck(status, item):
3435
"""since we are doing this a lot might as well return something more meaningful"""
35-
out = ""
3636
if status == 404:
3737
out = "It appears {} does not exist.".format(item)
3838
elif status == 403:
@@ -45,13 +45,13 @@ def statuscheck(status, item):
4545
out = "Reddit returned an error, response: {}".format(status)
4646
return out
4747

48+
4849
@hook.command("moremod", autohelp=False)
4950
def moremod(text, chan):
5051
"""if a sub or mod list has lots of results the results are pagintated. If the most recent search is paginated the pages are stored for retreival. If no argument is given the next page will be returned else a page number can be specified."""
5152
if not search_pages[chan]:
5253
return "There are modlist pages to show."
5354
if text:
54-
index = ""
5555
try:
5656
index = int(text)
5757
except:
@@ -127,6 +127,7 @@ def karma(text):
127127
out += "redditor for {} days.".format(account_age.days)
128128
return out
129129

130+
130131
@hook.command("cakeday", singlethreaded=True)
131132
def cake_day(text):
132133
"""cakeday <reddituser> will return the cakeday for the given reddit username."""
@@ -149,8 +150,8 @@ def cake_day(text):
149150
out += "they have been a redditor for {} days.".format(account_age.days)
150151
return out
151152

153+
152154
def time_format(numdays):
153-
age = ()
154155
if numdays >= 365:
155156
age = (int(numdays / 365), "y")
156157
if age[0] > 1:
@@ -159,6 +160,7 @@ def time_format(numdays):
159160
age = (numdays, "d")
160161
return age
161162

163+
162164
@hook.command("submods", "mods", "rmods", singlethreaded=True)
163165
def submods(text, chan):
164166
"""submods <subreddit> prints the moderators of the specified subreddit."""
@@ -190,6 +192,7 @@ def submods(text, chan):
190192
return "{}(page {}/{}) .moremod".format(out, search_page_indexes[chan] + 1, len(search_pages[chan]))
191193
return out
192194

195+
193196
@hook.command("subinfo","subreddit", "sub", "rinfo", singlethreaded=True)
194197
def subinfo(text):
195198
"""subinfo <subreddit> fetches information about the specified subreddit."""
@@ -211,7 +214,6 @@ def subinfo(text):
211214
subscribers = data['data']['subscribers']
212215
active = data['data']['accounts_active']
213216
sub_age = datetime.now() - datetime.fromtimestamp(data['data']['created'])
214-
age = ()
215217
if sub_age.days >= 365:
216218
age = (int(sub_age.days / 365), "y")
217219
else:

0 commit comments

Comments
 (0)