easy way to determine if chudded
parent
a24b36a822
commit
3375c1073f
|
@ -3,6 +3,7 @@ import requests
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
import traceback
|
import traceback
|
||||||
import backoff
|
import backoff
|
||||||
|
from functools import cache
|
||||||
|
|
||||||
class TimeOutException(Exception):
|
class TimeOutException(Exception):
|
||||||
pass
|
pass
|
||||||
|
@ -16,10 +17,26 @@ class RDramaAPIInterface:
|
||||||
self.site = site
|
self.site = site
|
||||||
self.protocol = "https" if https else "http"
|
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):
|
def make_post(self, title, submission_url, body):
|
||||||
url=f"{self.protocol}://{self.site}/submit"
|
url=f"{self.protocol}://{self.site}/submit"
|
||||||
return self.post(url, data={'title' : title, 'url': submission_url, 'body': body})
|
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.
|
Sends a message to a user.
|
||||||
'''
|
'''
|
||||||
|
|
Loading…
Reference in New Issue