From 3375c1073fa61080f495298b0c84243aa98cbd05 Mon Sep 17 00:00:00 2001 From: Chuck Sneed Date: Tue, 21 Mar 2023 18:10:57 -0500 Subject: [PATCH] easy way to determine if chudded --- RDramaAPIInterface.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/RDramaAPIInterface.py b/RDramaAPIInterface.py index 21ffe22..13c9a5e 100644 --- a/RDramaAPIInterface.py +++ b/RDramaAPIInterface.py @@ -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. '''