mass message

Releases and bugs in here...
yakko
Posts: 258
Joined: 2003-01-27 06:04

mass message

Post by yakko » 2003-03-12 20:41

This is the mass pm script that comes with DCH++:

Code: Select all

-- Mass message, demo of how to use foreach to make a mass-PM script
-- Copyright (C) 2003 Jacek Sieka

-- Minimum level to be allowed to send PM:s
local minLevel = 2

-- Some variables used by the script
local nick = nil
local rvalue = nil
local curlevel = nil

function send(msg)
   -- This function will be called for each client currently connected
   local function sendPM(client)
      client:privateMessage("<"..nick.."> "..msg, nick)
   end

   dchpp.foreach(sendPM, curlevel)
   
   rvalue = dchpp.ACTION_STOP
end

function dchpp.clientMessage(client, message)
   local level = client:getLevel()
   if level >= minLevel then
      rvalue = nil
      nick = client:getNick()
      string.gsub(message, "^%+masspm (%Z+)", send)
      if not rvalue then
      -- Send to all op's
         curlevel = -1
         string.gsub(message, "^%+oppm (%Z+)", send)
         curlevel = nil
      end
      
      nick = nil
      return rvalue
   end
end
   


It works but sends the mass message as a pm from the sender, instead of a bot. What needs to be changed to have it sent from a "bot" (optimally the same nick that OpCom uses)? I've been trying to figure this out and can't make heads or tails of LUA.

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

Post by Sedulus » 2003-03-12 20:47

well, you could just use Executer.lua
and then send:

Code: Select all

+lua local str = "MASS MESSAGE TEST, DO NOT BE AFRAID :P" ; local function send( c ) c:privateMessage( str, "-MassMessageBot-" ) end ; dchpp.foreach( send, 0 )
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-03-12 20:50

and the script would look like:

Code: Select all

-- Mass message, demo of how to use foreach to make a mass-PM script 
-- Copyright (C) 2003 Jacek Sieka

-- Minimum level to be allowed to send PM:s
local minLevel = 2

-- Some variables used by the script
local nick = "-MassMessageBot-"
local rvalue = nil
local curlevel = nil

function send(msg)
   -- This function will be called for each client currently connected
   local function sendPM(client)
      client:privateMessage("<"..nick.."> "..msg, nick)
   end

   dchpp.foreach(sendPM, curlevel)
   
   rvalue = dchpp.ACTION_STOP
end

function dchpp.clientMessage(client, message)
   local level = client:getLevel()
   if level >= minLevel then
      rvalue = nil
--      nick = client:getNick()
      string.gsub(message, "^%+masspm (%Z+)", send)
      if not rvalue then
      -- Send to all op's
         curlevel = -1
         string.gsub(message, "^%+oppm (%Z+)", send)
         curlevel = nil
      end
       
      nick = 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)

yakko
Posts: 258
Joined: 2003-01-27 06:04

Post by yakko » 2003-03-12 21:02

w00t! thanks! I tried changing the name but I didn't have quotes. I'm learning but slowly. :)

Who is online

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