PtokaX forum

Archive => Archived 5.1 boards => Help with scripts => Topic started by: speedX on 05 October, 2006, 22:16:17

Title: IP BOT [Mutor]
Post by: speedX on 05 October, 2006, 22:16:17
Quote
--IPLog 1.0e LUA 5.1
--
--by Mutor 7/3/05
--requested by bigfnpump
--
-- Logs user IP & Nick, get info by command
-- Provides right click menu
--
--   +Changes from 1.0 7/5/05
--      +Now retrieves IP from nick input as well as nick from IP input
--
--
--   +Changes from 1.0b 7/7/05
--      +Reply now sent in PM   -Request by CaSaNoVa
--
--   +Changes from 1.0c 7/9/05
--      -Removed 2 table loops
--
--   +Changes from 1.0d 9/2/05
--      +Send IP info to all users.   --Request by hell
--
--   +Changes 5/11/06
--      +Converted to LUA 5.1
--
--User Settings----------------------------------------------------------------------------------------------------------------
--
--//-- Botname pulled from the hub
Bot = frmHub:GetHubBotName()
Prefix = "+"         -- Command Prefix
IpCmd = "ip"         -- Get IP User Command
IpMenu = frmHub:GetHubName()   -- Menu name pulled form hub, uses hub name for menu
SubMenu0 ="IP Log"      -- Custom submenu
IPFile="IPLog.dat"
--//--Set your profiles here.
--profile_idx, Commands/Menus enabled [0=no 1=yes], "Profile Name"
IpProfiles = {
[-1] = {1,"Unregistered User"},
  • = {1,"Master"},
    [1] = {1,"Operator"},
    [2] = {1,"Vip"},
    [3] = {1,"Registered User"},
    [4] = {1,"Moderator"},
    [5] = {1,"NetFounder"},
    }
    --
    --End User Settings-------------------------------------------------------------------------------------------------------------

    function Main()
       if loadfile(IPFile) ~= nil then
          dofile(IPFile)
       else
          IPLog ={}
          Save_File(IPFile,IPLog,"IPLog")
       end
    end

    function OnExit()
    Save_File(IPFile,IPLog,"IPLog")
    end

    function NewUserConnected(user, data)
    local timein=os.date("%B %d %Y %X ")
    IPLog[user.sIP]={user.sName,timein}
    Save_File(IPFile,IPLog,"IPLog")
       if IpProfiles[user.iProfile][1] == 1 then
          Commands(user)
          user:SendData(Bot, IpProfiles[user.iProfile][2].."'s IP Log commands enabled. Right click hub tab or user list for command menu.")
       end
    end

    OpConnected = NewUserConnected

    function ChatArrival(user, data)
    local s,e,pre,cmd = string.find(data, "%b<>%s+(%p)(%S+)")
    local s,e,addy = string.find(data, "%s(%d+%.%d+%.%d+%.%d+)|$")
    local s,e,nick = string.find(data, "%s(%S+)|$")
       if IpProfiles[user.iProfile][1] == 1 then
             if pre and pre==Prefix then
                if (cmd==IpCmd) then
                   if nick and nick ~= addy then
                      local errmsg="\r\n\r\n\tThe user "..nick.." was not found in the log.\r\n"
                      for i,v in pairs(IPLog) do
                         if v[1]==nick then
                            local reply2="\r\n\r\n\tThe user "..v[1].." was last seen "..
                            "using the IP Address of "..i.." on "..v[2]..".\r\n\r\n"
                            SendToAll(reply2)
                            errmsg = nil
                            break
                         end
                      end
                      if errmsg ~= nil then
                         SendToAll(errmsg)
                      --return 1
                      end
                   end
                   if addy and IPLog[addy]==nil then
                      local errmsg="\r\n\r\n\tThe IP Address "..addy.." was not found in the log.\r\n"
                      SendToAll(errmsg)
                      --return 1
                   else
                      for i,v in pairs(IPLog) do
                         if i==addy then
                            local reply1="\r\n\r\n\tThe IP Address "..i.." was last used "..
                            "by "..v[1].." on "..v[2]..".\r\n\r\n"
                            SendToAll(reply1)
                            break
                         end
                      end
                      --return 1
                   end
                elseif (pre==Prefix) and (cmd==IpCmd) and not addy then
                      SendToAll("\r\n\r\n\tSyntax Error, Syntax = "..Prefix..IpCmd.." <IP or Nick>\r\n")
                --return 1
                end
             end
       end
    end

    function Commands(user)
       user:SendData("$UserCommand 255 7")   --clear the menu first
       user:SendData("$UserCommand 1 1 "..IpMenu.."\\"..SubMenu0.."\\IP Info $<%[mynick]> "..Prefix..IpCmd.." %[line:IP or Nick]&#124;|")
       user:SendData("$UserCommand 1 2 "..IpMenu.."\\"..SubMenu0.."\\IP From Nick $<%[mynick]> "..Prefix..IpCmd.." %[nick]&#124;|")
       user:SendData("$UserCommand 1 2 "..IpMenu.."\\"..SubMenu0.."\\Nick From IP$<%[mynick]> "..Prefix..IpCmd.." %[line:IP]&#124;|")
    end

    Save_Serialize = function(tTable, sTableName, hFile, sTab)
       sTab = sTab or "";
       hFile:write(sTab..sTableName.." = {\n" );
       for key, value in pairs(tTable) do
          local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
          if(type(value) == "table") then
             Save_Serialize(value, sKey, hFile, sTab.."\t");
          else
             local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
             hFile:write( sTab.."\t"..sKey.." = "..sValue);
          end
          hFile:write( ",\n");
       end
       hFile:write( sTab.."}");
    end

    Save_File = function(file,table , tablename )
       local hFile = io.open (file , "w")
       Save_Serialize(table, tablename, hFile);
       hFile:close()
    end
Hello Mutor.....could u plzz modify the above teh script in such a way tht the command comes b4 the result.....?? plzzz
Title: Re: IP BOT [Mutor]
Post by: speedX on 05 October, 2006, 22:29:20
ya....i kno...i was searchin for tht thread......but didnt get it.......tht's y i had to post a new thread......
Title: Re: IP BOT [Mutor]
Post by: speedX on 05 October, 2006, 23:06:19
plzz would u help me out mutor......
Title: Re: IP BOT [Mutor]
Post by: bastya_elvtars on 05 October, 2006, 23:42:02
Quote from: Mutor on 05 October, 2006, 22:53:33
Well I wonder what happened to that thread....   hmmm

Perhaps it was created between the DB save and the crash of the old server, therefore it's lost.
Title: Re: IP BOT [Mutor]
Post by: bastya_elvtars on 05 October, 2006, 23:52:03
Quote from: Mutor on 05 October, 2006, 23:43:48
That was my first thought, but the dates don't jive.

Oh well

I don't know. It is a miracle in itself that we did not have to start from scratch.
Title: Re: IP BOT [Mutor]
Post by: speedX on 06 October, 2006, 07:09:55
hey could plzz use
Quote
coz its diff to copy tht script.....
Title: Re: IP BOT [Mutor]
Post by: Herodes on 06 October, 2006, 08:13:41
Quote from: speedX on 06 October, 2006, 07:09:55
hey could plzz use   coz its diff to copy tht script.....
click on the 'quote' button on Mutor's post and grab the code from the post 'reply page' that you get after clicking,...
Title: Re: IP BOT [Mutor]
Post by: speedX on 06 October, 2006, 08:49:54
Hey thx for the tip Herodes......hey Mutor when a user type !getip <nick>  it shows tht the bot is giving the command is it possible for the nick to come instead of Bot name ??
Title: Re: IP BOT [Mutor]
Post by: Psycho_Chihuahua on 06 October, 2006, 09:28:34
well that seems so easy to do and i'm sure if you have a good look at the script you would find out what to change yourself.


My guess would be to change this line:
SendToAll(Bot,msg)
to something like:
SendToAll(user,msg)
Title: Re: IP BOT [Mutor]
Post by: speedX on 06 October, 2006, 10:53:32
nope....not workin with tht change..