Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ voltage=<0.1.5a8
re
surrealdb
aiohttp
security==1.3.1
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This library holds security tools for protecting Python API calls.

License: MITOpen SourceMore facts

5 changes: 3 additions & 2 deletions src/Bot/nerimity/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import requests
import json
from security import safe_requests

class Channel():
"""
Expand Down Expand Up @@ -117,7 +118,7 @@ def _get_messages_raw(self, amount: int) -> str:
"Content-Type": "application/json",
}

response = requests.get(api_endpoint, headers=headers)
response = safe_requests.get(api_endpoint, headers=headers)
if response.status_code != 200:
print(f"Failed to get messages from {self}. Status code: {response.status_code}. Response Text: {response.text}")
raise requests.RequestException
Expand Down Expand Up @@ -166,4 +167,4 @@ def deserialize(json: dict) -> 'Channel':
new_channel.created_at = float(json["createdAt"])
new_channel.order = json["order"]

return new_channel
return new_channel
5 changes: 3 additions & 2 deletions src/Bot/nerimity/member.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import requests
import json
from security import safe_requests

# Generic Member
class Member():
Expand Down Expand Up @@ -345,7 +346,7 @@ async def get_feed(self) -> list[Post]:
"Content-Type": "application/json",
}

response = requests.get(api_endpoint, headers=headers)
response = safe_requests.get(api_endpoint, headers=headers)
raw_feed = json.loads(response.content)

feed = []
Expand All @@ -369,4 +370,4 @@ def deserialize(json: dict) -> 'ClientMember':
new_member.badges = int(json["badges"])
new_member.friends = {}

return new_member
return new_member
5 changes: 3 additions & 2 deletions src/Bot/nerimity/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import requests
import json
from security import safe_requests

class Post():
"""
Expand Down Expand Up @@ -59,7 +60,7 @@ def get_comments(self) -> list['Post']:
"Content-Type": "application/json",
}

response = requests.get(api_endpoint, headers=headers)
response = safe_requests.get(api_endpoint, headers=headers)
if response.status_code != 200:
print(f"{ConsoleShortcuts.error()} Failed to get comments for {self}. Status code: {response.status_code}. Response Text: {response.text}")
raise requests.RequestException
Expand Down Expand Up @@ -143,4 +144,4 @@ def deserialize(json: dict) -> 'Post':
new_post.liked_by = [int(i["id"]) for i in json["likedBy"]]
new_post.attachments = json["attachments"]

return new_post
return new_post
7 changes: 4 additions & 3 deletions src/Bot/nerimity/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import requests
import json
from security import safe_requests

class Server():
"""
Expand Down Expand Up @@ -69,7 +70,7 @@ def get_ban_list(self) -> list[Member]:
"Content-Type": "application/json",
}

response = requests.get(api_endpoint, headers=headers)
response = safe_requests.get(api_endpoint, headers=headers)
if response.status_code != 200:
print(f"{ConsoleShortcuts.error()} Failed to get ban list {self}. Status code: {response.status_code}. Response Text: {response.text}")
raise requests.RequestException
Expand Down Expand Up @@ -100,7 +101,7 @@ def get_server_details(self) -> None:
"Content-Type": "application/json",
}

response = requests.get(api_endpoint, headers=headers)
response = safe_requests.get(api_endpoint, headers=headers)
if response.status_code != 200:
print(f"{ConsoleShortcuts.error()} Failed to get ban list {self}. Status code: {response.status_code}. Response Text: {response.text}")
raise requests.RequestException
Expand Down Expand Up @@ -348,4 +349,4 @@ def deserialize(json: dict) -> 'Server':
new_server.channels = {}
new_server.members = {}

return new_server
return new_server
555 changes: 278 additions & 277 deletions src/Bot/revolt_bot.py

Large diffs are not rendered by default.

Loading
Loading