mIRC Home    About    Download    Register    News    Help

Print Thread
Joined: Oct 2004
Posts: 20
E
eduard0 Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Oct 2004
Posts: 20
I'd like to get channel's topic, remove the first word / a specified part of text / some first letters of it and save it to %var after that. How do I do that?

Joined: Apr 2006
Posts: 464
O
Fjord artisan
Offline
Fjord artisan
O
Joined: Apr 2006
Posts: 464
Well doing all of it, is a bit difficult, would require 3 seperate scripts / commands in my opinion.

Anyway, to get the channels topic, and save it in a variable, you could use something like this
Code:
alias Get-Topic {
  set %channel-topic $chan($active).topic
  echo -s Topic is %channel-topic
}


Usage:
/Get-Topic
In the channel where you want to get the topic from.
Currently it will return the topic in the status window, just to visualise it, you could take that part out as well.

To remove the first word, some letter or some part, read up on:
$gettok
$left
$mid
$len

Or specify what you actually want with the topic.

Good luck.

Joined: Oct 2004
Posts: 20
E
eduard0 Offline OP
Ameglian cow
OP Offline
Ameglian cow
E
Joined: Oct 2004
Posts: 20
I'm working on a script that would change a specified channel's topic every 0:00am so that the topic first looks like this (for example): "TTG:91 other text" and after the idea is to replace the TTG:91 with TTG:90 next day and TTG:89 the following day.

I think it's easier to deal with the topic in multiple parts, so that one %var contains the number that will be reduced by 1 every 0:00 and the other topic would be saved in it's own %var.

Joined: Sep 2003
Posts: 4,230
D
Hoopy frood
Offline
Hoopy frood
D
Joined: Sep 2003
Posts: 4,230
Code:
;
;usage $new.topic.string(<channel>,<?|-|+|N>)
;
alias new.topic.string {
  if ($chan($1) == $1) {
    if (TTG:* * iswm $chan($1).topic) {
      var %num = $mid($gettok($chan($1).topic),1,32),5)
      if ($2 == ?) { return %num }
      if ($2 == -) { dec %num }
      if ($2 == +) { inc %num }
      if ($2 isnum) { var %num = $2 }
      return $+(TTG:,%num $gettok($chan($1).topic),2-,32))
    }
  }
}

* untested *

This does not set the topic but returns with a new topic string that you can set or do what ever you want with, that or it returns with the NUMBER from the topic
examples below... assume topic of #channelname is "TTG:90 blah blah blah" (the topic must start with TTG: then have one or more words to it.)

//echo -a $new.topic.string(#channelname,?)
90
//echo -a $new.topic.string(#channelname,-)
TTG:89 blah blah blah
//echo -a $new.topic.string(#channelname,+)
TTG:91 blah blah blah
//echo -a $new.topic.string(#channelname,88)
TTG:88 blah blah blah


Link Copied to Clipboard