mIRC Home    About    Download    Register    News    Help

Print Thread
#178618 12/06/07 06:31 PM
Joined: Jun 2007
Posts: 37
E
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2007
Posts: 37
Hi, I was wondering if i could trigger an mp3 in my bot, with something like !play, !random, !stop, !shuffle etc..

;/ I don't know how to make an mp3 player do this though..


In a script bot ofcourse

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Here's a simple one..

Code:
alias mp3 {
  set %mp3dir $$sdir=" Set Mp3 Directory: "
  write -c mp3.txt
  noop $findfile(%mp3dir,*.mp3,0,write mp3.txt $1-)
}

on $*:text:/!(play|stop|pause|resume|random)/Si:*:{
  if ($isfile(mp3.txt)) {
    if ($1 == !random) splay $read(mp3.txt,$r(1,$lines(mp3.txt)))
    if ($1 == !play) splay $read(mp3.txt,$2)
    if ($1 == !stop) splay stop
    if ($1 == !pause) splay pause
    if ($1 == !resume) splay resume
  }
}


Simple put this in your bot, type /mp3 to set your directory. And in your mIRC/Script type the above commands.

!play 5 - Plays the fifth mp3 in your mp3 file, etc. It's just a pretty basic one as I have to go out now, I'm sure you'll get more responsive replies soon.

Joined: Jun 2007
Posts: 37
E
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2007
Posts: 37
Is there anyway to get it to spam?

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
Code:
alias mp3 {
  set %mp3dir $$sdir=" Set Mp3 Directory: "
  write -c mp3.txt
  noop $findfile(%mp3dir,*.mp3,0,write mp3.txt $1-)
}

on $*:text:/!(play|stop|pause|resume|random)/Si:*:{
  if ($isfile(mp3.txt)) {
    var %target = $iif($target ischan,$chan,$nick)
    if ($1 == !random) { splay $read(mp3.txt) | msg %target I'm now randomly playing $nopath($insong.fname) }
    if ($1 == !play) { splay $read(mp3.txt,$2) | msg %target I'm now playing $nopath($read(mp3.txt,$2)) }
    if ($1 == !stop) { 
      if ($insong) { splay stop | msg %target Song stopped }
      else { msg %target Song not started }
    }
    if ($1 == !pause) { 
      if ($insong) && (!$insong.pause) { splay pause | msg %target Song stopped. }
    }
    if ($1 == !resume) { 
      if ($insong) && ($insong.pause) { splay resume | msg %target Song resumed. }
    }
  }
}

Joined: Jun 2007
Posts: 37
E
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2007
Posts: 37
I know this is really annoying, But is there any way to get it to play my songs in alphabetical order? because they are all jumbled up ;/

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Without side tracking the topic to much.
Could you explain this little line?

on $*:text:/!(play|stop|pause|resume|random)/Si:*:{

Is the $ required for the !triggers ?
What's the /Si part?

Never seen this kind of combining before...

Thx confused

Joined: Mar 2005
Posts: 420
X
Fjord artisan
Offline
Fjord artisan
X
Joined: Mar 2005
Posts: 420
the $ means that regex is being used in the event. Im not into regex yet but what I could tell is that any word that matches the words listed then the event will be triggered.

Google for some regex tutorial smile


If you have a plastic floor runner over your tiles, then you're one Hella Pinoy!
Joined: Nov 2006
Posts: 1,559
H
Hoopy frood
Offline
Hoopy frood
H
Joined: Nov 2006
Posts: 1,559
Well, the $ prefix makes matching text a regex (therefore the /regex/)
S > applies "strip control codes"
i > applies "case insensitivity" to the regex

Joined: Jun 2007
Posts: 37
E
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2007
Posts: 37
Post deleted by EffingHell

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
You just nailed it with the if ($nick == <somenick>) didn't you try it?

Code:
on $*:text:/!(play|stop|pause|resume|random)/Si:*:{
  if ($nick == YourNick) {
    if ($isfile(mp3.txt)) {
      var %target = $iif($target ischan,$chan,$nick)
      if ($1 == !random) { splay $read(mp3.txt) | msg %target I'm now randomly playing $nopath($insong.fname) }
      if ($1 == !play) { splay $read(mp3.txt,$2) | msg %target I'm now playing $nopath($read(mp3.txt,$2)) }
      if ($1 == !stop) { 
        if ($insong) { splay stop | msg %target Song stopped }
        else { msg %target Song not started }
      }
      if ($1 == !pause) { 
        if ($insong) && (!$insong.pause) { splay pause | msg %target Song stopped. }
      }
      if ($1 == !resume) { 
        if ($insong) && ($insong.pause) { splay resume | msg %target Song resumed. }
      }
    }
  }
}

Joined: Jun 2007
Posts: 37
E
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2007
Posts: 37
!pause just stops the song and !resume restarts it :[

Joined: Dec 2002
Posts: 3,547
S
Hoopy frood
Offline
Hoopy frood
S
Joined: Dec 2002
Posts: 3,547
It shouldn't do, it works for me.

Change:

Code:
      if ($insong) && (!$insong.pause) { splay pause | msg %target Song stopped. }


to

Code:
      if ($insong) && (!$insong.pause) { splay pause | msg %target Song paused. }

Joined: Jun 2007
Posts: 37
E
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Jun 2007
Posts: 37
It's the exact same @_@


Link Copied to Clipboard