Inital Commit!
This commit is contained in:
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
dist/
|
||||
21
LICENCE
Normal file
21
LICENCE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 KoffeeJava
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
14
README.md
Normal file
14
README.md
Normal file
@@ -0,0 +1,14 @@
|
||||
# NEW FUNC
|
||||
`macaronipm.user.UserExist()`
|
||||
|
||||
`macaronipm.user.IsBanned()`
|
||||
|
||||
`macaronipm.user.logout()`
|
||||
|
||||
`macaronipm.user.GetMessages()`
|
||||
|
||||
`macaronipm.user.getUnreadMessages()`
|
||||
|
||||
`macaronipm.IsOnline()`
|
||||
|
||||
`macaronipm.project.hasLovedVoted()`
|
||||
22
pyproject.toml
Normal file
22
pyproject.toml
Normal file
@@ -0,0 +1,22 @@
|
||||
[build-system]
|
||||
requires = ["uv_build >= 0.9.26, <0.10.0"]
|
||||
build-backend = "uv_build"
|
||||
|
||||
[project]
|
||||
name = "macaronipm"
|
||||
version = "3.0.0"
|
||||
authors = [
|
||||
{ name="KoffeeJava", email="koffeejava@tuta.io" },
|
||||
]
|
||||
description = "A PenguinMod API Wrapper"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.9"
|
||||
classifiers = [
|
||||
"Programming Language :: Python :: 3",
|
||||
"Operating System :: OS Independent",
|
||||
]
|
||||
license = "MIT"
|
||||
license-files = ["LICEN[CS]E*"]
|
||||
|
||||
[project.urls]
|
||||
Homepage = "https://www.koffeejava.us/macaroni"
|
||||
14
src/macaronipm/__init__.py
Normal file
14
src/macaronipm/__init__.py
Normal file
@@ -0,0 +1,14 @@
|
||||
import requests
|
||||
from . import misc
|
||||
from . import project
|
||||
from . import user
|
||||
|
||||
def isOnline():
|
||||
url = f"https://projects.penguinmod.com/api/v1/ping"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
return -1
|
||||
|
||||
return 0
|
||||
BIN
src/macaronipm/__pycache__/__init__.cpython-314.pyc
Normal file
BIN
src/macaronipm/__pycache__/__init__.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/macaronipm/__pycache__/main.cpython-314.pyc
Normal file
BIN
src/macaronipm/__pycache__/main.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/macaronipm/__pycache__/misc.cpython-314.pyc
Normal file
BIN
src/macaronipm/__pycache__/misc.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/macaronipm/__pycache__/project.cpython-314.pyc
Normal file
BIN
src/macaronipm/__pycache__/project.cpython-314.pyc
Normal file
Binary file not shown.
BIN
src/macaronipm/__pycache__/user.cpython-314.pyc
Normal file
BIN
src/macaronipm/__pycache__/user.cpython-314.pyc
Normal file
Binary file not shown.
45
src/macaronipm/misc.py
Normal file
45
src/macaronipm/misc.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import requests
|
||||
import json
|
||||
from colorist import Color
|
||||
from colorist import Effect
|
||||
from colorist import ColorHex
|
||||
|
||||
ORANGE = ColorHex("#ff8800")
|
||||
|
||||
def setToken(settoken):
|
||||
global TOKEN
|
||||
TOKEN = settoken
|
||||
|
||||
def setProject(projectid):
|
||||
global PID
|
||||
PID = projectid
|
||||
|
||||
def follow(target, toggle):
|
||||
url = "https://projects.penguinmod.com/api/v1/users/follow"
|
||||
|
||||
data = f'{{"token":"{TOKEN}","target":"{target}","toggle":{toggle}}}'
|
||||
headers = {'Content-type': 'application/json'}
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"MacaroniPM: {Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
def GetFeatured():
|
||||
print(f"{ORANGE}MacaroniPM: The featured function is stil being worked on. It is recomended {Effect.BOLD}{Effect.UNDERLINE}NOT{Effect.OFF}{ORANGE} to use this.{Effect.OFF}")
|
||||
url = f"https://projects.penguinmod.com/api/v1/projects/searchprojects?page=0&query=&type=featured&token={TOKEN}&reverse=false"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return response.text.split()
|
||||
91
src/macaronipm/project.py
Normal file
91
src/macaronipm/project.py
Normal file
@@ -0,0 +1,91 @@
|
||||
from . import misc
|
||||
import io
|
||||
import requests
|
||||
import json
|
||||
import base64
|
||||
from colorist import Color
|
||||
from colorist import Effect
|
||||
|
||||
def getThumbnail():
|
||||
url = f"https://projects.penguinmod.com/api/v1/projects/getproject?projectID={misc.PID}&requestType=thumbnail"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
base64_data = base64.b64encode(io.BytesIO(response.content).read()).decode('utf-8')
|
||||
return f"data:image/jpeg;base64,{base64_data}"
|
||||
|
||||
def getMeta():
|
||||
url = f"https://projects.penguinmod.com/api/v1/projects/getproject?projectID={misc.PID}&requestType=metadata"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return json.loads(response.content)
|
||||
|
||||
def loveToggle(toggle):
|
||||
url = "https://projects.penguinmod.com/api/v1/projects/interactions/loveToggle"
|
||||
|
||||
data = f'{{"projectId":"{misc.PID}","token":"{misc.TOKEN}","toggle":{toggle}}}'
|
||||
headers = {'Content-type': 'application/json'}
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
def voteToggle(toggle):
|
||||
url = "https://projects.penguinmod.com/api/v1/projects/interactions/voteToggle"
|
||||
|
||||
data = f'{{"projectId":"{misc.PID}","token":"{misc.TOKEN}","toggle":{toggle}}}'
|
||||
headers = {'Content-type': 'application/json'}
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
def getRankedProjects(page):
|
||||
url = f"https://projects.penguinmod.com/api/v1/projects/getprojects?page={page}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return json.loads(response.content)
|
||||
|
||||
def hasLovedVoted():
|
||||
url = f"https://projects.penguinmod.com/api/v1/projects/getuserstatewrapper?projectId={misc.PID}&token={misc.TOKEN}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return json.loads(response.content)
|
||||
120
src/macaronipm/user.py
Normal file
120
src/macaronipm/user.py
Normal file
@@ -0,0 +1,120 @@
|
||||
from . import misc
|
||||
import io
|
||||
import requests
|
||||
import json
|
||||
import base64
|
||||
from colorist import Color
|
||||
from colorist import Effect
|
||||
|
||||
def getMeta(target):
|
||||
url = f"https://projects.penguinmod.com/api/v1/users/profile?target={target}&token={misc.misc.TOKEN}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return json.loads(response.content)
|
||||
|
||||
def isBlocking(target):
|
||||
url = f"https://projects.penguinmod.com/api/v1/users/hasblocked?target={target}&token={misc.misc.TOKEN}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
jsons = json.loads(response.content.decode())
|
||||
return jsons['has_blocked']
|
||||
|
||||
def getPfp(target):
|
||||
url = f"https://projects.penguinmod.com/api/v1/users/getpfp?username={target}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
base64_data = base64.b64encode(io.BytesIO(response.content).read()).decode('utf-8')
|
||||
return f"data:image/jpeg;base64,{base64_data}"
|
||||
|
||||
def userExist(target):
|
||||
url = f"https://projects.penguinmod.com/api/v1/users/userexists?username={target}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
|
||||
return json.loads(response.content)['exists']
|
||||
|
||||
def isBanned(target):
|
||||
url = f"https://projects.penguinmod.com/api/v1/users/isBanned?username={target}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
|
||||
return json.loads(response.content)['isBanned']
|
||||
|
||||
def logout():
|
||||
url = "https://projects.penguinmod.com/api/v1/users/logout"
|
||||
|
||||
data = f'{{"token":"{misc.misc.TOKEN}"}}'
|
||||
headers = {'Content-type': 'application/json'}
|
||||
response = requests.post(url, headers=headers, data=data)
|
||||
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
return 0
|
||||
|
||||
def getMessages():
|
||||
url = f"https://projects.penguinmod.com/api/v1/users/getmessages?token={misc.TOKEN}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
jsons = json.loads(response.content.decode())
|
||||
return jsons
|
||||
|
||||
def getUnreadMessages():
|
||||
url = f"https://projects.penguinmod.com/api/v1/users/getunreadmessages?token={misc.TOKEN}"
|
||||
|
||||
response = requests.get(url)
|
||||
|
||||
if not response.status_code == 200:
|
||||
print(f"{Color.RED}Something went wrong!")
|
||||
print(f"Status code: {response.status_code}")
|
||||
print(f"Response from url: {Effect.BOLD}{Effect.UNDERLINE}{json.loads(response.content.decode())["error"]}{Effect.OFF}")
|
||||
return -1
|
||||
|
||||
jsons = json.loads(response.content.decode())
|
||||
return jsons
|
||||
6
src/test.py
Normal file
6
src/test.py
Normal file
@@ -0,0 +1,6 @@
|
||||
import macaronipm
|
||||
|
||||
macaronipm.misc.setToken("6e5035471364acbbdb523dd05e903ccd48c3a60ea6d5ec14c485a833dccf555f")
|
||||
macaronipm.misc.setProject("5284710295")
|
||||
|
||||
print(macaronipm.user.getUnreadMessages())
|
||||
Reference in New Issue
Block a user