PtokaX forum

Archive => Archived 4.0 boards => Help with Lua 4 scripts => Topic started by: ?nake on 28 October, 2003, 04:00:32

Title: Multichat Help script
Post by: ?nake on 28 October, 2003, 04:00:32
hi folks can some one convert this script to lua so i can usse the MHC Bot to have a multichat server with Ptoakx.


here it goes



Dim sBotName, sOPChatName, oNoMHC, oMHCBots, sTheText, OPMsg, HubBytes, UserCount

Sub Main()
  sBotName = "MHC"             '***USE SAME NAME AS FIRST BOTNAME IN BOT
  sOPChatName = "MHOPChat"       '***ENTER NAME OF OP CHAT SCRIPT IN THIS HUB          
  Set oNoMHC = CreateObject("Scripting.Dictionary")
  Set oMHCBots = CreateObject("Scripting.Dictionary")
End Sub

Sub NewUserConnected(curUser)
curUser.SendChatMessage cstr(sBotName), "For those users not wishing to view MultiHubChat, these triggers are available:"+vbCrLf+"                                             ?   mhchide   ?   mhcshow   ?"
End Sub

Sub DataArival(curUser, sCurData)

If Left(sCurData, 12) = "$GetNickList" and curUser.bOperator Then        '***MAKES OPCHAT BOT INVISIBLE TO NON-OPS
  curUser.SendData "$Hello "+CStr(sOPChatName)+"|$MyINFO $ALL "+Cstr(sOPChatName)+" OP Chat Room$ $Chat"+chr(8)+"$"+frmHub.txtIP+"$"+"0"+"$|"
End If
If (Left(sCurData, 5 + Len(sOPChatName)) = "$To: "+sOPChatName) Then     '***DEALS WITH OP CHAT
    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 "$To: "+usrOP.sName+" From: "+Cstr(sOPChatName)+" $<"+curUser.sName+"> "+cstr(OPMsg)+"|"         '***LOCAL OPCHAT
       End If
      End If
     Next  
    colUsers.ItemByName(cstr(sBotName)).SendChatMessage "???","?"+CurUser.sName+"?"+cstr(OPMsg)   '***REMOTE OPCHAT
End If

If Left(sCurdata, 1) = "<" Then                                          '***ALLOWS USER TO VIEW OR HIDE MHC
  sTheText = AfterFirst(sCurData, "> ")
   If LCase(sTheText) = "mhchide" Then
     If Not oNoMHC.Exists(LCase(curUser.sname)) Then oNoMHC(LCase(curUser.sname))= "blocked": curUser.SendChatMessage cstr(sBotName), "You have chosen not to view MultiHub Chat."
   ElseIf LCase(sTheText) = "mhcshow" then
     If oNoMHC.Exists(LCase(curUser.sname)) Then oNoMHC.Remove(LCase(curUser.sname)): curUser.SendChatMessage cstr(sBotName), "You have chosen to view MultiHub Chat."
   End If
   
ElseIf Left(sCurdata, 4) = "$FW " Or Left(sCurdata, 6) = "$FWOC " Then   '***PROCESSES DATA FROM REMOTE HUBS
    sRemUser = BeforeFirst(AfterFirst(sCurData, " "), " ")
    sRemMsg = AfterFirst(AfterFirst(sCurData, " "), " ")
      If Left(sCurdata, 6) = "$FWOC " Then
          For Each usrOP In colUsers
            If usrOP.bOperator Then usrOP.SendData CStr("$To: "+usrOP.sName+" From: "+sOPChatName+" $<"+CStr(sRemUser)+"> "+CStr(sRemMsg))
          Next    
      ElseIf Left(sCurdata, 4) = "$FW " Then
         For Each usr In ColUsers
          If Not oNoMHC.Exists(LCase(cstr(usr.sname))) Then usr.SendChatMessage CStr(sRemUser), CStr(sRemMsg)
         Next  
      End If

ElseIf Left(sCurData, 13) = "$MyINFO $ALL " Then                           '***STOPS MHC BOTS FROM BEING COUNTED IN HUB BYTES
  If Right(BeforeFirst(AfterFirst(sCurData, "$ $"), "$"),1)=chr(108) Then
    If Not oMHCBots.exists(LCase(curUser.sName)) Then oMHCBots(LCase(curUser.sName)) = " "
  End If  

ElseIf Left(sCurData, 11) = "$GetHubInfo" Then                             '***GATHERS HUB USERCOUNT & SHARE
    HubBytes = 0  
    For each User in colUsers
      If Not oMHCBots.exists(LCase(cstr(User.sName))) Then HubBytes = HubBytes+User.ibytesshared
    Next
    Usercount = cstr(colusers.Count)
    colUsers.ItemByName(cstr(sBotName)).SendChatMessage "???", "?"+Cstr(UserCount)+"?"+cstr(HubBytes)
End If

End Sub

Function BeforeFirst(sIn, sFirst)              
    BeforeFirst = Left(sIn, InStr(1, sIn, sFirst) - 1)
End Function
Function AfterFirst(sIn, sFirst)  
    AfterFirst = Right(sIn, Len(sIn) - InStr(1, sIn, sFirst) - (Len(sFirst) - 1))
End Function




if you do i will be thank full and you will be te king of
lua :-P peace m8s :)

btw if i remmber correctlly some on alredy made it on the old forume does some one has it ?
Title:
Post by: lazyj189 on 28 October, 2003, 08:40:19
I dont think you need that script.  There is a multihub server program that does work to make the mainchat do multihub.  Still doesnt work on multihubbing the opchaat or anything else.
Title:
Post by: ?nake on 28 October, 2003, 15:23:03
? sorry but what do you mean?
the inbilt multi hub chat?
well it still dosent work on Ptoakx. but i know if i can get this script in lua it will work 8o
Title:
Post by: lazyj189 on 28 October, 2003, 16:24:01
Yes, the built in multihub will work as long as you have the multihub server program which is external from the ptokax hub.  There's a link around here somewhere as to where you can download it.  Gotta leave for work righ tnow, so I'll look for it later tonight my time for ya.
Title:
Post by: [T-G-T]M@sto on 21 November, 2003, 07:48:07
QuoteOriginally posted by lazyj189
Yes, the built in multihub will work as long as you have the multihub server program which is external from the ptokax hub.  There's a link around here somewhere as to where you can download it.  Gotta leave for work righ tnow, so I'll look for it later tonight my time for ya.
Timis Up  :D