✅ 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
MODiX
MODiX8mo ago
blueberriesiftheywerecats
REPL Result: Success
"How " + "Do " + "You " + "Work"
"How " + "Do " + "You " + "Work"
Result: string
How Do You Work
How Do You Work
Compile: 141.386ms | Execution: 17.139ms | React with ❌ to remove this embed.
blueberriesiftheywerecats
In my implementation I used CSharpScript.EvaluateAsync
leowest
leowest8mo ago
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
Pobiega
Pobiega8mo ago
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
blueberriesiftheywerecats
yeah, as I thought so, it just reads csharprepl console?
Pobiega
Pobiega8mo ago
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 it
blueberriesiftheywerecats
ahh 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
leowest
leowest8mo ago
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
blueberriesiftheywerecats
weird
Pobiega
Pobiega8mo ago
remember, this service was made specifically to support a discord bot its not an "RCE as a feature" bot
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
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
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
its discord bot with some stuff and I wanted to implement c# runner in it
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
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
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega8mo ago
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
blueberriesiftheywerecats
maybe, but I read through the file, removed like half of redundant or susy code and it have to be pretty safe
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
the only way to make something unexected is to run specific c# code inside
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
yeah, maybe, I dont really know the consequences of running c# scripts on the server I could get smth like sql injection, but c#
Pobiega
Pobiega8mo ago
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
blueberriesiftheywerecats
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
leowest
leowest8mo ago
unless u flood the bot or just run thing that wil lconsume memory/cpu heavely
blueberriesiftheywerecats
yeah im trying to do that rn
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
but cant you do that on @MODiX? I think it will work
Pobiega
Pobiega8mo ago
no, you can't because the code runner for modix runs inside a docker container
blueberriesiftheywerecats
mine too
Pobiega
Pobiega8mo ago
its sandboxed, and cant access the outside. sure, but your bot token can probably be extracted
blueberriesiftheywerecats
well yeah...
Pobiega
Pobiega8mo ago
if you run it in the same process as the bot
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
i mean i got all +-850 lines of code that works with c# compiler
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
prolly with a lot of restrictions
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
blueberriesiftheywerecats
yeah make sense
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Pobiega
Pobiega8mo ago
Yup
Unknown User
Unknown User8mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server