✅ How does Bot work?
how does @MODiX can compile code?
I tried to implement it by myself and it works pretty good, but how MODiX doing that? I coudnt find any answers on github page
44 Replies
blueberriesiftheywerecats
REPL Result: Success
Result: string
Compile: 141.386ms | Execution: 17.139ms | React with ❌ to remove this embed.
In my implementation I used CSharpScript.EvaluateAsync
GitHub
GitHub - discord-csharp/CSharpRepl: CSharpRepl is a web api for C# ...
CSharpRepl is a web api for C# REPL using the Roslyn Scripting APIs - discord-csharp/CSharpRepl
there is a docker image for the code runner, and the bot just makes a request to the code runner
there is a hard timeout on a request for 30 sec, or the image will be restarted
more specifically this portion https://github.com/discord-csharp/CSharpRepl/blob/main/CSharpRepl/Eval/CSharpEval.cs
yeah, as I thought
so, it just reads csharprepl console?
what? no?
that repo has nothing to do with the
dotnet tool
for repl
Leo linked the exact code that does what you are asking, just check itahh ok
how can I make loading feature, like this api crashes when I spam with commands and I dont want to get error, I want him to take as much time as he needs and get response
looks like I can request every ~20 sec
U would change here https://github.com/discord-csharp/CSharpRepl/blob/main/CSharpRepl/Startup.cs#L89 I guess
GitHub
CSharpRepl/CSharpRepl/Startup.cs at main · discord-csharp/CSharpRepl
CSharpRepl is a web api for C# REPL using the Roslyn Scripting APIs - discord-csharp/CSharpRepl
weird
remember, this service was made specifically to support a discord bot
its not an "RCE as a feature" bot
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
yeah I used CSharpEval.cs file in that repo and remade it for my needs
so now it runs fast and without timeouts
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
its discord bot with some stuff and I wanted to implement c# runner in it
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
well just so u can run whatever c# code u want, I literally just coppied that one file from csharprepl repo to compile and run code
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
if you run that one file inside your bot, you're in for a heap of trouble
there is a very very good reason modix runs that as a separate service
maybe, but I read through the file, removed like half of redundant or susy code and it have to be pretty safe
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
the only way to make something unexected is to run specific c# code inside
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
yeah, maybe, I dont really know the consequences of running c# scripts on the server
I could get smth like sql injection, but c#
for one, they can crash your bot
or freeze it
the timeout and separate process is to prevent the bot from being affected by lockups
well I can create something similar with my implementation, but Its not necessary in my case where I have small group of people
and is timeout thing really enough to prevent running some dangerous code?
I dont think so
and I found out that it works well even if you run infinite loop, It will only crash the execution of that script, but not the bot
unless u flood the bot
or just run thing that wil lconsume memory/cpu
heavely
yeah im trying to do that rn
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
but cant you do that on @MODiX?
I think it will work
no, you can't
because the code runner for modix runs inside a docker container
mine too
its sandboxed, and cant access the outside.
sure, but your bot token can probably be extracted
well yeah...
if you run it in the same process as the bot
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
i mean i got all +-850 lines of code that works with c# compiler
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
prolly with a lot of restrictions
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
yeah make sense
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View
Yup
Unknown User•9mo ago
Message Not Public
Sign In & Join Server To View