HoJBot.jl icon indicating copy to clipboard operation
HoJBot.jl copied to clipboard

dedicated Discord channel as backend storage

Open rapus95 opened this issue 4 years ago • 0 comments
trafficstars

this channel holds the configuration data and maybe even the complete bot state either in serialized or in human-readable form. for configuration parameters, human-readable might be favourable, but for arbitrary state base64 most probably is a good format. Proposal (in pseudo julia code):

function startup()
  haschannel("botconfig") || createchannel("botconfig")
  global configchannel = getchannel("botconfig")
  global configmsg = getconfigmessage(message->startswith(message, "hojbot"))

  global config = loadsettings(content(configmsg)) #sets config dictionary
end

function commander(c, m::Message, Val{:config})
  k, v = parseconfig(m)
  updateconfig!(k, v)
end

function updateconfig!(k,v)
  msg = generateconfigmsg()
  edit!(configmsg, msg)
  config[k] = v
end

rapus95 avatar May 31 '21 08:05 rapus95