File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -73,24 +73,20 @@ def moremod(text, chan):
7373@hook .command ("subs" , "moderates" , singlethread = True )
7474def moderates (text , chan ):
7575 """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.
7776 global search_pages
7877 search_pages [chan ] = []
7978 search_page_indexes [chan ] = 0
8079 user = text
81- r = requests .get (user_url .format (user ), headers = agent )
80+ r = requests .get (user_url .format (user ) + "moderated_subreddits.json" , headers = agent )
8281 if r .status_code != 200 :
8382 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 )
8883
89- mod_list = mod_list . text . split ( 'r/' )
90- del mod_list [ 0 ]
84+ data = r . json ( )
85+ subs = data [ 'data' ]
9186 out = colors .parse ("$(b){}$(b) moderates these public subreddits: " .format (user ))
92- for sub in mod_list :
93- out += "{} \u2022 " .format (sub )
87+ for sub in subs :
88+ out += "{} \u2022 " .format (sub ['sr' ])
89+
9490 out = out [:- 2 ]
9591 out = smart_truncate (out )
9692 if len (out .split ('\n ' )) > 2 :
You can’t perform that action at this time.
0 commit comments