godbolt ¶
Godbolt API Wrapper for Tux Bot.
This module provides integration with the Godbolt API allowing code execution and compilation for various programming languages.
Classes:
-
CompilerFilters–Compiler filters.
-
CompilerOptions–Compiler options.
-
Options–Godbolt API options.
-
Payload–Payload for the Godbolt API.
Functions:
-
checkresponse–Check the response from the Godbolt API.
-
sendresponse–Send the response from the Godbolt API.
-
getlanguages–Get the languages from the Godbolt API.
-
getcompilers–Get the compilers from the Godbolt API.
-
getspecificcompiler–Get a specific compiler from the Godbolt API.
-
getoutput–Send a POST request to the Godbolt API to get the output of the given code.
-
generateasm–Generate assembly code from the given code.
Classes¶
CompilerFilters ¶
Bases: TypedDict
Compiler filters.
Parameters:
-
TypedDict(Compiler filters.) –Dictionary of compiler filters.
CompilerOptions ¶
Bases: TypedDict
Compiler options.
Parameters:
-
TypedDict(Compiler options.) –Dictionary of compiler options.
Options ¶
Payload ¶
Bases: TypedDict
Payload for the Godbolt API.
Parameters:
-
TypedDict(Payload.) –Dictionary of payload.
Functions¶
checkresponse async ¶
checkresponse(res: Response) -> str | None
Check the response from the Godbolt API.
Parameters:
-
res(Response) –The response from the Godbolt API.
Returns:
-
str | None–The response from the Godbolt API if successful, otherwise None.
Raises:
-
TuxAPIConnectionError–If connection to Godbolt API fails.
-
TuxAPIRequestError–If the API request fails.
-
TuxAPIResourceNotFoundError–If the resource is not found.
sendresponse async ¶
Send the response from the Godbolt API.
Parameters:
-
url(str) –The URL to send the response from.
Returns:
-
str | None–The response from the Godbolt API if successful, otherwise None.
Raises:
-
TuxAPIConnectionError–If connection to Godbolt API fails.
-
TuxAPIRequestError–If the API request fails.
-
TuxAPIResourceNotFoundError–If the resource is not found.
getlanguages async ¶
getlanguages() -> str | None
Get the languages from the Godbolt API.
Returns:
-
str | None–The languages from the Godbolt API if successful, otherwise None.
getcompilers async ¶
getcompilers() -> str | None
Get the compilers from the Godbolt API.
Returns:
-
str | None–The compilers from the Godbolt API if successful, otherwise None.
getspecificcompiler async ¶
getoutput async ¶
Send a POST request to the Godbolt API to get the output of the given code.
Parameters:
-
code(str) –The code to compile.
-
lang(str) –The language of the code.
-
compileroptions(str | None, default:None) –The compiler options, by default None
Returns:
-
str | None–The output of the code if successful, otherwise None.
Raises:
-
TuxAPIConnectionError–If connection to Godbolt API fails.
-
TuxAPIRequestError–If the API request fails.
-
TuxAPIResourceNotFoundError–If the resource is not found.
generateasm async ¶
Generate assembly code from the given code.
Parameters:
-
code(str) –The code to generate assembly from.
-
lang(str) –The language of the code.
-
compileroptions(str | None, default:None) –The compiler options, by default None
Returns:
-
str | None–The assembly code if successful, otherwise None.
Raises:
-
TuxAPIConnectionError–If connection to Godbolt API fails.
-
TuxAPIRequestError–If the API request fails.
-
TuxAPIResourceNotFoundError–If the resource is not found.