I need help converting a script
 

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

I need help converting a script

Started by Skimoney22, 05 February, 2004, 04:06:59

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Skimoney22

I used a script in my old NMDC hub that was called Helper bot , is there any way someone could make a script like this for me in Ptokax? I see that there are         !network and !rules in Robocop, but I would like to add quite a few more. Probaly around 300-400 textfiles with commands.


' This script finds and reads a specific .txt file
'      And displays the content as a private message
'           Works great in addition to general bot
'
' add as many commands as nessesary just make sure the .txt file exists
' and that "(sTheText, 6)))" is correct (number of letters in the command
' Make sure the loggpath is correct
'
'   Made by: Gadget and  Manic_Depresiv_Santa
'
Dim sBotName, LoggPath

Sub Main()
sBotName="[HELPER]"           '<---- The HelperBots name
LoggPath = "C:\Programmer\dchub1500\Scripts\"           '<---- Path to the .txt files
End Sub

Sub DataArival(curUser, sCurData)
If (Left(sCurdata, 1) = "<") Then

lPos = InStr(1, sCurData, "> ")
sTheText = Mid(sCurData, lPos + 2)

'------------------Users and OPs can use these commands-------------------------
if (lcase(Left(sTheText, 6))) = "+rules" then
curUser.PrivateMessage cstr(sBotName), cstr(Read("rules.txt"))
End If

if (lcase(Left(sTheText, 8))) = "+network" then
curUser.PrivateMessage cstr(sBotName), cstr(Read("network.txt"))
End If

'------------------Only OPs can use these commands-------------------------------
if (lcase(Left(sTheText, 8))) = "+oprules" and curUser.bOperator = true then
curUser.PrivateMessage cstr(sBotName), cstr(Read("oprules.txt"))
End If

End If
End Sub

Function Read(TextFile)
Dim temp
Set fs = CreateObject("Scripting.FileSystemObject")
Set a = fs.OpenTextFile(LoggPath & TextFile, 1, false)
temp = a.ReadAll
a.Close
Set a = nothing
Set fs = nothing
Read = temp
End Function


plop

small question: could you next time try a search 1st, the next script posted a couple times allready.
-- texter bot by plop
-- thx 2 chilla for the faster routine for opening the files
-- shows text files from a folder named text.
-- doesn't mather what prefix it used.
-- if the file excist it shows.

Bot = "something"
FDFolder = "text"

function Main()
   frmHub:RegBot(Bot)
end

function DataArrival(user, data)
   data=strsub(data,1,strlen(data)-1) 
   if( strsub(data, 1, 1) == "<" ) then
      s,e,cmd = strfind(data,"%b<>%s+(%S+)") 
      cmd = strsub(cmd, 2,strlen(cmd))
      if readfrom(FDFolder.."/"..cmd..".txt") then
         showtext(user, cmd)
         return 1
      end
   elseif(strsub(data, 1, 4) == "$To:") then
      s,e,cmd = strfind(data,"$To:%s+%S+%s+From:%s+%S+%s+$%b<>%s+(%S+)")
      cmd = strsub(cmd, 2,strlen(cmd))
      if readfrom(FDFolder.."/"..cmd..".txt") then
         showtext(user, cmd)
         return 1
      end
   end
end

function showtext(user, file)
	local handle = openfile(FDFolder.."/"..file..".txt", "r")
	local contents = gsub(read(handle, "*a"),strchar(10), "\r\n")
	closefile (handle)
	user:SendPM(Bot, "\r\n"..contents.."\r\n|")
end

plop
http://www.plop.nl lua scripts/howto\'s.
http://www.thegoldenangel.net
http://www.vikingshub.com
http://www.lua.org

>>----> he who fights hatred with hatred, drives the spreading of hatred <----<<

SMF spam blocked by CleanTalk