0.16 scripts

Releases and bugs in here...
Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 14:32

0.16 scripts

Post by Sedulus » 2003-02-12 22:44

error in new Executer.lua, see the XXX's
complete file:

Code: Select all

-- This script enables users to execute lua commands from the main chat
-- Note; it is very dangerous to allow normal users to do this as there are very few security checks done along the way
-- (especially for the disconnect command, and the whole system library (with file ops) in lua)
-- Copyright (C) 2003 Jacek Sieka

-- Minimum level to be allowed to execute LUA commands / files
local minLevel = 3

-- This variable represents the client that's executing the command (use it in your
-- command if you want to: "+lua me:hubMessage(me:getIp())" sends you your ip...
me = nil        -- XXX cannot be a local value, since loadstring() needs it
local rvalue = nil

local function execute(str)     -- XXX this may be local however ;)
        local f, e = loadstring(str)
        if f then
                x, e = pcall(f)
        end

        if(e) then
                me:hubMessage(e)
        else
                me:hubMessage("Script executed OK!")
        end

        rvalue = dchpp.ACTION_HANDLED   -- XXX whoops, forgot the dchpp namespace
end

function dchpp.clientMessage(client, message)
        local level = client:getLevel()
        if level >= minLevel then
                rvalue = nil
                me = client
                string.gsub(message, "^%+lua (%Z+)", execute)
                me = nil
                return rvalue
        end
end
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 14:32

Post by Sedulus » 2003-02-12 22:58

AutoBot.lua:

Code: Select all

function dchpp.clientValidateNick(client, nick)
        if strfind(strlower(nick), "moglo", 1)  then
                client:disconnect()
                return dchpp.ACTION_HANDLED
        end
end
this piece contains lua4 scripting, but an error is never fired.
cause: dchpp.clientValidateNick() is never called.
workaround... don't use it until it's fixed.
<<edit: fixed in next version>>
Last edited by Sedulus on 2003-02-14 13:54, edited 1 time in total.
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 14:32

Post by Sedulus » 2003-02-12 23:18

dchpp.sendToAll() has ceased to function...

include the following in your lua scripts as a workaround:

Code: Select all

function dchpp.sendToAll( parm1, parm2 )
    if parm2 then
        error( "sorry... I have no clue who is passive, don't use the second parm", 2 )
    end
    local function send( client )
        client:send( parm1 )
    end
    dchpp.foreach( send, 0 )
end

[edit: fixed ugly formatting]
<<edit: fixed in next version>>
Last edited by Sedulus on 2003-02-14 13:54, edited 1 time in total.
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

Sedulus
Forum Moderator
Posts: 687
Joined: 2003-01-04 14:32

Post by Sedulus » 2003-02-12 23:41

updated (temporary) NATusers.lua that works with 0.16:

Code: Select all

-- vim:ts=4:sw=4:noet
-- NATusers.lua for DCH++ (0.16) by Sedulus, 20030213, no rights reserved
--
-- A hack to allow owners of hubs to $ConnectToMe and $Search in their own hub,
-- without having to go passive mode (because the IP doesn't match the login IP).

-- add usernames here
local NATusers = {
    ["[Rug.nl]Sedulus"] = 1,
    ["sed"] = 1,
}

function dchpp.clientMessage( client, msg )
    if msg == "-help" then
        local str = "\r\n"..
            "This hub has NATusers.lua installed. The following users may "..
            "use IP's that they did not log in with:\r\n"..
            "\r\n"
        for key, elem in NATusers do
            str = str..key.."\r\n"
        end
        client:hubMessage( str )
    end
end

function dchpp.clientLine( client, msg )
    if NATusers[client:getNick()] then
        local ret,c,othernick
        ret,c,othernick = string.find( msg, "^$ConnectToMe ([^ ]+) " )
        if ret then
            local otherclient = dchpp.getClient( othernick )
            if otherclient then
                otherclient:send( msg )
            end
            return dchpp.ACTION_HANDLED
        end
        ret,c = string.find( msg, "^$Search " )
        if ret then
            local function send( client )   -- XXX workaround
                client:send( msg )          -- XXX workaround
            end                             -- XXX workaround
            dchpp.foreach( send, 0 )        -- XXX workaround
--          dchpp.sendToAll( msg )          -- temporarily commented out
            return dchpp.ACTION_HANDLED
        end
    end
end
http://dc.selwerd.nl/hublist.xml.bz2
http://www.b.ali.btinternet.co.uk/DCPlusPlus/index.html (TheParanoidOne's DC++ Guide)
http://www.dslreports.com/faq/dc (BSOD2600's Direct Connect FAQ)

Who is online

Users browsing this forum: Google [Bot] and 0 guests