Skip to content

Commit

Permalink
(xxx) code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
xTrayambak committed Nov 22, 2024
1 parent cb3ca51 commit f868c78
Showing 1 changed file with 4 additions and 40 deletions.
44 changes: 4 additions & 40 deletions src/commands/run.nim
Original file line number Diff line number Diff line change
Expand Up @@ -61,33 +61,6 @@ proc updateConfig*(input: Input, config: Config) =

writeFile(fflagsFile, serialized)

proc onGameLeave*(config: Config, discord: Option[DiscordRPC]) =
debug "lucem: left experience"

if !discord:
return

let client = &discord

client.setActivity(
Activity(
details: "Playing Roblox with Lucem (Sober)",
state: "In the Roblox app",
timestamps: ActivityTimestamps(start: epochTime().int64),
)
)

proc onBloxstrapRpc*(config: Config, discord: Option[DiscordRPC], line: string) =
assert false
debug "lucem: trying to extract BloxstrapRPC payload from line"
debug "lucem: " & line
let payload = line.split("[FLog::Output] [BloxstrapRPC]")

if payload.len < 2:
warn "lucem: failed to obtain BloxstrapRPC JSON payload as split results in one or less element."
warn "lucem: " & line
return

proc eventWatcher*(
config: Config,
input: Input
Expand Down Expand Up @@ -123,29 +96,27 @@ proc eventWatcher*(
ticksUntilSoberRunCheck = 0

while hasntStarted or soberIsRunning:
#debug "lucem: ticking reactor"
reactor.tick()

let logFile = readFile(getSoberLogPath()).splitLines()

if ticksUntilSoberRunCheck < 1:
# debug "lucem: checking if sober is still running"
debug "lucem: checking if sober is still running"
soberIsRunning = soberRunning()
ticksUntilSoberRunCheck = 5000

dec ticksUntilSoberRunCheck

if logFile.len - 1 < line:
# echo "woops (" & $line & "): " & $logFile
continue

let data = logFile[line]
if data.len < 1:
inc line
continue

#[if verbose or not defined(release):
echo data]#
if verbose or not defined(release):
echo data

if data.contains(
"[FLog::GameJoinUtil] GameJoinUtil::joinGamePostStandard"
Expand All @@ -164,12 +135,9 @@ proc eventWatcher*(
)
)

# onGameJoin(args.config, data, args.discord, startedPlayingAt)

if data.contains("[FLog::Network] UDMUX Address ="):
let str = data.split(" = ")[1].split(",")[0]

echo str
send(
Packet(
magic: mgOnServerIp,
Expand All @@ -179,12 +147,9 @@ proc eventWatcher*(
)
)

#[if data.contains("[FLog::Output] [BloxstrapRPC]"):
onBloxstrapRpc(args.config, args.discord, data)]#

if data.contains("[FLog::Network] Client:Disconnect") or
data.contains("[FLog::Network] Connection lost - Cannot contact server/client"):
discard#onGameLeave(config)
continue

# sleep(config.lucem.pollingDelay.int)
hasntStarted = false
Expand All @@ -193,7 +158,6 @@ proc eventWatcher*(
info "lucem: Sober seems to have exited - we'll stop here too. Adios!"

proc runRoblox*(input: Input, config: Config) =
var startingTime = epochTime()
info "lucem: running Roblox via Sober"

writeFile(getSoberLogPath(), newString(0))
Expand Down

0 comments on commit f868c78

Please sign in to comment.