topic with $lines in it

Do you have script in mind but no ability to make it, type in what it should do, and you might be lucky.

topic with $lines in it

Postby Ark » Tue Nov 04, 2008 7:57 pm

im scripting a bnc request script but im having a problem the way the script gos it someone privmasg the bot !apply when the bot logs the request
i would like it to change the topic and read how many lines are in the request txt so it would go user types !apply the bot loges the request then changes the channel topic to "topic here blah blah then Applacations pending [0] or however many lines there are in the txt file
Ark
 

Re: topic with $lines in it

Postby Cristian » Tue Nov 04, 2008 10:10 pm

If I understood your text correctly, then this script should do the job.

The trigger is: !apply
The information written to the text file is the persons nickname and hostname.

I am using a seperator (|) in the topic to better management. (default)

Edit the local aliasses to fill you needs. (channel,filename,text output,seperator)

If you have questions or problems, don't hesitate to post them. Have fun.

Code: Select all
alias -l ::channel { return #channel }
alias -l ::filename { return pending.txt }
alias -l ::text { return Applications pending $+([,$lines($::filename),]) }
alias -l ::seperator { return $asc(|) }

on *@:TEXT:!apply:$($::channel): {

  var %hostname = $address($nick,1)
  if ($read($::filename, w, %hostname)) {
    return
  }

  var %topic = $chan($chan).topic
  .write $::filename $nick %hostname

  if ($numtok(%topic,$::seperator) == 1) {
    .topic $chan %topic $+($chr(32),$chr($::seperator),$chr(32),$::text)
  }
  else {
    var %x = $numtok(%topic,$::seperator)
    var %topic = $deltok(%topic,$+(%x,-),$::seperator)

    .topic $chan %topic $+($chr(32),$chr($::seperator),$chr(32),$::text)
  }
}
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: topic with $lines in it

Postby Ark » Tue Nov 04, 2008 10:36 pm

this is what ive scripted so far
Code: Select all
on *:text:!BNchelp:*: {
  msg # 14 To Apply For A 11BNC 14/MSG 11BNC 11!Apply 8*11Nick 3: 11User 3: 11Pass 3: 11Email.8* 14Please Allow 24hrs For SetUp We Will Notify You Via Email If Your BNC Is Approved
}
On *:text:!Apply*:?: {
  write Request.txt 8*14 $nick 10 $+ 9 $2- 11 $+ 8*
  if (%Apply != $null) {
    msg $nick Request recorded as Request %Request $+ .
    inc %Request 1
  }
  if (%Request == $null) {
    set %Apply
    msg $nick 11Request 14Has Been 11Logged 14Please Be Allow 1124HRs 14For Setup As We May Be 11Busy %Request $+ .
  }
}
On *:text:.Pending:#bnc^admins: {
  if ($nick isop $chan) {
    msg # $lines(Request.txt) 14Requests 4Pending
    play $chan Request.txt
  }
  elseif ($nick !isop $chan) { msg # 14You are not allowed to use this Command 4Admins Only
  }
}
on *:text:.Clear:#bnc^admins: {
  if ($nick isop $chan) {
    remove Request.txt
    msg #  14Requests 4Deleted
    msg #  $lines(request.txt) 14Requests 4Pending
  }
  elseif ($nick !isop $chan) { msg # 14You are not allowed to use this Command 4Admins Only
  }
}

were would i add your script? lol and would it change the topic from this 11 14[15BNC^Admins14] |8x14| [15Current Applications Pending:11 0.14] |8x14| [15Current News:11 14]
to this 11 14[15BNC^Admins14] |8x14| [15Current Applications Pending:11 1.14] |8x14| [15Current News:11 14]
per !apply request notice in topic from 0 to 1 on so on
Ark
 

Re: topic with $lines in it

Postby Cristian » Tue Nov 04, 2008 10:41 pm

Applications pending [?] will be appended last in the topic.

So I would set it up like this --> ' topic-info - topic-info - topic-info | Applications pending [?] '.
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: topic with $lines in it

Postby Ark » Tue Nov 04, 2008 11:04 pm

im sorry but im new at this could u add it into the script i posted i tried to but i wont work :|
and put in an alies -1 topic::11 14[15BNC^Admins14] |8x14|  sorry for being a pain i just need to see were it should be :roll:
Ark
 

Re: topic with $lines in it

Postby Cristian » Wed Nov 05, 2008 4:33 am

What have you tried? Show me.

You have been given a script, read it thru, try and understand how it works.

Implement it into your own code, test it. If it doesn't work add "echo -a something" and test it again, find out where it stops, and why.

I have noticed, that I haven't given you the correct script, mine is channel based, if you try and use the "," it would be easier to read.

Code: Select all
alias -l ::channel { return #channel }
alias -l ::filename { return request.txt }
alias -l ::text { return Applications pending $+([,$lines($::filename),]) }
alias -l ::seperator { return $asc(|) }

on *@:TEXT:!apply & & &:?: {

  var %hostname = $address($nick,1)
  if ($read($::filename, w, %hostname)) {
    return
  }
  if ($me !isop $::channel) { msg $::channel I need operator status. | return }

  var %topic = $chan($::channel).topic
  .write $::filename $nick $1-4 %hostname

  if ($numtok(%topic,$::seperator) == 1) {
    .topic $::channel %topic $+($chr(32),$chr($::seperator),$chr(32),$::text)
  }
  else {
    var %x = $numtok(%topic,$::seperator)
    var %topic = $deltok(%topic,$+(%x,-),$::seperator)

    .topic $::channel %topic $+($chr(32),$chr($::seperator),$chr(32),$::text)
  }
}
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: topic with $lines in it

Postby Ark » Wed Nov 05, 2008 12:51 pm

this is how i implamented ur script in to mine but it still dosent change topic on !apply i wanted the script to activate it on a voiced user



Code: Select all
on *:text:!BNchelp:*: {
  msg # 14 To Apply For A 11BNC 14/MSG 11BNC 11!Apply 8*11Nick 3: 11User 3: 11Pass 3: 11Email.8* 14Please Allow 24hrs For SetUp We Will Notify You Via Email If Your BNC Is Approved
}
On *:text:!Apply*:?: {
  write Request.txt 8*14 $nick 10 $+ 9 $2- 11 $+ 8*
  if (%Apply != $null) {
    msg $nick Request recorded as Request %Request $+ .
    inc %Request 1
  }
  if (%Request == $null) {
    set %Apply
    msg $nick 11Request 14Has Been 11Logged 14Please Be Allow 1124HRs 14For Setup As We May Be 11Busy %Request $+ .
  }
}
On *:text:.Pending:#bnc^admins: {
  if ($nick isop $chan) {
    msg # $lines(Request.txt) 14Requests 4Pending
    play $chan Request.txt
  }
  elseif ($nick !isop $chan) { msg # 14You are not allowed to use this Command 4Admins Only
  }
}
on *:text:.Clear:#bnc^admins: {
  if ($nick isop $chan) {
    remove Request.txt
    msg #  14Requests 4Deleted
    msg #  $lines(request.txt) 14Requests 4Pending
  }
  elseif ($nick !isop $chan) { msg # 14You are not allowed to use this Command 4Admins Only
  }
}
alias -l ::channel { return #bnc^admins }
alias -l ::filename { return Request.txt }
alias -l ::text { return 11 14[15BNC^Admins14] |8x14| [15Current Applications pending $+([,$lines($::filename),]) }
alias -l ::seperator { return $asc(|) }

on *:TEXT:!apply & & &:?: {

  var %hostname = $address($nick,1)
  if ($read($::filename, w, %hostname)) {
    return
  }
  if ($me !isop $::channel) { msg $::channel I need operator status. | return }

  var %topic = $chan($::channel).topic
  .write $::filename $nick $1-4 %hostname

  if ($numtok(%topic,$::seperator) == 1) {
    .topic $::channel %topic $+($chr(32),$chr($::seperator),$chr(32),$::text)
  }
  else {
    var %x = $numtok(%topic,$::seperator)
    var %topic = $deltok(%topic,$+(%x,-),$::seperator)

    .topic $::channel %topic $+($chr(32),$chr($::seperator),$chr(32),$::text)
  }
}
Ark
 

Re: topic with $lines in it

Postby Cristian » Wed Nov 05, 2008 5:21 pm

Try and remove your first !apply script.
Cristian
proof of advance
proof of advance
 
Posts: 282
Joined: Sun Nov 04, 2007 3:02 pm
Location: Denmark
Authnick: Sumsar

Re: topic with $lines in it

Postby Ark » Wed Nov 05, 2008 11:02 pm

tanks sumsar that worked thamks for all your help
*SOLVED*
Ark
 


Return to Mirc Scripting Request

Who is online

Users browsing this forum: No registered users and 0 guests

cron