Notepad script for BCDC
 

News:

29 December 2022 - PtokaX 0.5.3.0 (20th anniversary edition) released...
11 April 2017 - PtokaX 0.5.2.2 released...
8 April 2015 Anti child and anti pedo pr0n scripts are not allowed anymore on this board!
28 September 2015 - PtokaX 0.5.2.1 for Windows 10 IoT released...
3 September 2015 - PtokaX 0.5.2.1 released...
16 August 2015 - PtokaX 0.5.2.0 released...
1 August 2015 - Crowdfunding for ADC protocol support in PtokaX ended. Clearly nobody want ADC support...
30 June 2015 - PtokaX 0.5.1.0 released...
30 April 2015 Crowdfunding for ADC protocol support in PtokaX
26 April 2015 New support hub!
20 February 2015 - PtokaX 0.5.0.3 released...
13 April 2014 - PtokaX 0.5.0.2 released...
23 March 2014 - PtokaX testing version 0.5.0.1 build 454 is available.
04 March 2014 - PtokaX.org sites were temporary down because of DDOS attacks and issues with hosting service provider.

Main Menu

Notepad script for BCDC

Started by FleetCommand, 31 January, 2004, 08:23:30

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

FleetCommand

I's a simple try (my first working usable lua script for bcdc (and my first lua script at all), but  it works :P :)

Allows users to write message into a text file and read it back (you can commenct the corresponding lines if don't want to let them read back it, or can be good on ophub to send message each other etc)

You can store your help file in help.txt

[B]Replacement of hub.onPrivateMessage function of Startup.lua[/B]
hub.onPrivateMessage = function( this, user, to, prefix, text )
		-- DC():PrintDebug( this:getHubName().."> Priv msg: "..user:getNick().." -> "..to.." = "..text )
		-- FleetCommand NotePad Script
		-- BLua 0.1 - molnihun at netscape.net
		local s = string.lower( text )
		local subszoveg=string.sub(s,1,6)
		local fajlnev=""
		if subszoveg == "-radd " or subszoveg== "-madd " then
			if subszoveg== "-radd " then fajlnev="report.txt"
			else fajlnev="message.txt"
			end
			local ownNick = this:getOwnNick()
			local fajl=io.open (fajlnev, "a")
			fajl:write(" :: "..os.date("%Y. %m. %d - %H:%M") .. " :: " ..user:getNick() .. " :: " .. string.sub(text,7, string.len(text)).."\n")
			fajl:close()
			user:sendPrivMsgFmt( "OK ("..fajlnev..")" )
		elseif subszoveg == "-rread" or subszoveg=="-mread" then
			if subszoveg== "-rread" then fajlnev="report.txt"
			else fajlnev="message.txt"
			end
			user:sendPrivMsgFmt( "Listing " .. fajlnev.. ":" )
			local fajl=io.open(fajlnev,"r")
			local szoveg=""
			szoveg=fajl:read("*l")
			repeat
			     user:sendPrivMsgFmt( szoveg )
			     szoveg=fajl:read()
			until (szoveg == nil)
			fajl:close()
			user:sendPrivMsgFmt( "OK" )
		elseif string.sub(s, 1,5) == "-help" or string.sub(s, 1,2)== "-?" then
			local fajl=io.open("help.txt","r")
			local szoveg=""
			szoveg=fajl:read("*l")
			repeat
			     user:sendPrivMsgFmt( szoveg )
			     szoveg=fajl:read()
			until (szoveg == nil)
			fajl:close()
		end
	end

[B]Replacement of hub.onChatMessage function of Startup.lua[/B]

	hub.onChatMessage = function( this, user, text )
		DC():PrintDebug( this:getHubName().."> Chat from "..user:getNick()..": "..text )
	
		local s = string.lower( text )
		if string.sub(s, 1,2) == "-?" or string.sub(s,1,5) == "-help" then
			local ownNick = this:getOwnNick()
			local fajl=io.open("help.txt","r")
			local szoveg=""
			szoveg=fajl:read("*l")
			repeat
			   this:sendPrivMsgTo( user:getNick(), "<" ..ownNick.. "> "..szoveg.."|" )
			   szoveg=fajl:read()
			until (szoveg == nil)
			fajl:close()
		end

	end

[B]a sample help.txt - put this in the working directory[/B]
          --------------------------------------------------------------------------------------
          Help                                                                 BLua 0.1
          --------------------------------------------------------------------------------------
          
          -?                                                                           Help
          -help                                                                      Help
          -radd                                                  Report user to OPs
          -rread                                                           Read reports
          -madd                                           Send comment to OPs
          -mread                                                    Read comments
          --------------------------------------------------------------------------------------


SMF spam blocked by CleanTalk