Script Optimization Question - 12/08/15 01:45 AM
Hi All,
Here is what I have been using for a while for a quote bot with audio playback. I am trying to see if there is a better way to do this. I am fairly knowledgeable in powershell. Though I don't believe there is a switch function that I can use. Well here is the code portion.
This is a sample portion. Current system is 68 quotes with up to 4 different quote audio files. I have what I need working. Just wondering if there was a better way to do this.
Thank you all for your time!
Here is what I have been using for a while for a quote bot with audio playback. I am trying to see if there is a better way to do this. I am fairly knowledgeable in powershell. Though I don't believe there is a switch function that I can use. Well here is the code portion.
Code:
on *:TEXT:!q *:#: { ;if ((%floodquote) || ($($+(%,floodquote.,$nick),2))) { return } ;set -u30 %floodquote On ;set -u60 %floodquote. $+ $nick On if ($2 isalnum) && ($2 <= $lines(%quotefile)) { msg $chan Quote $chr(91) $+ $chr(35) $+ $2 $+ $chr(92) $+ $lines(%quotefile) $+ $chr(93) $+ $chr(34) $+ $read(%quotefile, $2) $+ $chr(34) if ($2 == 1) { var %qr1 $rand(1,2) if (%qr1 == 1) { splay %soundquotes $+ q1-1.mp3 } else { splay %soundquotes $+ q1-2.mp3 } } elseif ($2 == 2) { var %qr2 $rand(1,4) if (%qr2 == 1) { splay %soundquotes $+ q2-1.mp3 } elseif (%qr2 == 2) { splay %soundquotes $+ q2-2.mp3 } elseif (%qr2 == 3) { splay %soundquotes $+ q2-3.mp3 } else { splay %soundquotes $+ q2-4.mp3 } } elseif ($2 == 3) { var %qr3 $rand(1,3) if (%qr3 == 1) { splay %soundquotes $+ q3-1.mp3 } elseif (%qr3 == 2) { splay %soundquotes $+ q3-2.mp3 } else { splay %soundquotes $+ q3-3.mp3 } } elseif ($2 == 4) { var %qr4 $rand(1,2) if (%qr4 == 1) { splay %soundquotes $+ q4-1.mp3 } else { splay %soundquotes $+ q4-2.mp3 } } } }
This is a sample portion. Current system is 68 quotes with up to 4 different quote audio files. I have what I need working. Just wondering if there was a better way to do this.
Thank you all for your time!