; Random phrases bot script
; by Roman production 2024
; gopher://shibboleths.org/
; Script that sends messages every 8-12 users phrases randomly

on $*:TEXT:*:#:{
  inc -u999999999 %msgCount
  if (!$botsonly) && ((%msgCount >= 8) && (%msgCount <= 12) && ($nick != $me)) {
    if (%msgCount == $rand(8, 12)) {
      var %randomPhrase = $getRandomLine(phrases.txt)
      msg $chan %randomPhrase
    }
  }
  if (%msgCount > 12) {
    unset %msgCount
  }
}

alias -l getRandomLine {
  var %file = phrases.txt
  var %lines = $lines(%file)
  var %random = $rand(1,%lines)
  var %line = $read(%file,%random)
  return %line
}