easy way to determine if chudded

master
Chuck Sneed 2023-03-21 18:10:57 -05:00
parent a24b36a822
commit 3375c1073f
1 changed files with 17 additions and 0 deletions

View File

@ -3,6 +3,7 @@ import requests
from bs4 import BeautifulSoup
import traceback
import backoff
from functools import cache
class TimeOutException(Exception):
pass
@ -16,10 +17,26 @@ class RDramaAPIInterface:
self.site = site
self.protocol = "https" if https else "http"
def is_chudded(self):
return "Chud" in self.get_my_badges_simple()
@cache
def get_my_badges_simple(self):
return [i['name'] for i in self.get_my_badges()]
def get_my_badges(self):
return self.get_me()['badges']
def make_post(self, title, submission_url, body):
url=f"{self.protocol}://{self.site}/submit"
return self.post(url, data={'title' : title, 'url': submission_url, 'body': body})
@cache
def get_me(self):
self.get_front_page()
url=f"{self.protocol}://{self.site}/@me"
return self.get(url)
'''
Sends a message to a user.
'''