<filename>discum/utils/contextproperties.py
#x-context-properties
#some of these values are hardcoded cause that's just faster

import base64
import json

class ContextProperties(object):
	@staticmethod
	def encodeData(data):
		binaryData = json.dumps(data).encode()
		encodedData = base64.b64encode(binaryData).decode("utf-8")
		return encodedData

	@staticmethod
	def get(location, guild_id=None, channel_id=None, channel_type=None):
		loc = location.lower()
		if loc == "friends":
			return "<KEY> # {"location":"Friends"}
		elif loc == "context menu":
			return "<KEY> # {"location":"ContextMenu"}
		elif loc == "user profile":
			return "<KEY>" # {"location":"User Profile"}
		elif loc == "add friend":
			return "<KEY> # {"location":"Add Friend"}
		elif loc == "guild header":
			return "<KEY>" # {"location":"Guild Header"}
		elif loc in ("accept invite page", "join guild"):
			data = {
				"location": "Accept Invite Page",
				"location_guild_id": guild_id,
				"location_channel_id": channel_id,
				"location_channel_type": channel_type,
			}
			if loc == "join guild":
				data["location"] = "Join Guild"
			return ContextProperties.encodeData(data)
		else:
			data = {"location":location}
			return ContextProperties.encodeData(data)
<filename>discum/utils/contextproperties.py
#x-context-properties
#some of these values are hardcoded cause that's just faster

import base64
import json

class ContextProperties(object):
	@staticmethod
	def encodeData(data):
		binaryData = json.dumps(data).encode()
		encodedData = base64.b64encode(binaryData).decode("utf-8")
		return encodedData

	@staticmethod
	def get(location, guild_id=None, channel_id=None, channel_type=None):
		loc = location.lower()
		if loc == "friends":
			return "<KEY> # {"location":"Friends"}
		elif loc == "context menu":
			return "<KEY> # {"location":"ContextMenu"}
		elif loc == "user profile":
			return "<KEY>" # {"location":"User Profile"}
		elif loc == "add friend":
			return "<KEY> # {"location":"Add Friend"}
		elif loc == "guild header":
			return "<KEY>" # {"location":"Guild Header"}
		elif loc in ("accept invite page", "join guild"):
			data = {
				"location": "Accept Invite Page",
				"location_guild_id": guild_id,
				"location_channel_id": channel_id,
				"location_channel_type": channel_type,
			}
			if loc == "join guild":
				data["location"] = "Join Guild"
			return ContextProperties.encodeData(data)
		else:
			data = {"location":location}
			return ContextProperties.encodeData(data)
#x-context-properties #some of these values are hardcoded cause that's just faster # {"location":"Friends"} # {"location":"ContextMenu"} # {"location":"User Profile"} # {"location":"Add Friend"} # {"location":"Guild Header"}