File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import json
2+
13import requests
24
35from collections import defaultdict
@@ -73,24 +75,20 @@ def moremod(text, chan):
7375@hook .command ("subs" , "moderates" , singlethread = True )
7476def moderates (text , chan ):
7577 """This plugin prints the list of subreddits a user moderates listed in a reddit users profile. Private subreddits will not be listed."""
76- #This command was written using concepts from FurCode http://github.com/FurCode.
7778 global search_pages
7879 search_pages [chan ] = []
7980 search_page_indexes [chan ] = 0
8081 user = text
81- r = requests .get (user_url .format (user ), headers = agent )
82+ r = requests .get (user_url .format (user ) + "moderated_subreddits.json" , headers = agent )
8283 if r .status_code != 200 :
8384 return statuscheck (r .status_code , user )
84- soup = BeautifulSoup (r .text )
85- mod_list = soup .find ('ul' , id = "side-mod-list" )
86- if mod_list is None :
87- return "{} does not moderate any public subreddits." .format (user )
8885
89- mod_list = mod_list . text . split ( 'r/' )
90- del mod_list [ 0 ]
86+ data = r . json ( )
87+ subs = data [ 'data' ]
9188 out = colors .parse ("$(b){}$(b) moderates these public subreddits: " .format (user ))
92- for sub in mod_list :
93- out += "{} \u2022 " .format (sub )
89+ for sub in subs :
90+ out += "{} \u2022 " .format (sub ['sr' ])
91+
9492 out = out [:- 2 ]
9593 out = smart_truncate (out )
9694 if len (out .split ('\n ' )) > 2 :
You can’t perform that action at this time.
0 commit comments