PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: DoJIN on 05 January, 2004, 17:14:15

Title: err not ptokax bound but its lua
Post by: DoJIN on 05 January, 2004, 17:14:15
hey  im testing the lua integration for my client

i need a lua script that executes  a ban command when some1 advertises in main chat

so as example some1 says:

<[TUC]?Niederweit>bla.no-ip.com

it will respond with

+pban [TUC] Niederweit Advertisement is forbidden

can this be done? and who is willing to create it
Title:
Post by: plop on 05 January, 2004, 17:33:11
try the search button from this forum.
there are a couple diferent versions of these scripts.
some ban, some kick and my sneaky anti advertising replaces the url for your own hub url.

plop
Title:
Post by: DoJIN on 05 January, 2004, 17:51:42
thats just it
  the scripts isnt server bound   but client bound

i can run lua scripts on my dc client   the hub is in perl but  the hub owner is very busy with other scripts for the hub

and all scripts here kick or ban the user as an server command   i want it to be as an chat command   he have troubles with addy spammers in the hub laley
Title:
Post by: SaintSinner on 05 January, 2004, 17:54:52
how can you run lua scripts on your client,...
what client are you using?
Title:
Post by: DoJIN on 05 January, 2004, 17:56:43
.pdc++

it will run the script if its called  startup.lua   ( works on more clients)
Title:
Post by: plop on 05 January, 2004, 19:18:38
bcdc++ 305a also does it.
haven't checked it good, so don't know it it can capture mainchat events.
would any1 know a manual about these clients scripting interface ???

plop
Title:
Post by: DoJIN on 06 January, 2004, 00:04:02
i think i can get an clientside triggerbot scriptje
but im not sure
ill ask aroud
Title:
Post by: DoJIN on 06 January, 2004, 17:48:13
ghmmm  he isnt sure if hes allowed to give me the script   cuz he didnt create it  


but

i found this in the source of my client

if dcpp == nill then dcpp = { } end
if clients == nil then clients = { } end

function OnCommandEnter(mess)
   -- macros and such can be used here, but not practically until I remove next comment :p
   -- returning true here will at some point prevent DC++ from further processing it.
end

function OnTimer()
   -- Set this up by calling Timer():SetTimer(seconds), Timer():StartTimer(),
   -- and Timer():StopTimer()
end

function OnDownloadComplete(targetname, targetsize)
   frmClient():PrintDebug("Download complete: \"" .. targetname .. "\" is " ..
      targetsize .. " bytes")
end

dcpp.search = function(aClient, search_string)
   -- frmClient():PrintDebug("Search received: " .. search_string)
   return false;
end

dcpp.myinfo = function(aClient, myinfo_nick)
   AddUser(aClient, myinfo_nick)

   return false;
end

dcpp.quit = function(aClient, nick)
   frmClient():PrintDebug("User removed: \"" .. nick .. "\"")
   clients[aClient].ops[nick] = nil
   clients[aClient].users[nick] = nil

   return false;
end

dcpp.hubName = function(aClient, hub_name)
   clients[aClient].name = hub_name
   frmClient():PrintDebug("Received hubname: " .. clients[aClient].name)
end

dcpp.hello = function(aClient, hello_nick)
   -- find out own nick
   if clients[aClient].my_nick == nil then
      -- the first hello send by the server is the nick it accepts from us.
      clients[aClient].my_nick = hello_nick
      frmClient():PrintDebug("Own nick on " .. clients[aClient].name .. " is " .. hello_nick)
   end

   AddUser(aClient, hello_nick)

   return false;
end

dcpp.privateMessage = function(aClient, sender, message)
   frmClient():PrintDebug("PM received from " .. sender .. ": \"" .. message .. "\"")
   if string.find(message, "slot") ~= nil then
      frmClient():SendClientMessage(aClient, "$To: " .. sender .. " From: " ..
         clients[aClient].my_nick .. " $<" .. clients[aClient].my_nick ..
         "> don't ask...|")
   end

   return false;
end

function DataArrival(client, mess)
   -- returning true here will at some point prevent DC++ from further processing it.

   if string.find(mess, "$Search ") == 1 then
      return dcpp.search(client, mess)
   elseif string.find(mess, "$MyINFO $ALL ") == 1 then
      return dcpp.myinfo(client, string.sub(mess, 14, string.find(mess, " ", 14) - 1))
   elseif string.find(mess, "$Quit ") == 1 then
      return dcpp.quit(client, string.sub(mess, 7, -1))
   elseif string.find(mess, "$HubName ") then
      return dcpp.hubName(client, string.sub(mess, 10, -1))
   elseif string.find(mess, "$Hello ") == 1 then
      return dcpp.hello(client, string.sub(mess, 8, -1))
   elseif string.find(mess, "$OpList ") == 1 then
      for op in string.gfind(string.sub(mess, 9, -1), "[^$]+") do AddOp(client, op) end
   elseif string.find(mess, "$To: ") == 1 then
      local fromNick = string.sub(mess, string.find(mess, "From: ") + 6, -1)
      local sepPos = string.find(fromNick, " %$")
      local message = string.sub(fromNick, sepPos + 2, -1)
      fromNick = string.sub(fromNick, 1, sepPos - 1)
      return dcpp.privateMessage(client, fromNick, message)
   end
end

function SendActiveSearchResult(aClient, IP_port, search_nick, filename, filesize, open_slots, total_slots)
   frmClient():SendUDP(IP_port, "$SR " .. search_nick .. " " .. filename ..
      "\005" .. filesize .. " " .. open_slots .. "/" .. total_slots ..
      "\005" .. clients[aClient].name .. " (" .. clients[aClient].ipPort .. ")|")
end




is this of some help?
Title:
Post by: plop on 06 January, 2004, 19:26:40
thats nearly the same as bcdc++.
got some other things 2 make 1st but i'll try 2 build something in or before the weekend.

plop
Title:
Post by: DoJIN on 08 January, 2004, 23:47:18
i just red this :

QuoteOriginally posted by plop
thats nearly the same as bcdc++.
got some other things 2 make 1st but i'll try 2 build something in or before the weekend

build in where?
Title:
Post by: plop on 09 January, 2004, 04:25:53
QuoteOriginally posted by DoJIN
i just red this :

QuoteOriginally posted by plop
thats nearly the same as bcdc++.
got some other things 2 make 1st but i'll try 2 build something in or before the weekend

build in where?
got some other things 2 make 1st but i'll try 2 build something.
in or before the weekend.
maby this is more clear. lol
should have been a , between something and in.

plop
Title:
Post by: DoJIN on 09 January, 2004, 17:23:17
soz now i c my bad :s
Title:
Post by: DoJIN on 19 January, 2004, 18:15:44
hey    Plop hows the script going ?
Title:
Post by: plop on 19 January, 2004, 19:17:16
QuoteOriginally posted by DoJIN
hey    Plop hows the script going ?
bit short on time but it's getting there, won't stop before it works. lol

plop
Title:
Post by: DoJIN on 20 January, 2004, 11:56:01
hehe  is it fun to do something different then ptokax scripting  for once?
Title:
Post by: plop on 20 January, 2004, 13:25:55
QuoteOriginally posted by DoJIN
hehe  is it fun to do something different then ptokax scripting  for once?
same thing. lol
also use it for generating interactive website's so my bot can show realtime webstats from the hub.
but this is a bit on ice.

plop
Title:
Post by: DoJIN on 07 February, 2004, 23:21:39
well  ive got it

plop tnx   but i get an sytax error:
script1.lua:38: attempt to index global `hub' (a nil value)


heres the code :

-----------------------------------------------------------------------------------------------------------

-- Originally Written by ???
-- ReWritten by BlazeXxX
-- Requested by DoJiN
-- ReWritten to be ran on a dc++ client by plop


-- these are bot names it shouldn't send the slot response 2
DONT = { ["HubWatcher"]=1,}

-- the kick/ban reason which the user in question gets
Reason = "has been kicked because of Offensive Language / Advertising."

-- the command you want 2 trigger
DoCommand = "+lban"

-- replace this with the botname
botname = "HubWatcher"

-- the array of forbidden things
trigs = { "fuck", "weingarten","ip.com","ass.org","dns2go","yhub","servemp3.net","mine.nu"}

   hub.onPrivateMessage = function( this, user, to, prefix, text )
      DC():PrintDebug( this:getHubName().."> Priv msg: "..user:getNick().." -> "..to.." = "..text )
       
      if not user:isOp() and not user:msgHandled( "slots" ) then
         local s = string.lower( text )
         if string.find( s, "[^a-z]slots?[^a-z]" ) then
            user:sendPrivMsgFmt( "regarding slots: if you want something _rare_ (NOT ".."something _new_), please specify what")
            DC():PrintDebug( this:getHubName().."> Sent 'slots' reply to: "..user:getNick() )
            user:setMsgHandled( "slots" )
         else
            for i=1,table.getn(trigs) do
               if string.find(s, trigs) then
                  local ownNick = this:getOwnNick()
                  DC():SendHubMessage( this:getId(), "<"..ownNick.."> +pban "..user:getNick().." You have been kicked because of Offensive Language / Advertising.|" )
                  break
               end
            end
         end
      end
   end
Title:
Post by: VidFamne on 08 February, 2004, 01:29:51
Dont you have to declare the table  "hub" somewhwere?
Like hub = {}
Title:
Post by: DoJIN on 08 February, 2004, 14:17:27
ive got no clue  plop made it on my request

he told me it worked for him we both use the same client to run the script on

there was 1 thing tho :

seems 2 be a problem still, as it shouldn't kick OP's ( not user:isOp() ), but that fails 2 do what it should do.
anyway enjoy the script and i hope it works (worked for me @ least).

plop
Title:
Post by: DoJIN on 08 February, 2004, 16:13:30
hmm  ive been fooling arouns a bit  

does some1 know how i can get  the nick of the person who says one of the forbidden words?
Title:
Post by: plop on 10 February, 2004, 12:37:53
QuoteOriginally posted by VidFamne
Dont you have to declare the table  "hub" somewhwere?
Like hub = {}
the script has 2 be inserted in the startup.lua file shipped with bcdc++/phantomdc.
in that part you'll find the table called hub.
but this 1 only works on 0.305.
everything changed on 0.306 as they are still developing the scripting interface.
here is the version for 0.306 clients.
insert this @ the top of the startup.lua file.
-- the array of forbidden things
trigs = { "fuck", "weingarten","ip.com","ass.org","dns2go","yhub","servemp3.net","mine,nu"}
and replace this function/part.
  hub.onPrivateMessage = function( this, user, to, prefix, text )
      DC():PrintDebug( this:getHubName().."> Priv msg: "..user:getNick().." -> "..to.." = "..text )
     
      if not user:isOp() and not user:msgHandled( "slots" ) then
         local s = string.lower( text )
         if string.find( s, "[^a-z]slots?[^a-z]" ) then
            user:sendPrivMsgFmt( "regarding slots: if you want something _rare_ (NOT ".."something _new_), please specify what")
            DC():PrintDebug( this:getHubName().."> Sent 'slots' reply to: "..user:getNick() )
            user:setMsgHandled( "slots" )
         else
            for i=1,table.getn(trigs) do
               if string.find(s, trigs[i]) then
                  local ownNick = this:getOwnNick()
                  DC():SendHubMessage( this:getId(), "<"..ownNick.."> !kickuser "..user:getNick().." You have been kicked because of Offensive Language / Advertising.|" )
                  break
               end
            end
         end
      end
   end
plop
Title:
Post by: plop on 10 February, 2004, 12:42:29
QuoteOriginally posted by DoJIN
hmm  ive been fooling arouns a bit  

does some1 know how i can get  the nick of the person who says one of the forbidden words?
with this.
user:getNick()

unlike on ptokax on bcdc++/phantomdc everything is done by the script.

plop
Title:
Post by: DoJIN on 12 February, 2004, 19:25:23
yeah  that was what ive been loookin for  tnx