PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Neospider69 on 24 December, 2003, 02:41:31

Title: Translate VB to LUA
Post by: Neospider69 on 24 December, 2003, 02:41:31
I need some help, i need to translate this script to LUA, Can anyone help me? Is there someone here that will take the challenge???

Here?s the script


Dim sBotName, sOPChatName, oNoDCHL, oDCHLBots, sTheText, OPMsg, HubBytes, UserCount, bIPAddPM, bIPFixPM

Sub Main()
  sBotName = "CineMania"              '***USE SAME NAME AS BOT NAME IN HUB-LINK
  sOPChatName = "CineChat"       '***ENTER NAME OF OP CHAT SCRIPT IN THIS HUB
  bIPAddPM = True '***Send User a PM if IP # is blank in Connect requests?
  bIPFixPM = True '***Send User a PM if IP # is wrong in Connect requests?
  Set oNoDCHL = CreateObject("Scripting.Dictionary")   '*** USERS WHO DO NOT WANT TO RECIEVE CHAT FROM REMOTE HUBS
  Set oDCHLBots = CreateObject("Scripting.Dictionary") '*** BOTS WHICH SHOULD NOT BE COUNTED IN HUB TOTALS
End Sub

Sub NewUserConnected(curUser)
   'curUser.SendChatMessage cstr(sBotName), "For those users not wishing to view MultiHubChat, these triggers are available:"+vbCrlf+"?   DCHLhide   ?   DCHLshow   ?"
   If curUser.sname = sBotName Then  '*** SEND HUB-LINK THE $MyINFO STRING FOR ALL CONNECTED USERS.
    For Each usr In colUsers
    If Not usr.sname = sBotName Then curUser.SendData "$Hello " & usr.sname & "|" & usr.sMyInfoString & "|"
    Next
   Else
    Call CheckUserName(curUser.sName) '*** VALIDATE THAT THE USERNAME IS AVAILABLE IN HUB-LINK
   End If
End Sub

Sub OpConnected(curUser)
   Call NewUserConnected(curUser)
End Sub

Sub CheckUserName(UserName)
colUsers.ItemByName(cstr(sBotName)).SendData "$#TUN " & UserName & "|"
End Sub

Sub DataArival(curUser, sCurData)

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''' Process Main Chat User Commands First and then Exit Sub   '''
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

If AscW(sCurData) = 60 Then                            '***ALLOWS USER TO VIEW OR HIDE CHAT FROM REMOTE HUBS
   sTheText = AfterFirst(sCurData, "> ")
   Select Case LCase(sTheText)

   Case "dchlhide"
      If Not oNoDCHL.Exists(LCase(curUser.sname)) Then
         oNoDCHL(LCase(curUser.sname))= "blocked"
         curUser.SendChatMessage cstr(sBotName), "You have chosen not to view MultiHub Chat."
         Exit Sub
      End If

   Case "dchlshow"
      If oNoDCHL.Exists(LCase(curUser.sname)) Then
         oNoDCHL.Remove(LCase(curUser.sname))
         curUser.SendChatMessage cstr(sBotName), "You have chosen to view MultiHub Chat."
         Exit Sub
      End If

   Case Else
      Exit Sub

End Select

End If

''''''''''''''''''''''''''''''''''''''''
''' Process DC and HUB-LINK Commands '''
''''''''''''''''''''''''''''''''''''''''

If AscW(sCurData) = 36 Then
   Select Case Trim(BeforeFirst(sCurData & " ", " "))

'''''''''''''''''''''''''''''''
''' Commands Sent by Users  '''
'''''''''''''''''''''''''''''''

  Case "$GetNickList" '***MAKES OPCHAT BOT VISIBLE TO OPs ONLY
If curUser.bOperator And Not curUser.sName = sBotName Then
curUser.SendData "$Hello " + CStr(sOPChatName)+"|"
If Not curUser.sName = sBotName Then
curUser.SendData "$MyINFO $ALL "+Cstr(sOPChatName)+" OP Chat Room$ $Chat"+chr(8)+"$"+frmHub.txtIP+"$"+"0"+"$|"
End If
End If
If Not curUser.sName = sBotName Then colUsers.ItemByName(cstr(sBotName)).SendData "$#GNL "+curUser.sName+"|"

Case "$ConnectToMe"          '***RELAY ACTIVE CONNECT REQUESTS TO REMOTE USERS (ALSO VALIDATES/CORRECTS IP)
If Not curUser.sName = sBotName Then
         CTMTo = BeforeFirst(AfterFirst(sCurData, " "), " ")
If Not colUsers.Online(CStr(CTMTo)) Then
CTMMsg = AfterFirst(AfterFirst(sCurData, " "), " ")
          CTMMsgIP = BeforeFirst(AfterFirst(AfterFirst(sCurData, " "), " "), ":")
          CTMIP = curUser.IP
          If Mid(CTMMsg, InStr(CTMMsg, ":") - 1, 1) = " " Then
            CTMMsg = Replace(CTMMsg, ":", curUser.IP & ":")
            If bIPAddPM Then curUser.SendData "$To: " & curUser.sName & " From: " & sBotName & " $<" & sBotName & "> " & "Your connection request for " & CTMTo & " did not include an IP Address. To stop this message please put the IP " & CTMIP & " in your connection settings. If you have a dynamic IP you can get a free DNS name from www.no-ip.com and put that in instead.|"
          Elseif Not CTMMsgIP = CTMIP Then
            If Not CTMIP = "127.0.0.1" And Not Left(CTMIP, 7) = "192.168" Then   ' Make sure it's not a local hubowner.
                CTMMsg = Replace(CTMMsg, CTMMsgIP, curUser.IP)
                If bIPFixPM Then curUser.SendData "$To: " & curUser.sName & " From: " & sBotName & " $<" & sBotName & "> " & "You have the wrong IP address in your connection settings. To stop this message please update it to read " & CTMIP & "|"
            End If
          End If
colUsers.ItemByName(cstr(sBotName)).SendData "$#CTM " & CTMTo & " " & CTMMsg & "|"
End If
End If

Case "$RevConnectToMe"        '***RELAY PASSIVE CONNECT REQUESTS TO REMOTE USERS
If Not curUser.sName = sBotName Then
sUserName = AfterFirst(AfterFirst(sCurData," ")," ")
If Not colUsers.Online(CStr(sUserName)) Then
colUsers.ItemByName(cstr(sBotName)).SendData "$#RTM" & AfterFirst(sCurData, "$RevConnectToMe") & "|"
End If
End If

Case "$To:" '***DEALS WITH OP CHAT
sUserName = BeforeFirst(AfterFirst(sCurData, " "), " ")
If sUserName = sOPChatName Then    
OPMsg = AfterFirst(sCurData, "> ")
For Each usrOP In colUsers
If usrOP.bOperator Then
If usrOP.sName = curUser.sName Or usrOP.sName = sBotName Then
Else
usrOP.SendData CStr("$To: "+usrOP.sName+" From: "+sOPChatName+" $<"+Cstr(curUser.sName)+"> "+Cstr(OPMsg)+"|")   '***LOCAL OPCHAT
End If
End If
Next  
colUsers.ItemByName(cstr(sBotName)).SendChatMessage "???","?"+CurUser.sName+"?"+cstr(OPMsg)   '***REMOTE OPCHAT
Else         '***DEALS WITH PRIVATE MESSAGES TO REMOTE HUBS (**WARNING** PM'S TO LOCAL BOTS ARE ALSO PICKED UP)
If Not colUsers.Online(CStr(sUserName)) And  Not sUserName = "Vandel\Debug" Then
colUsers.ItemByName(cstr(sBotName)).SendData "$#PRM " & AfterFirst(sCurData, " ")
End If
End If

Case "$Hello", "$Quit"   'SENDS REMOTE JOINS AND PARTS TO USERS ON THE LOCAL HUB.
If curUser.sName = sBotName Then
For Each usr In ColUsers
If Not usr.sName = sBotName Then
If Not AfterFirst(sCurData, " ") = sOPChatName Then
usr.SendData sCurData + "|"
End If
End If
Next
End If

Case "$MyINFO" '*** STOPS HUB-LINK BOTS FROM BEING COUNTED IN HUB BYTES
If Mid(sCurdata, 9, 5) = "$ALL " Then
If Right(BeforeFirst(AfterFirst(sCurData, "$ $"), "$"),1)=chr(108) Then
If Not oDCHLBots.exists(LCase(curUser.sName)) Then oDCHLBots(LCase(curUser.sName)) = " "
End If
End If

Case "$Kick"                  '*** RELAYS KICK COMMAND FOR USERS WHO ARE NOT LOCAL
sUserName = AfterFirst(sCurData, " ")
If Not colUsers.Online(CStr(sUserName)) Then
colUsers.ItemByName(cstr(sBotName)).SendData "$#KCK " & curUser.sName & " " & AfterFirst(sCurData, " ")
End If

Case "$OpForceMove"           '*** RELAYS RE-DIRECT COMMAND FOR USERS WHO ARE NOT LOCAL
sRedirWho = BeforeFirst(AfterFirst(sCurData, "$Who:"), "$")
If Not colUsers.Online(CStr(sRedirWho)) Then
colUsers.ItemByName(cstr(sBotName)).SendData "$#OFM " & curUser.sName & " " & AfterFirst(sCurData, " ")
End If


'''''''''''''''''''''''''''''''''
''' Commands Sent by HUB-LINK '''
'''''''''''''''''''''''''''''''''

Case "$#INF"                '*** SEND $MyINFO FOR LINKED HUBS TO ALL CONNECTED USERS
sSendtoWho = BeforeFirst(AfterFirst(sCurData, " "), " ")
If sSendToWho = "$ALL" Then
For Each usr In colUsers
If Not usr.sName = sBotName Then usr.SendData "$MyINFO " & AfterFirst(sCurData, " ") & "|"
Next
Else                    '***  OR JUST TO THE USER WHO REQUESTED IT.
colUsers.ItemByName(cstr(sSendToWho)).SendData "$MyINFO $ALL " & AfterFirst(AfterFirst(sCurData, " "), " ") & "|"
End If

Case "$#OPL"               '*** RE-SEND OPLIST WHICH INCLUDES ALL OPS FROM LINKED HUBS
For Each usr In colUsers
If Not usr.sName = sBotName Then
If usr.bOperator Then
usr.SendData "$OpList " & AfterFirst(sCurData, " ") & sOpChatName & "$$|"
Else
usr.SendData "$OpList " & AfterFirst(sCurData, " ") & "|"
End If
End If
Next

Case "$RS"     '*** RELAY A SEARCH REQUEST
        For Each User In ColUsers
           If User.sName <> sBotName Then
              User.SendData CStr(mid(sCurData,5))
           End If
        Next

Case "$FW" '*** PROCESSES MAIN CHAT FROM REMOTE HUBS
sRemUser = BeforeFirst(AfterFirst(sCurData, " "), " ")
sRemMsg = AfterFirst(AfterFirst(sCurData, " "), " ")
For Each usr In ColUsers
If Not oNoDCHL.Exists(LCase(cstr(usr.sname))) And Not usr.sname = sBotName Then
usr.SendChatMessage CStr(sRemUser), CStr(sRemMsg)
End If
Next  

Case "$FWOC" '*** PROCESSES OPCHAT FROM REMOTE HUBS
sRemUser = BeforeFirst(AfterFirst(sCurData, " "), " ")
sRemMsg = AfterFirst(AfterFirst(sCurData, " "), " ")
For Each usrOP In colUsers
If usrOP.bOperator And Not usrOP.sname = sBotName Then
usrOP.SendData CStr("$To: "+usrOP.sName+" From: "+sOPChatName+" $<"+CStr(sRemUser)+"> "+CStr(sRemMsg))
End If
Next    

Case "$#PRM"                  '*** PROCESSES PRIVATE MESSAGES FROM REMOTE HUBS
sLocUser = BeforeFirst(AfterFirst(sCurData, " "), " ")
sRemUser = BeforeFirst(AfterFirst(sCurData, "From: "), " ")
sRemPrfx = BeforeFirst(AfterFirst(AfterFirst(sCurData, "$"), "$"), " ")
sRemMsg = AfterFirst(sCurData, "> ")
colUsers.ItemByName(cstr(sLocUser)).SendData "$To: " & sLocUser & " From: " & sRemUser & " $" & sRemPrfx & " " & sRemMsg & "|"

Case "$#GMI"                  '*** SENDS $GetInfo TO REQUESTED CLIENT.
sLocUser = BeforeFirst(AfterFirst(sCurData, " "), " ")
colUsers.ItemByName(cstr(sLocUser)).SendData ("$GetINFO " & AfterFirst(sCurData, " ") & "|")

Case "$GetHubInfo" '*** GATHERS HUB USERCOUNT & SHARE
HubBytes = 0
For Each User In colUsers
If Not oDCHLBots.exists(LCase(cstr(User.sName))) Then HubBytes = HubBytes+User.ibytesshared
Next
Usercount = cstr(colusers.Count)
colUsers.ItemByName(cstr(sBotName)).SendChatMessage "???", "?"+Cstr(UserCount)+"?"+cstr(HubBytes)

Case "$#UNT"                  '*** ACCEPT OR DISCONNECT USER BASED ON RESPONSE FROM HUB LINK
sLocUser = BeforeFirst(AfterFirst(sCurData, " "), " ")
Result = AfterFirst(AfterFirst(sCurData, " "), " ")
If Not Result = "OK" Then
colUsers.ItemByName(cstr(sLocUser)).SendData "<" & sBotName & "> " & "The user name " & sLocUser & " is already taken." & "|"
frmHub.DoEventsForMe
colUsers.ItemByName(cstr(sLocUser)).disconnect
End If
End Select

End If

End Sub


''''''''''''''''''''''''
''' String Functions '''
''''''''''''''''''''''''


Function BeforeFirst(sIn, sFirst)              
    BeforeFirst = LeftB(sIn, InStrB(1, sIn, sFirst) - 1)
End Function

Function AfterFirst(sIn, sFirst)  
    AfterFirst = RightB(sIn, LenB(sIn) - InStrB(1, sIn, sFirst) - LenB(sFirst) + 1)
End Function


Title:
Post by: plop on 24 December, 2003, 03:15:40
looks like a bot 2 connect multiple hubs with chat and downloads.
you have 2 wait untill the modded multihub server is ready.
currently the original mhs only links the chats.

plop
Title:
Post by: Neospider69 on 24 December, 2003, 16:30:26
HUMMM

that?s for when?
Title:
Post by: plop on 24 December, 2003, 18:00:20
check here (http://board.univ-angers.fr/thread.php?threadid=544&boardid=11&sid=865bf83366cc3ef17f165af4328f1ca5)

plop
Title:
Post by: HaArD on 27 December, 2003, 07:26:27
A PtokaX script is currently under development....
Title:
Post by: Neospider69 on 27 December, 2003, 12:09:38
WEEEEEEE

Tks a lot

You're an angel who came to save me from the hell of neomodus

lol

BCool
Title:
Post by: DoN on 29 January, 2004, 18:42:20
Just out of interest did any one ever managed to translate this script?? I know another one called "GeneralBot script v0.241 by Gadget
It looks a bit like this. Or maybe this is just a revamped version. Is converting from VB to LUA extremely hard :rolleyes:
Because I would like to use the General Bot under ptokax but sadly I cant as its VB.. ;(


Brgs
Title:
Post by: plop on 29 January, 2004, 22:09:24
QuoteOriginally posted by DoN
Just out of interest did any one ever managed to translate this script?? I know another one called "GeneralBot script v0.241 by Gadget
It looks a bit like this. Or maybe this is just a revamped version. Is converting from VB to LUA extremely hard :rolleyes:
Because I would like to use the General Bot under ptokax but sadly I cant as its VB.. ;(


Brgs
why convert general bot when there are better bot's allready availeble for ptokax??
some commands you won't find in them but they are either worthless or not posible or bad for your hub (causing lag).

plop
Title:
Post by: Neospider69 on 29 January, 2004, 22:40:45
I recommend Channel Bot 4.3c_fix
Title:
Post by: DoN on 29 January, 2004, 22:41:26
QuoteOriginally posted by plop
why convert general bot when there are better bot's allready availeble for ptokax??
some commands you won't find in them but they are either worthless or not posible or bad for your hub (causing lag).

plop

I dont know. I've tried some bots but maybe its just my incompetencance of actually using the bot to the full potential.
That I dont actually see a good thing when its sittin there under my nose.

Brgs
Title:
Post by: plop on 29 January, 2004, 23:02:58
QuoteOriginally posted by DoN
I dont know. I've tried some bots but maybe its just my incompetencance of actually using the bot to the full potential.
That I dont actually see a good thing when its sittin there under my nose.

Brgs
try them all for a couple day's and i bet you find 1 which fits yours needs or comes really close 2 it.
if it's the last you can always ask the creator 2 add the things your missing in it.
if you want a bot with loads of options/commands your gone like channelbot, but it's heavy (called a beast by a couple ppl, inc me).
if your a starter on ptokax i suggest robocop, it's good and really easy 2 use/configure.

plop