PtokaX forum

Archive => Archived 4.0 boards => Request for Lua 4 scripts => Topic started by: Endless on 01 August, 2004, 08:33:07

Title: BCDC's formatting.lua and sounds...
Post by: Endless on 01 August, 2004, 08:33:07
In BCDC, using the formatting.lua, you can specify some names that will display in a different color.  Like if someone says your nick in the main chat, that line can be a specified color.  I was wondering, if it would be possible to also have it play a sound.  Like, for ex, you have a hub member who you just can never catch, you keep missing him when he comes in, but you're always near the computer, you just keep missing him.  If BCDC and formatting.lua could play a sound when that person shows, you could finally catch him (or her :-))  I always have joins/parts on so the user wouldnt actually have to say anything, the ***Joins: would trigger it.

Is this possible?  I've included the code from my current formatting.lua in case no-one knows what I'm talking about.

Thanks,
E

--edit: 8/5/2004 - Cut out formatting.lua text since it wasn't needed and rather long.
Title:
Post by: MrZ on 01 August, 2004, 13:23:36
Hia

Dont know what client ur using but fullDC has that option, my DCPlusPlus.xml file contains this


hope it could give ya (anyone) a clue

Z ya
Title:
Post by: BottledHate on 02 August, 2004, 03:51:28
no need to mess with the formatting.lua for that... this 'annoys' you with a pop up including the text of the nick you are looking for if they nick chats or comes online.... i'm sure u can make it do whatever to get your attention.

--//[BCDC .403b]
--//annoy when findNick chats or comes online....
dcpp:setListener( "chat", "listenfornick",
function( hub, user, text )
local findNick = "NickNameHere" --//case sensitive...
if user:getNick() == findNick then
         local executor = "net send 192.168.2.100 "..findNick.." just said:  "..text.."        In:  "..hub:getHubName()
         os.execute(executor);      
end
end
)

dcpp:setListener( "userMyInfo", "nickonline",
function( hub, user, msg )
local findNick = "NickNameHere" --//case sensitive...
if user:getNick() == findNick then
         local executor = "net send 192.168.2.100 "..findNick.." just came online in:  "..hub:getHubName()
         os.execute(executor);      
end
end
)
DC():PrintDebug("*** Annoy Me!!! loaded. ***")



hope this helps...

-BH
Title:
Post by: Endless on 02 August, 2004, 05:21:25
I tried it as you posted, and two command prompt windows came up and then went away, nothing else seemed to happen.  I'm not anywhere near good at scripting, I usually just wing it and see if it works.  I finally got it to play a sound by changing this:
         local executor = "net send 192.168.2.100 "..findNick.." just said:  "..text.."        In:  "..hub:getHubName()

to this:
         local executor = "\start.wav"

I stuck that wave file in the BCDC dir.  It wouldnt work for some reason when I used a full path to \windows\media\

But, my problem, the wave plays in winamp (my default program for waves), and it plays over, and over, and over, it wont stop.

Otherwise it works,  thanks for a starter :-)

Oh, and also, what if I want to have it match several nicks?  Do I add a new line with the other nick? or put it on the first line separated by a comma or something?

Feel free to tell me I did it wrong, I don't doubt it one bit, hehe.

E
Title:
Post by: BottledHate on 02 August, 2004, 22:18:19
if you just plugged in what i gave u, then yes.. you probably just got a couple wndows that open and close....
you needed to change the ip in that feild.. as that was my internal ip.. not yours..... anyways...


for multiple nicks you want to ue a table...

here's an example:


--//[BCDC .403b]
--//annoy when findNicktable[] chats or comes online....
findNicktable = {["nickName1"] =1, ["nick2"] = 1, ["NiCk3"] = 1 }

dcpp:setListener( "chat", "listenfornick",
function( hub, user, text )
if findNicktable[user:getNick()] then
         local executor = "net send 192.168.2.100 "..findNick.." just said:  "..text.."        In:  "..hub:getHubName()
         os.execute(executor);      
end
end
)

dcpp:setListener( "userMyInfo", "nickonline",
function( hub, user, msg )
if findNicktable[user:getNick()] then
         local executor = "net send 192.168.2.100 "..findNick.." just came online in:  "..hub:getHubName()
         os.execute(executor);      
end
end
)
DC():PrintDebug("*** Annoy Me!!! loaded. ***")


plop has a GREAT site that explains tables and everything...
if you are just starting in lua as i am.. it is a MUST read and a great reference.... plop's website (http://www.plop.nl/index.php)

-?H
Title:
Post by: BottledHate on 02 August, 2004, 23:12:54
also.. if you are trying to play a wav.... this will play it once then close the app after playing it. if you use xp..
the file should be there.. u'll just need to change the path a bit.

local executor = "C:\\WINNT\\system32\\sndrec32.exe /play /close C:\\WINNT\\media\\chimes.wav"


note the "\\" instead of just "\"  .... the backslash is escape charactor for other special/reserved things..
to make it put one in the string you have to do it twice...  
for example if i wanted to use a path with spaces... i'd need to add quotes into the string....
the quotation mark is a reserved char.. so in order to put it in the string u use the escape char \.    
local executor = "C:\\WINNT\\system32\\sndrec32.exe /play /close \"C:\\My Suff\\any name here.wav\""
os.execute(executor);
this is the same as typing:
    c:\winnt\system32\sndrec32.exe /play /close "c:\my spaces path\filename.wav"
into any dos prompt, or from the run line.


for more info on reserved chars and escape sequenses check out the Lua Reference Manual (http://www.lua.org/manual/5.0/manual.html#2.1).

hope this helps...

-?H
Title:
Post by: Endless on 03 August, 2004, 00:32:33
QuoteOriginally posted by BottledHate
if you just plugged in what i gave u, then yes.. you probably just got a couple wndows that open and close....
you needed to change the ip in that feild.. as that was my internal ip.. not yours..... anyways...

I actually did set it to my internal ip at first.  That's when I got two cmd windows that closed.  Doesn't matter though, I don't wanna do a netsend.

Below is the exact text I'm using now and it does work.  I'm pretty much happy, it notifys me and that's what I wanted.  But why does the sound play twice when the person enters the hub?  I turned off joins/parts and that didnt help.

Also,  why are there the two "dcpp:setListener" sections?  I was playin around and tried one setlistener but not the other and vise versa, but the same thing happened on both.  I got the sound two times upon the person entering, and once upon them speaking.  What do the two sections do?

Thanks for the help so far.
E

Quote
--//[BCDC .403b]

--//annoy when findNicktable[] chats or comes online....

findNicktable = {["E2"] = 1, ["Ghost"] = 1, ["NiCk3"] = 1 }

dcpp:setListener( "chat", "listenfornick",

   function( hub, user, text )

      if findNicktable[user:getNick()] then

         local executor = "C:\\WINDOWS\\system32\\sndrec32.exe /play /close D:\\_StandAlone\\DC++who-EndlessHub\\listener.wav"

         os.execute(executor);      

      end

   end                                                

         
)

dcpp:setListener( "userMyInfo", "nickonline",

   function( hub, user, msg )

      if findNicktable[user:getNick()] then

         local executor = "C:\\WINDOWS\\system32\\sndrec32.exe /play /close D:\\_StandAlone\\DC++who-EndlessHub\\listener.wav"

         os.execute(executor);      

      end

   end                                                

         

)

DC():PrintDebug("*** Annoy Me!!! loaded. ***")
Title:
Post by: BottledHate on 03 August, 2004, 01:48:18
two listeners because it is listening for two different things..... one is a chat message... the other is the $myinfo the user sends when they join the hub...

as far as it playing twice... i dunno... maybe add a couple lines to figure out where it's coming from....

maybe they use a client that spams $MyInfo... (or jsut sends it twice)... note: if the users share changes, description changes, anything like that.. it send $MyInfo again..


--//[BCDC .403b]

--//annoy when findNicktable[] chats or comes online....

findNicktable = {["E2"] = 1, ["Ghost"] = 1, ["NiCk3"] = 1 }

dcpp:setListener( "chat", "listenfornick",

function( hub, user, text )

if findNicktable[user:getNick()] then

local executor = "C:\\WINDOWS\\system32\\sndrec32.exe /play /close D:\\_StandAlone\\DC++who-EndlessHub\\listener.wav"

os.execute(executor);
Hub:injectChat(user:getNick().." Found In Chat!")

end

end


)

dcpp:setListener( "userMyInfo", "nickonline",

function( hub, user, msg )

if findNicktable[user:getNick()] then

local executor = "C:\\WINDOWS\\system32\\sndrec32.exe /play /close D:\\_StandAlone\\DC++who-EndlessHub\\listener.wav"

os.execute(executor);

Hub:injectChat(user:getNick().." ONLINE! ..got myinfo")

end

end



)

DC():PrintDebug("*** Annoy Me!!! loaded. ***")

Title:
Post by: BottledHate on 03 August, 2004, 02:22:05
you also said you were playing around trying to make them 1.. in doing so you may have an extra listener in there(loaded) that keeps giving extra responses... in which case you'll need to restart your client to get that one out.


-?H
Title:
Post by: Endless on 03 August, 2004, 07:07:27
I tried restarting and retrying the code I last posted, same thing happened, two sounds on enter, one on speak.

I then tried the new code you posted and the same, and nothing new.  Am I right to assume that "Hub:injectChat(user:getNick().." Found In Chat!")" would post " Found In Chat!" in my chat window?  If so, it didn't work on enter, or on speak.

I'm not really worried about having a sound when the user speaks, only when they enter.  And I always have joins/parts on, could the script only look for "***Joins:  " ?  Or even just look for the specific nick I'm interested in being notified of.  That would also allow the script to be adapted later for notification on keywords.   Hmm, that sounds like something that would have already been done by someone else, I'll have a look around and see what I can find.

Thanks for your help this far, you've been great :-)

E
Title:
Post by: BottledHate on 03 August, 2004, 08:05:20
i've run the script.. it play sounds 1 time.

the mod was supposed to tell you where each ofthe sounds was coming from..... so u can troubleshoot.  so if both messages ib the main were "ONLINE! ..got myinfo"... then you know you are receving the myinfo twice from the user.

are you in two hubs that that user is in too? you'll get a myinfo with their nick form each.
Hub:injectChat(user:getNick().." ONLINE! ..got myinfo    Hub received from: "..hub:getHubName())
that will tell u what hub it comes from.. so if it is a multiple hub thing.. u get the message from both.

as far as client side scripts.. not much has been made(public).  good luck.

-?H
Title:
Post by: BottledHate on 03 August, 2004, 11:50:49
ok.. i suppose i could make this into a useable script...


type "/annoy help" in any hub window once loaded.


--//[BCDC .403b]
--//annoy when findNick chats or comes online....
--//this plays a sound file..be sure to change the appropriate info bellow.
--//u can edit this to annoy you in other ways.. ;)  -?H

-----Info need to change:
annoyingSoundPathUsers = "c:\\winnt\\media\\The Microsoft Sound.wav"  --// you must use \\ for backslash
annoyingSoundPathTrigs = "c:\\winnt\\media\\tada.wav"  --// you must use \\ for backslash
-----



findTable = {["Users"]={},["Trigs"]={}}
Serialize = function(tTable, sTableName, sTab)
   sTab = sTab or "";
   sTmp = ""
   sTmp = sTmp..sTab..sTableName.."={"
   local tStart = 0
for key, value in tTable do
      if tStart == 1 then
         sTmp = sTmp..",\r\n"
      else
         sTmp = sTmp.."\r\n"
         tStart = 1
      end
      local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
      if(type(value) == "table") then
         sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
      else
         local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
         sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
      end
   end
   sTmp = sTmp.."\r\n"..sTab.."}"
   return sTmp
end

local okenize = function( str )
local ret = {}
string.gsub( str, "([%S+_%+_.+_%w+]+)", function( s ) table.insert( ret, s ) end ) --// % = alt0160, look for false space in names..
return ret
end
function saveFindData()
   local savestring = ""
   savestring = Serialize(findTable, "findTable", "")
   local f,e = io.open( "_AnnoyMe.txt", "w+")
   if f then
      f:write(savestring)
      f:close()
   end
end
local printSting = function(list)
   local pString = ""
   for k,v in findTable[list] do
      pString = pString.."            "..k.."\r\n"
   end
return pString
end
local f,e = io.open( "_AnnoyMe.txt", "a+" )
if f then
   f:write( "" )
   f:close()
end
dofile("_AnnoyMe.txt")

dcpp:setListener( "chat", "trigggy",
function( hub, user, text )
      for k,v in findTable["Trigs"] do
         if string.find(text, k ) == 1 then
            local executor = "sndrec32.exe /play /close \""..annoyingSoundPathTrigs.."\""
            os.execute(executor);    
         end
      end
   end
)

dcpp:setListener( "userMyInfo", "nickonline",
function( hub, user, msg )
if findTable["Users"][user:getNick()] then
         local executor = "sndrec32.exe /play /close \""..annoyingSoundPathUsers.."\""
         os.execute(executor);      
end
end
)

dcpp:setListener( "ownChatOut", "anonyme",
function( hub, text )
   if string.sub( text, 1, 1 ) ~= "/" then return end
      local parms = okenize( string.sub(  text, 2 ) )
      if parms[1] == "annoy" then
         if parms[2] == nil then
            hub:injectChat( "\r\n ????/?  Current AnnoyMe List  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs").."\r\n ('/annoy help' for commands.)")              
         elseif parms[2] =="help"  then
            hub:injectChat("\r\n ????/?  Help For AnnoyMe script  ?\?`??\r\n"..
                                           "        /annoy\t\t\tlists the current AnonyMe list.\r\n"..
                                           "        /annoy addU [nick]\t\tadd a nick name to be annoyed by when the user comes online.\r\n"..
                                           "        /annoy addT [trig]\t\tadds a single word to Annoy you when said in chat.\r\n"..                                              
                                           "        /annoy removeU [nick]\tremove the user from the AnnoyMe list.\r\n"..                                              
                                           "        /annoy removeT [trig]\tremove the trig from the AnnoyMe list.\r\n"..
                                           "        /annoy removeall\t\tremove all values.\r\n"..                                              
                                           "        /annoy help\t\t\t(this)")
         elseif parms[2] == "list" then
            hub:injectChat( "\r\n ????/?  Current AnnoyMe List  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
         elseif parms[2] == "addU" then
               if parms[3] ~= nil then
               findTable["Users"][parms[3]] = 1
               hub:injectChat( "\r\n ????/?  User Added..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs"))
               saveFindData()
            else
               hub:injectChat( "\r\n ????/?  Format: /annoy addU NickName123  ?\\?`??")
            end
         elseif parms[2] == "addT" then
            if parms[3] ~= nil then
               findTable["Trigs"][parms[3]] = 1
               hub:injectChat( "\r\n ????/?  Trig Added..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
               saveFindData()
            else
               hub:injectChat( "\r\n ????/?  Format: /annoy addT WoRd  ?\\?`??")
            end                          
         elseif parms[2] == "removeall" then
            findTable = nil
            findTable = {["Users"] = {}, ["Trigs"] = {}}
            hub:injectChat( "\r\n ????/?  *Deleted all values* No Current Nicks or Trigs to Annoy you.  ?\\?`??\r\n")
            saveFindData()
         elseif parms[2] == "removeU" then
            if findTable["Users"][parms[3]] then
                  findTable["Users"][parms[3]] = nil
                  hub:injectChat( "\r\n ????/?  User Removed..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
                  saveFindData()
            else
               hub:injectChat( "\r\n ????/?  User not found. (case sensitive)  ?\\?`??")
            end
         elseif parms[2] == "removeT" then
            if findTable["Trigs"][parms[3]] then
                  findTable["Trigs"][parms[3]] = nil
                  hub:injectChat( "\r\n ????/?  Trig Removed..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
                  saveFindData()
               else
                  hub:injectChat( "\r\n ????/?  Trig not found. (case sensitive)  ?\\?`??")
               end
         else
            hub:injectChat( "\r\n ????/?  Unknown Command ('/annoy help' for commands.)  ?\\?`??")
         end
         return 1
      end
 
end
)

DC():PrintDebug("*** Annoy Me!!! loaded. ***")

--//[BCDC .403b]


Enjoy!

-BH
Title:
Post by: BottledHate on 04 August, 2004, 00:36:23
i was really tired last night when i made that... had to edit something small.... it wouldn't have caused a crash. but it is just beter now.

edited on post above....

-?H
Title:
Post by: Endless on 04 August, 2004, 00:56:31
QuoteOriginally posted by BottledHate
i've run the script.. it play sounds 1 time.

the mod was supposed to tell you where each ofthe sounds was coming from..... so u can troubleshoot.  so if both messages ib the main were "ONLINE! ..got myinfo"... then you know you are receving the myinfo twice from the user.

Hmm, I got nothing in either client.  I dunno.  I'd guess it has something to do with one of the clients, or ptokax.  It's no biggie.

Quoteare you in two hubs that that user is in too? you'll get a myinfo with their nick form each.

I am in the hub with my normal nick, and BCDC.  "E2", one of the watch nicks in the script, is set up on a different client (PossumMod v0.0.12a)  I connect with the E2 client and get the two sounds from BCDC.  Both clients are on this computer, but they are different clients and run on different ports etc.  The hub is mine btw, but it's not on this computer, and it's Ptokax 0.3.2.6 test drive 3.

The two sounds isn't really a big deal to me,  the script makes a sound and that's what I was aiming for.

You can give up if you want to, ya done good thus far :)

E
Title:
Post by: Endless on 04 August, 2004, 01:21:50
QuoteOriginally posted by BottledHate
ok.. i suppose i could make this into a useable script...


type "/annoy help" in any hub window once loaded.

hehe, I loaded it up and nothing happened.  No error for loading, it said Annoy Me loaded in the status bar.

Nothing happens for "/annoy help" or "/annoy addT hmm" (nothing happened when I or someone else said "hmm"  

I do, however, have a 0 byte "_AnnoyMe.txt"  in my BCDC dir.

Can a script use "/" in commands?  I figured maybe those were pretty much reserved for DC alone.

But this is otherwise pretty cool.  Seems easy to add and remove nick trigs or keyword trigs.  And a dif sound for each.

E
Title:
Post by: BottledHate on 04 August, 2004, 08:42:43
ok.. so now that i'm messing with this... i've added more...  you'll need to delete the _AnnoyMe.txt and start fresh as the table structure has changed.

v1.3
fixed: hopefully.. for the most part... playing the sound twice for users in multiple hubs.
added: /annoy seen [nick]  -where [nick] = someone on the annoyme list... displays last logout info.. or current online hub.
fixed: /annoy help
future: change sound files from bcdc.. (instead of editing the lua file)
future: [your reasonable suggestion here]  ;)


--//[AnnoyMe 1.3][BCDC .403b] by BottledHate
--//annoy when findNick chats or comes online....
--//this plays a sound file... also keeps a log of the last time the user was seen.
--//be sure to change the appropriate info bellow.

-----Info need to change:
annoyingSoundPathUsers = "c:\\winnt\\media\\The Microsoft Sound.wav"  --//   you must use \\ for backslash .... wav files only.   network files unc:  "\\\\pcname\\path\\to\\sound.wav"
annoyingSoundPathTrigs = "c:\\winnt\\media\\tada.wav"  --//   you must use \\ for backslash  ... wav fiels only.                 local files... "c:\\path to\\the\\sound.wav"
-----///

Serialize = function(tTable, sTableName, sTab)
   sTab = sTab or "";
   sTmp = ""
   sTmp = sTmp..sTab..sTableName.."={"
   local tStart = 0
for key, value in tTable do
      if tStart == 1 then
         sTmp = sTmp..",\r\n"
      else
         sTmp = sTmp.."\r\n"
         tStart = 1
      end
      local sKey = (type(key) == "string") and string.format("[%q]",key) or string.format("[%d]",key);
      if(type(value) == "table") then
         sTmp = sTmp..Serialize(value, sKey, sTab.."\t");
      else
         local sValue = (type(value) == "string") and string.format("%q",value) or tostring(value);
         sTmp = sTmp..sTab.."\t"..sKey.." = "..sValue
      end
   end
   sTmp = sTmp.."\r\n"..sTab.."}"
   return sTmp
end

local okenize = function( str )
local ret = {}
string.gsub( str, "([%S+_%+_.+_%w+]+)", function( s ) table.insert( ret, s ) end ) --// % = alt0160, look for false space in names..
return ret
end

function saveFindData()
   local savestring = ""
   savestring = Serialize(findTable, "findTable", "")
   local f,e = io.open( "_AnnoyMe.txt", "w+")
   if f then
      f:write(savestring)
      f:close()
   end
end

local seenString = function(n)
   local sestring = ""
   if findTable["Users"][n]["LastSeen"] then
    sestring  = "????/?  "..n.." was last seen leaving "..findTable["Users"][n]["LastSeen"].." ?\\?`??"
   else
   sestring = "????/?  There is no data yet for: "..n.."  ?\\?`??"
   end
   return sestring
end

local printSting = function(list)
   local pString = ""
   for k,v in findTable[list] do
      pString = pString.."            "..k.."\r\n"
   end
return pString
end

function GetTime()
   a = os.date("%a")
   I = os.date("%I")
   M = os.date("%M")
S = os.date("%S")
b = os.date("%b")
d = os.date("%d")
z = os.date("%z")
y = os.date("%y")
Date = a..", "..I..":"..M..":"..S..", "..b.."/"..d.."/"..y.." "..z
return Date
end


local f,e = io.open( "_AnnoyMe.txt", "a+" )
if f then
   f:write( "" )
   f:close()
end

userOnline = {}
findTable = {["Users"]={},["Trigs"]={},["SoundFiles"] ={}}
dofile("_AnnoyMe.txt")

dcpp:setListener( "userQuit", "seeen",
function( hub, nick )
      local s,e,nameTrim =  string.find(hub:getHubName(), "([%S+_%s+_.+_%w+]+) %(%d+.%d+.")
   --DC():PrintDebug("userquit data: "..hub:getHubName()..nick)
      if findTable["Users"][nick] then
         findTable["Users"][nick]["LastSeen"] = nameTrim.." "..GetTime()
         if userOnline[nick] then
         userOnline[nick] = nil
         end
         saveFindData()
      end
      return
end
)
dcpp:setListener( "chat", "trigggy",
function( hub, user, text )
      for k,v in findTable["Trigs"] do
         if string.find(text, k ) == 1 then
            --if findTable["SoundFiles"]["Trigs"] then
            --local executor = "sndrec32.exe /play /close \""..findTable["SoundFiles"]["Trig"].."\""
            local executor = "sndrec32.exe /play /close \""..annoyingSoundPathTrigs.."\""
            os.execute(executor);
            --else
            --hub:injectChat( "????/?  Error: Trigger sound file not set... edit the AnnoyMe(version).lua file line: 8 and set the sound file path. ?\\?`??")
            --end
         end
      end
   end
)

dcpp:setListener( "userMyInfo", "nickonline",
function( hub, user, msg )
      local s,e,nameTrim =  string.find(hub:getHubName(), "([%S+_%s+_.+_%w+]+) %(%d+.%d+.")
if findTable["Users"][user:getNick()] then
         if userOnline[user:getNick()] then
            userOnline[user:getNick()] = nameTrim
         else
            userOnline[user:getNick()] = nameTrim
            --if findTable["SoundFiles"]["Users"] then
               --local executor = "sndrec32.exe /play /close \""..findTable["SoundFiles"]["Users"].."\""
               local executor = "sndrec32.exe /play /close \""..annoyingSoundPathUsers.."\""
               os.execute(executor);
            --else
               --hub:injectChat( "????/?  Error: User sound file not set... edit the AnnoyMe(version).lua file line:7 and set the sound file path. ?\\?`??")
            --end
         end
end
end
)

dcpp:setListener( "ownChatOut", "anonyme",
function( hub, text )
   if string.sub( text, 1, 1 ) ~= "/" then return end
      local parms = okenize( string.sub(  text, 2 ) )
      if parms[1] == "annoy" then
         if parms[2] == nil then
            hub:injectChat( "????/?  Current AnnoyMe List  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs").."\r\n ('/annoy help' for commands.)")              
         elseif parms[2] =="help"  then
            hub:injectChat("????/?  Help For AnnoyMe script  ?\\?`??\r\n"..
                                           "        /annoy\t\t\t-lists the current AnonyMe list.\r\n"..
                                           "        /annoy addU [nick]\t\t-adds a nick name to be annoyed by when the user comes online.\r\n"..
                                           "        /annoy addT [trig]\t\t-adds a single word to Annoy you when said in chat.\r\n"..                                              
                                           "        /annoy removeU [nick]\t-remove the user from the AnnoyMe list.\r\n"..                                              
                                           "        /annoy removeT [trig]\t-remove the trig from the AnnoyMe list.\r\n"..
                                           "        /annoy removeall\t\t-remove all values.\r\n"..
                                           "        /annoy seen [nick]\t\t-shows the last seen info for a person on your AnnoyMe list.\r\n"..                                          
                                           "        /annoy help\t\t\t(this)")
         elseif parms[2] == "list" then
            hub:injectChat( "????/?  Current AnnoyMe List  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
         elseif parms[2] == "seen" then
               if findTable["Users"][parms[3]] then
                  if userOnline[parms[3]] then
                     hub:injectChat("????/?  User is currently Online in: "..userOnline[parms[3]].."  ?\\?`??")
                  else
                     hub:injectChat(seenString(parms[3]))
                  end
               else
                  hub:injectChat( " ????/?  Format: /annoy seen [nick]     ..where [nick] is someone already added to the AnnoyMe list.  ?\\?`??")
               end
         elseif parms[2] == "addU" then
               if parms[3] ~= nil then
               findTable["Users"][parms[3]] = {}
               hub:injectChat( "????/?  User Added..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs"))
               saveFindData()
            else
               hub:injectChat( "????/?  Format: /annoy addU NickName123  ?\\?`??")
            end
         elseif parms[2] == "addT" then
            if parms[3] ~= nil then
               findTable["Trigs"][parms[3]] = {}
               hub:injectChat( "????/?  Trig Added..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
               saveFindData()
            else
               hub:injectChat( "????/?  Format: /annoy addT WoRd  ?\\?`??")
            end                          
         elseif parms[2] == "removeall" then
            findTable = nil
            findTable = {["Users"] = {}, ["Trigs"] = {}}
            hub:injectChat( "????/?  *Deleted all values* No Current Nicks or Trigs to Annoy you.  ?\\?`??\r\n")
            saveFindData()
         elseif parms[2] == "removeU" then
            if findTable["Users"][parms[3]] then
                  findTable["Users"][parms[3]] = nil
                  hub:injectChat( "????/?  User Removed..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
                  saveFindData()
            else
               hub:injectChat( "????/?  User not found. (case sensitive)  ?\\?`??")
            end
         elseif parms[2] == "removeT" then
            if findTable["Trigs"][parms[3]] then
                  findTable["Trigs"][parms[3]] = nil
                  hub:injectChat( "????/?  Trig Removed..... *New* Current AnnoyMe list.  ?\\?`??\r\n    Users:\r\n"..printSting("Users").."    Trigs:\r\n"..printSting("Trigs") )
                  saveFindData()
               else
                  hub:injectChat( "????/?  Trig not found. (case sensitive)  ?\\?`??")
               end
         else
            hub:injectChat( "????/?  Unknown Command ('/annoy help' for commands.)  ?\\?`??")
         end
         return 1
      end
 
end
)

DC():PrintDebug("*** AnnoyMe 1.3 Loaded. ***")

--//[AnnoyMe 1.3][BCDC .403b] by BottledHate



qtion/comments/suggestions always welcome.

edit:
also hosted on plop's website (http://www.plop.nl/bcdcbots/BottledHate.php) ... which is a great source for learning lua.

-?H
Title:
Post by: Endless on 04 August, 2004, 23:25:00
I tried the most recent script you pasted, "/annoy help" still won't work here.  Does it work on your end?  Maybe it's something with my client or hub.  I use BCDC .401b.  I never get any errors in the status bar of BCDC, it just loads up fine and that's it.

I was peeking around in the script, and saw this bit on line 285 ":dcpp:setListener( "ownChatOut", "anonyme","   Seems to be a slip of the finger.

I also found a similar ?mistype? on line 303

A few other possible things I noticed:
Line 185 - "seeen" ?
Line 213 - "trigggy" ?
Line 291 - "okenize" ?

Even after changing those to what I would think would have been right, "/annoy help" didn't do anything.

Just wondering, will %windir% work in place of winnt?  My install is in c:windows and not winnt.  If %windir% works instead, most users could probably start using the script without any editing at all.

So far, so good :)

E
Title:
Post by: BottledHate on 05 August, 2004, 00:13:33
no, those are not typos those are variables for the listeners... which can be anything/.. "seeen". "triggy", "anonyme" all don't matter... they can be anything... if you change okenize, the script won't work. that typo was on purpose.

  yes /annoy help works for me... i use bcdc.403..... maybe u should upgrade?  the startup.lua is probably a lil different from the one in .403, causeing the error with displaying the /annoy help.

i could change the path for the defualt wavs to include %windir%, but the windir is pointless.. u are suppoesd to set files u want... the ONLY thing u have to put in are the two files you want to use for each "annoy" (wav files). if you want to do it on your own... feel free!!
-----Info need to change:
annoyingSoundPathUsers = "c:\\%windir%\\media\\The Microsoft Sound.wav"  --//   you must use \\ for backslash .... wav files only.   network files unc:  "\\\\pcname\\path\\to\\sound.wav"
annoyingSoundPathTrigs = "c:\\%windir%\\media\\tada.wav"  --//   you must use \\ for backslash  ... wav fiels only.                 local files... "c:\\path to\\the\\sound.wav"
-----///


yeah, next release will have the option to set the sounds from within bcdc.. that is the only thing that requires editing right now.  everything else is handled through /annoy... so after next version, u shouldn't need to edit anything.

maybe i'll get that done tonight???

future: the abilty to set different sound files for each user... or if you don't specify a custom one, it would play the default one.


hope u are enjoying the script.. i know i am :)

-?H
Title:
Post by: BottledHate on 05 August, 2004, 00:36:15
ok.. so i just had a look at the .401 startup.lua... and it doesn't support the "ownChatOut" ... and the "onMyInfo" is different too.. so, you will be unable to use the /annoy commands till u upgrade. you will probably also keep getting two notifys as well.

i suggest upgrading to bcdc++.403b.. here's a link (http://utrum.dyndns.org:8000/dl/BCDCPlusPlus-0.403b.rar).  once u upgrade... things are a lil different.. all lua scripts go in [bcdc]/scripts/
so just save the AnnoyMe script in there.  in bcdc /luafile [AnnoyMeScriptName.lua]

to have it load on start... edit the new startup.lua line:~508 and add another dofile([file]) where file = the annoyme scirpt.... if you are getting erorrs on loading the script in the new bcdc.403, delete the "_AnnoyMe.txt"... as the table structure has changed. any old values in there will cause crashes.

-?H
Title:
Post by: Endless on 05 August, 2004, 06:16:54
Well, I went for .403b, and now "/annoy" does soemthing.  But none of the other commands do anything.  "/annoy help", addT, addU, seen, none of em do anything.  Only "/annoy" shows the current (empty) annoy list.  The _annoyme.txt file is still 0B and empty, even after trying to add a trig like "annoy addT hmm" or "/annoy addU E2"

Gonna try a fresh install of BCDC and see if maybe some option here is screwing me up.  Will let ya know if that fixes it.

E
Title:
Post by: Endless on 05 August, 2004, 09:13:46
I tried a fresh copy of BCDC 403b, no luck on it working so far.

But I was playing around, the onjoin.lua script that comes with bcdc, the one that sends a welcome pm to people as they come in the hub, I modified it a bit to instead play the sound.  And to my surprise, it did work, (not the first time of course :) )  It played the sound, and one time only too.  I figured maybe you would be interested in lookin at it, maybe get an idea for your's or something.

Quote
--// vim:ts=4:sw=4:noet

dcpp:setListener( "userConnected", "onjoin",
   function( hub, user )
      local findNick = "E2"

      if user:getNick() == findNick then

      local executor = "sndrec32.exe /play /close D:\\_StandAlone\\DC++who-EndlessHub\\listener.wav"

      os.execute(executor);

   end

end
)

DC():PrintDebug( "  ** Loaded onjoinmod.lua **" )

[/SIZE]

I don't know who made the original script, and I of course don't mean to take credit for it.  The only commented out sections I removed were where it said what the script did (it doesnt do that anymore since I modified it)

E
Title:
Post by: BottledHate on 05 August, 2004, 09:34:20
hmmm.. interesting. everthing works for me and another friend i had testing.. maybe try this one.

here's another:
1.4
added: sound support
fixed: lil shit here and there.

lol... seems it's getting too long for posting... here (http://www.stcycles.com/AnnoyMe1.4.lua) is a link... drop it in you /scritps dir and go! no editing of the file is needed in this one.

-?H
Title:
Post by: VidFamne on 05 August, 2004, 14:09:15
Is this script depending on startup.lua?
If so, why not make a stand alone script?
Sorry for my newbish question.  :))
Title:
Post by: Endless on 05 August, 2004, 22:08:07
Woohoo! Now it works.  I tried it first on my clean install of 403b and then on my daily use 403b, both worked.  Whatever you did fixed it :)

I was wondering,  do the commands have to be case sensitive? Things like "/annoy addT "

Oh, and your dc print debug still says 1.3.

So is this sucker done or do you still have more planned?

Thx...
E
Title:
Post by: BottledHate on 05 August, 2004, 22:45:56
QuoteOriginally posted by VidFamne
Is this script depending on startup.lua?
If so, why not make a stand alone script?
Sorry for my newbish question.  :))

someone correct me if i'm wrong... addtional scripts are loaded into the start-up.lua.  making it work independent of the start-up.lua's funcitons would be redundant, since you would have to re-create most of its funcitons anyways... and bcdc doesn't run without the startup.lua.

i'm a newb too.. so i'm not totally sure if my answer is right.....
Title:
Post by: BottledHate on 05 August, 2004, 23:15:48
QuoteOriginally posted by Endless
Woohoo! Now it works.  I tried it first on my clean install of 403b and then on my daily use 403b, both worked.  Whatever you did fixed it :)

I was wondering,  do the commands have to be case sensitive? Things like "/annoy addT "

Oh, and your dc print debug still says 1.3.

So is this sucker done or do you still have more planned?

Thx...
E

-- Sweet! glad to hear u got it to load!

-- **EDITED: get below 1.4.2** is a link to 1.4.1... no more case sensitive for commands. still is for trigs and users.  fixed another minor bug.

-- should say the correct version numbers now.

-- since i pesonally run this script now, i'll add whatever sounds cool at the time i want it! ;)  any other ideas/suggestions are always welcome.
---i was thinking about adding a 'command' option... kinda like how a personal sound for each is an option. so u can set it to run whatever you want for a user/trig, in addtion to the annoying sound u set.

-?H
Title:
Post by: BottledHate on 06 August, 2004, 01:40:56
1.4.2...

--fixed the way it manages the online hubs for the 'seen' command. (signing off in 1 hub no longer makes it think they are completly gone.)
--added massinjectchat.. for when a user signs in on the AnnoyMe list.. sends message to all hubs "[user] has just signed on in [hub]" (only u see it)
--fixed /annoy removeall ..doesn't screw up the table structure anymore.. and keeps the default sounds, if set, intact.
--fixed other lil stuff.

here is: AnnoyMe 1.4.2 (http://www.stcycles.com/AnnoyMe1.4.2.lua)

....bleh

-?H
Title:
Post by: Endless on 06 August, 2004, 08:18:53
It also worth noting that a relative link seems to work fine here.  Putting the wav file in the BCDC dir and using \soundfile.wav for ex.

I can't seem to get  this to work:
"/annoy sound default Users D:\listener.wav"
I get this error:
"????/?  error.. format example /annoy sound default User [path], or "clear"  ?\?`??"

Adding a sound to a specific trig or user works. But not setting just the default sound.  Any idea?

Thx
E
Title:
Post by: BottledHate on 06 August, 2004, 09:40:39
QuoteOriginally posted by Endless
I can't seem to get  this to work:
"/annoy sound default Users D:\listener.wav"
I get this error:
"????/?  error.. format example /annoy sound default User [path], or "clear"  ?\?`??"
heh, thats an error from me makiing the commads not case sensitive in a hurry for you...

it is fixed in 1.5... which will be posted manana... preview help commands...(still being refined):
[00:33:34] ????/?  Help For AnnoyMe script  ?\?`??
/annoy -lists the current AnonyMe list.
/annoy addU [nick] -adds a nick name to be annoyed by when the user comes online.
/annoy addT [trig] -adds a single word to Annoy you when said in chat.
/annoy removeU [nick] -remove the user from the AnnoyMe list.
/annoy removeT [trig] -remove the trig from the AnnoyMe list.
/annoy disableU [nick] -disables [nick] sounds and execute. still saves seen data and prints joins.
/annoy disableT [trig] -disables [trig] sounds and execute..
/annoy enableU [nick] -enable the user on the AnnoyMe list. (Enabled by default)
/annoy enable/disableALL -enable/disable ALL user and trig sounds and executes.
/annoy removeT [trig] -enable the trig on the AnnoyMe list. (Enabled by default)
/annoy removeall -remove all values.
/annoy seen [nick] -shows the last seen info for a person on your AnnoyMe list.
/annoy sound help -shows the sound help screen.
/annoy execute help -shows the execute help screen.
/annoy help -(this)
[00:33:40] ????/?  Help For AnnoyMe script Sounds  ?\?`??
Examples:
/annoy sound default Users c:\path\file.wav -set the default sounds.. sub 'Users' with 'Trigs' for default trigger sound.
/annoy sound user NickName c:\path\to a\sound.wav -adds a sound to a user on your AnnoyMe list
/annoy sound trig TrIgGeR c:\path\to a\sound.wav -adds a sound to a trig on your AnnoyMe list
/annoy sound clear trig, users, or all -clears all sounds in group or all sounds to default.
[00:33:42] ????/?  Help For AnnoyMe script Executes  ?\?`??
Examples:
/annoy execute default Users c:\path\file.exe -set the default execute.. sub 'Users' with 'Trigs' for default trigger file execute.
/annoy execute user NickName c:\path\to a\file.com -adds a file to execute to a user on your AnnoyMe list
/annoy execute trig TrIgGeR c:\path\to a\file.bat -adds a file to execute to a trig on your AnnoyMe list
/annoy execute clear [trig, users, or all] -clears all executes in group or all executions to default.


bed time!

-?H
Title:
Post by: BottledHate on 07 August, 2004, 02:54:25
1.5:
added: set a file to execute as well as sounds for each trig/user
added: enable/disable individual trigs/users on the annoy me list.. so u don't lose your settings if you just want it to shut up.
added: flood protection.. only annoys on trigs once in every 10 seconds.
fixed: help menus a bit
fixed: alot of little redundant stuff.. sure there still is more.
fixed: changed the way it handles online users on the list a bit.
fixed: more code clean up here and there as i learn more ;)


so anyways.. HERE (http://www.stcycles.com//hate/scripts/AnnoyMe1.5.lua) it is.... v1.5 of AnnoyMe.

edit:
????/?  Help For AnnoyMe script  ?\?`??
/annoy -lists the current AnonyMe list.
/annoy [add/remove][U/T] [/] -adds or removes a or to be annoyed by....
/annoy [enable/disable][U/T] [/] -enables or disables sounds and executes for the or .
/annoy [enable/disable]all -enable/disable ALL user and trig sounds and executes.
/annoy removeall -remove all values. (default sounds and executes are saved)
/annoy seen -shows the last seen info for a person on your AnnoyMe list.
/annoy sound help -shows the sound help screen.
/annoy execute help -shows the execute help screen.
/annoy help -(this)
Examples:
/annoy addU NiCKnamE
/annoy disableU NiCKnamE
/annoy removeT tRiggEr

????/?  Help For AnnoyMe script Sounds  ?\?`??
/annoy sound [user/trig] [/] [/clear]
/annoy sound default [users/trigs] [/clear]
Examples:
/annoy sound default Users c:\path\file.wav -set the default sounds.. sub 'Users' with 'Trigs' for default trigger sound.
/annoy sound default Trigs clear -clears the default sound for Trigs...
/annoy sound user NickName c:\path\to a\sound.wav -adds a sound to a user on your AnnoyMe list
/annoy sound trig TrIgGeR c:\path\to a\sound.wav -adds a sound to a trig on your AnnoyMe list
/annoy sound trig TrIgGeR clear -clears the sound for the specified trig.

????/?  Help For AnnoyMe script Executes  ?\?`??
/annoy execute [user/trig] [/] [/clear]
/annoy execute default [users/trigs] [/clear]
Examples:
/annoy execute default Users c:\path\file.exe -set the default execute.. sub 'Users' with 'Trigs' for default trigger file execute.
/annoy execute default Trigs clear -clears the default execute for Trigs...
/annoy execute user NickName c:\path\to a\file.com -adds a file to execute to a user on your AnnoyMe list
/annoy execute trig TrIgGeR c:\path\to a\file.bat -adds a file to execute to a trig on your AnnoyMe list
/annoy execute trig TrIgGeR clear -clears the execute for the specified trig.

-?H
Title:
Post by: BottledHate on 12 August, 2004, 22:38:56
request done... any other comments qtions... take it to Client side scripting. here is a thread (http://board.univ-angers.fr/thread.php?threadid=2558&boardid=24&sid=fa7097cad74fffde94fe63f476b5a5cc&page=1#1)


-BH
Title:
Post by: Endless on 13 August, 2004, 00:40:43
Been out of town a few days, and haven't had time to give 1.5 a try.  But I'm sure it will work :-)

Thanks for the script, seems to cover everything I was looking for and then some.

Thx agan...
E