Added a default user agent to use, modifiable from the config file
This commit is contained in:
parent
c9c60464d8
commit
b28d6ff4b8
|
@ -11,7 +11,7 @@ class Deviantart:
|
|||
def __init__(self, bot):
|
||||
self.base_url = "https://www.deviantart.com/api/v1/oauth2/gallery/all"
|
||||
self.bot = bot
|
||||
self.headers = {"User-Agent": "Bonfire/1.0.0"}
|
||||
self.headers = {"User-Agent": config.user_agent}
|
||||
self.session = aiohttp.ClientSession()
|
||||
self.token = None
|
||||
self.params = None
|
||||
|
|
|
@ -18,7 +18,7 @@ class Links:
|
|||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
# Only default headers for all requests we should use sets the User-Agent
|
||||
self.headers = {"User-Agent": "Bonfire/1.0.0"}
|
||||
self.headers = {"User-Agent": config.user_agent}
|
||||
self.session = aiohttp.ClientSession()
|
||||
|
||||
@commands.command(pass_context=True, aliases=['g'])
|
||||
|
|
|
@ -22,7 +22,7 @@ class Overwatch:
|
|||
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.headers = {"User-Agent": "Bonfire/1.0.0"}
|
||||
self.headers = {"User-Agent": config.user_agent}
|
||||
self.session = aiohttp.ClientSession()
|
||||
|
||||
@commands.group(no_pm=True)
|
||||
|
|
|
@ -21,7 +21,7 @@ async def online_users():
|
|||
# In place of requesting for /channel and checking if that is online currently, for each channel
|
||||
# This method is in place to just return all online_users
|
||||
url = '{}/online/all?key={}'.format(base_url, key)
|
||||
with aiohttp.ClientSession(headers={"User-Agent": "Bonfire/1.0.0"}) as s:
|
||||
with aiohttp.ClientSession(headers={"User-Agent": config.user_agent}) as s:
|
||||
async with s.get(url) as response:
|
||||
return await response.json()
|
||||
except:
|
||||
|
@ -40,7 +40,7 @@ def check_online(online_channels, channel):
|
|||
class Picarto:
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
self.headers = {"User-Agent": "Bonfire/1.0.0"}
|
||||
self.headers = {"User-Agent": config.user_agent}
|
||||
self.session = aiohttp.ClientSession()
|
||||
|
||||
async def check_channels(self):
|
||||
|
|
|
@ -19,7 +19,7 @@ class Twitch:
|
|||
self.bot = bot
|
||||
self.key = config.twitch_key
|
||||
self.params = {'client_id': self.key}
|
||||
self.headers = {"User-Agent": "Bonfire/1.0.0",
|
||||
self.headers = {"User-Agent": config.user_agent,
|
||||
"Client-ID": self.key}
|
||||
|
||||
async def channel_online(self, channel: str):
|
||||
|
|
|
@ -61,6 +61,8 @@ da_id = global_config.get("da_id", "")
|
|||
da_secret = global_config.get("da_secret", "")
|
||||
# The invite link for the server made for the bot
|
||||
dev_server = global_config.get("dev_server", "")
|
||||
# The User-Agent that we'll use for most requests
|
||||
user_agent = global_config.get('user_agent', "")
|
||||
|
||||
# The variables needed for sharding
|
||||
shard_count = global_config.get('shard_count', 1)
|
||||
|
|
|
@ -7,6 +7,8 @@ discord_bots_key: 'key'
|
|||
carbon_key: 'key'
|
||||
twitch_key: 'key'
|
||||
|
||||
user_agent: 'User-Agent/1.0.0 (Comment like link to site)'
|
||||
|
||||
shard_count: 1
|
||||
shard_id: 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue