PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: TheKnowledge on 23 June, 2005, 03:10:31

Title: MOTD editor
Post by: TheKnowledge on 23 June, 2005, 03:10:31
Is it possible to make a script that enables you to edit the welcome message from an external pc? I'm running my hub from a server pc. I tried to access the motd.txt file through FTP access. After I edited it, and uploaded it to replace the existing one, the welcome message went back to the following message; "Push it!", and that's it. Being able to edit and update news on my motd as an OP or master would be awesome. Not nececcarily looking for a script, just a solution to what I have to do to be able to edit motd.txt through FTP or whatever.
Title:
Post by: bastya_elvtars on 23 June, 2005, 03:18:25
There is a script called SaveString, written by chill & Herodes. Find it and somebody can use that to make you this, because this IS possible.

../motd.txt
Title:
Post by: jiten on 23 June, 2005, 09:38:47
Well, you could try UltraVNC that "... is a great and famous remote controle, multi-OS tool..." for those things.
That's just an example, because there are other programs like that one.

Cheers
Title:
Post by: bastya_elvtars on 23 June, 2005, 13:25:32
A quick and dirty one...

-- Mini MOTD saver.
-- use the command you specify below. using without parameters results in empty motd.
-- only Masters can use it.
-- works in PM with the bot.


bot="MOTD"
conmmand="motd"

function ToArrival(user,data)
  data=string.sub(data,1,string.len(data)-1)
  local _,_,whoto,cmd = string.find(data,"$To:%s+(%S+)%s+From:%s+%S+%s+$%b<>%s+[%!%+%#](%S+)")
  if whoto==bot and cmd==conmmand then
    if user.iProfile==0 then
      local _,_,motd=string.find(data,"%b<>%s+%S+%s+(.+)")
      local f,err=io.open(frmHub:GetPtokaXLocation().."cfg/motd.txt","w+")
      if err then user:SendPM(bot,err) end
      if motd then
        f:write(motd)
        user:SendPM(bot,"MOTD saved.")
      else
        f:write("")
        user:SendPM(bot,"MOTD emptied.")
      end
      f:close()
    else
      user:SendPm(bot,"Not allowed...")
    end
    return 1
  end
end

function Main()
  frmHub:RegBot(bot)
end

-- // IMPORTANT: only works with 0.331!
Title:
Post by: GeceBekcisi on 23 June, 2005, 14:34:05
Tested the script. Saves given motd successfully but PtokaX saves current motd on exit or restart, and also motd doesnt dynamically change.
Title:
Post by: bastya_elvtars on 23 June, 2005, 14:39:06
QuoteOriginally posted by GeceBekcisi
Tested the script. Saves given motd successfully but PtokaX saves current motd on exit or restart, and also motd doesnt dynamically change.

I know, this would need to set file's priority over GUIs. I think the GUI one should only be a text editor (with a Save button), and the actual MOTD should load from the file. I will ask PPK.
Title:
Post by: TheKnowledge on 23 June, 2005, 22:34:12
Thanks for fast reply's. I use PtokaX 0.3.3.1, and my rank at the hub is Master.

I tried the quick and dirty one, but the MOTD still says "Push it!".

Regarding the SaveString and UltraVNC, could you link me or paste the code?

Another solution would be a simple script that pops up a welcome message as PM when users log on to the hub. I've seen this in other hubs, but don't know what the name of the script is called, so I don't know what to look for.
Title:
Post by: bastya_elvtars on 23 June, 2005, 22:48:25
You can send the MOTD in PM.
Title:
Post by: TheKnowledge on 23 June, 2005, 22:55:33
I tried that. It says MOTD Saved, but the when I restart or reconnect, the MOTD still only says "Push it!".
Title:
Post by: bastya_elvtars on 23 June, 2005, 23:00:11
QuoteOriginally posted by TheKnowledge
I tried that. It says MOTD Saved, but the when I restart or reconnect, the MOTD still only says "Push it!".

That's due to the above. You can only do remote admin or ftp.