Difference between revisions of "How to make your own theme"

From Scriptwiki
Jump to: navigation, search
m (added a link to URL-logger (this one only has the old coloring))
m (huuuge update, changed from variables to identifies, changed event colors to echo $color(event) and many small fixes)
Line 5: Line 5:
  
 
== Start ==
 
== Start ==
We'll start off with some variables, you can copy this alias, change the variables to whatever you like and run it by writing /setvars, you can leave some of the variables blank like %delimiter_timestamp_left and %delimiter_timestamp_right, so there won't be anything around the timestamp, the color variables should be set though.
+
We'll start with 2 aliases that returns colorcodes, and delimiters (ie < or > for <nick>).
Everytime you change these, you'll need to run the alias again.
+
You can leave some of the returned values blank like ts_right and ts_right (in theme_delimiter, timestamp delimiters), so there won't be anything around the timestamp.
  
  alias setvars {
+
  alias theme_color {
 
   ;color of timestamp
 
   ;color of timestamp
   set %color_timestamp 03
+
   if ($1 == timestamp) { return 03 }
 
   
 
   
 
   ;color of @-prefix
 
   ;color of @-prefix
   set %color_op 10
+
   if ($1 == prefix-op) { return 10 }
 
   
 
   
 
   ;color of +-prefix
 
   ;color of +-prefix
   set %color_voice 11
+
   if ($1 == prefix-voice) { return 11 }
 
   
 
   
 
   ;color of %-prefix
 
   ;color of %-prefix
   set %color_hop 06
+
   if ($1 == prefix-hop) { return 06 }
 
   
 
   
 
   ;color of nick  
 
   ;color of nick  
   set %color_nick 14
+
   if ($1 == nick) { return 14 }
 
   
 
   
 
   ;color of link
 
   ;color of link
   set %color_link 07
+
   if ($1 == link) { return 07 }
 
   
 
   
 
   ;color of left and right delimiters ie: <nick> (the < and > in there)
 
   ;color of left and right delimiters ie: <nick> (the < and > in there)
   set %color_delimiter 05
+
   if ($1 == delimiter) { return 05 }
 
   
 
   
 
   ;color of event name
 
   ;color of event name
   set %color_sysmsg 04
+
   if ($1 == sysmsg) { return 04 }
 
   
 
   
 
   ;color of system message delimiter ie: [highlight] (the [ and ] in there)
 
   ;color of system message delimiter ie: [highlight] (the [ and ] in there)
   set %color_system_delimiter 05
+
   if ($1 == sysdelimiter) { return 05 }
 +
}
 
   
 
   
 +
alias theme_delimiter {
 
   ;left delimiter of system messages ($chr(91) = [ and $chr(93) = ])
 
   ;left delimiter of system messages ($chr(91) = [ and $chr(93) = ])
   set %delimiter_system_left $chr(91)
+
   if ($1 == sys_left) { return $chr(91) }
 
   
 
   
 
   ;right delimiter of system messages
 
   ;right delimiter of system messages
   set %delimiter_system_right $chr(93)
+
   if ($1 == sys_right) { return $chr(93) }
 
   
 
   
 
   ;left delimiter of timestamp
 
   ;left delimiter of timestamp
   set %delimiter_timestamp_left (
+
   if ($1 == ts_left) { return ( }
 
   
 
   
 
   ;right delimiter of timestamp
 
   ;right delimiter of timestamp
   set %delimiter_timestamp_right )
+
   if ($1 == ts_right) { return ) }
 
   
 
   
 
   ;left delimiter of nick
 
   ;left delimiter of nick
   set %delimiter_left (
+
   if ($1 == nick_left) { return ( }
 
   
 
   
 
   ;right delimiter of nick
 
   ;right delimiter of nick
   set %delimiter_right )
+
   if ($1 == nick_right) { return ) }
 
  }
 
  }
  
Line 71: Line 73:
 
   
 
   
 
   ;check with regex if the line includes <nowiki>www. or http://</nowiki>
 
   ;check with regex if the line includes <nowiki>www. or http://</nowiki>
   if ($regex(%line,(<nowiki>/(\b(www.?\.|https?:\/\/|ftp:\/\/).)/i</nowiki>))) {
+
   if ($regex(%line,<nowiki>/(\b(www.?\.|https?:\/\/|ftp:\/\/).)/i</nowiki>)) {
 
   
 
   
 
     var %x = 1  
 
     var %x = 1  
Line 79: Line 81:
 
   
 
   
 
       ;check if a link is found
 
       ;check if a link is found
       if ($regex($gettok(%line,%x,32),(<nowiki>/(\b(www.?\.|https?:\/\/|ftp:\/\/).)/i</nowiki>))) {  
+
       if ($regex($gettok(%line,%x,32),<nowiki>/(\b(www.?\.|https?:\/\/|ftp:\/\/).)/i</nowiki>)) {  
 
         ;put some colors and underline to the link, $chr(31) is the underline
 
         ;put some colors and underline to the link, $chr(31) is the underline
         var %l2 = $+($clr(%color_link),$chr(31),$gettok(%line,%x,32),$chr(31),$clr)
+
         var %l2 = $+($clr($theme_color(link)),$chr(31),$gettok(%line,%x,32),$chr(31),$clr)
 
   
 
   
 
         ;replace the old link with the new, colored one
 
         ;replace the old link with the new, colored one
Line 102: Line 104:
 
     $matchtok(@.+.%,$left($nick($2,$1).pnick,1),1,46), $&
 
     $matchtok(@.+.%,$left($nick($2,$1).pnick,1),1,46), $&
 
     $replace($ifmatch, $&
 
     $replace($ifmatch, $&
     @,$+($clr(%color_op),@,$clr), $&
+
     @,$+($clr($theme_color(prefix-op)),@,$clr), $&
     +,$+($clr(%color_voice),+,$clr), $&
+
     +,$+($clr($theme_color(prefix-voice)),+,$clr), $&
     %,$+($clr(%color_hop),%,$clr) $&
+
     %,$+($clr($theme_color(prefix-hop)),%,$clr) $&
 
     ),$chr(160))
 
     ),$chr(160))
 
  }
 
  }
Line 117: Line 119:
 
   ;with custom delimiters
 
   ;with custom delimiters
 
   
 
   
  ;use the mirc event colors for text color, we need to replace rawmode with mode to get the correct color, we also don't want to trigger for raws
 
  ;and we check if $2 is set, so we can set the event color if we want to; ie. $theme_nick(Nick,own text)
 
 
  if (($event) && ($event != text) && ($event !isnum)) || ($2) { var %event_color = $color($replace($iif($2,$2,$event),rawmode,mode)) }
 
 
   
 
   
 
   return $+( $&
 
   return $+( $&
     $clr(%color_delimiter),%delimiter_left, $&
+
     $clr($theme_color(delimiter)),$theme_delimiter(nick_left), $&
 
     $modeprefix($1,$chan), $&
 
     $modeprefix($1,$chan), $&
     $clr(%color_nick),$1, $&
+
     $clr($theme_color(nick)),$1, $&
     $clr(%color_delimiter),%delimiter_right, $&
+
     $clr($theme_color(delimiter)),$theme_delimiter(nick_right), $&
     $clr(%event_color) $&
+
     $clr $&
 
     )
 
     )
 
  }
 
  }
Line 138: Line 136:
 
   ;with custom delimiter
 
   ;with custom delimiter
 
   
 
   
  ;this is the same if-statement as with the $theme_nick to set the text color.
 
  ;ie. $theme_system(topic) = in on topic event we can return [topic], $event will be topic, so the color will be "Topic text" from mirc color settings
 
  ;but in raw 332 (which returns the topic), $event will be "332", not "topic", so we have to use $theme_system(topic,topic) to set the right color
 
 
  if (($event) && ($event != text) && ($event !isnum)) || ($2) { var %event_color = $color($replace($iif($2,$2,$event),rawmode,mode)) }
 
 
   
 
   
 
   return $+( $&
 
   return $+( $&
     $clr(%color_system_delimiter),%delimiter_system_left, $&
+
     $clr($theme_color(sysdelimiter)),$theme_delimiter(sys_left), $&
     $clr(%color_sysmsg),$1, $&
+
     $clr($theme_color(sysmsg)),$1, $&
     $clr(%color_system_delimiter),%delimiter_system_right, $&
+
     $clr($theme_color(delimiter)),$theme_delimiter(sys_right), $&
     $clr(%event_color) $&
+
     $clr $&
 
     )
 
     )
 
  }
 
  }
Line 165: Line 158:
 
   ;note that you shouldn't add ( and ) around the timestamp, since they are already in a variable (which you can change).
 
   ;note that you shouldn't add ( and ) around the timestamp, since they are already in a variable (which you can change).
 
   .timestamp -f $+( $&
 
   .timestamp -f $+( $&
     $clr(%color_timestamp),%delimiter_timestamp_left, $&
+
     $clr($theme_color(timestamp)),$theme_delimiter(ts_left), $&
 
     HH:nn:ss, $&
 
     HH:nn:ss, $&
     %delimiter_timestamp_right, $&
+
     $theme_delimiter(ts_right), $&
 
     $clr)  
 
     $clr)  
 
  }
 
  }
Line 191: Line 184:
 
   ;then we have the echo, where we get to use $theme_nick, which returns
 
   ;then we have the echo, where we get to use $theme_nick, which returns
 
   ;modeprefix, and the brackets around the nick (see above)
 
   ;modeprefix, and the brackets around the nick (see above)
   echo -at $theme_nick($nick) %line  
+
   echo $color(own text) -at $theme_nick($nick) %line  
 
  }
 
  }
  
Line 205: Line 198:
 
   ;triggers for Cail, Caili, Cail:, Caili: basically nick + 2 characters  
 
   ;triggers for Cail, Caili, Cail:, Caili: basically nick + 2 characters  
 
   ;('i' in [i,$chr(44),:] is 'cause i'm sometimes referred to Caili, you can ofcourse remove it, or change it/add other characters)
 
   ;('i' in [i,$chr(44),:] is 'cause i'm sometimes referred to Caili, you can ofcourse remove it, or change it/add other characters)
 
+
 
   var %hlpattern = $+(/(^|\s),$me,([i,$chr(44),:]{0,2})?\b/i)
 
   var %hlpattern = $+(/(^|\s),$me,([i,$chr(44),:]{0,2})?\b/i)
 
   if ($regex($1-,%hlpattern)) {
 
   if ($regex($1-,%hlpattern)) {
Line 212: Line 205:
 
     if ($active != $chan) { echo -at $theme_system(highlight,highlight) $+($chan,/,$nick,:) %line }
 
     if ($active != $chan) { echo -at $theme_system(highlight,highlight) $+($chan,/,$nick,:) %line }
 
   
 
   
     echo -mt $chan $theme_nick($nick,highlight) %line
+
     echo $color(highlight) -mt $chan $theme_nick($nick) %line
 
   }
 
   }
 
   else {
 
   else {
     echo -mt $chan $theme_nick($nick) %line
+
     echo $color(normal text) -mt $chan $theme_nick($nick) %line
 
   }
 
   }
 
  }  
 
  }  
Line 223: Line 216:
  
 
  on ^*:TEXT:*:?: {
 
  on ^*:TEXT:*:?: {
   ;halt default actions, and set $1- into a variable
+
   ;halt default actions, and set $1- into a variable
 
   haltdef
 
   haltdef
 
   var %line = $urlc($1-)
 
   var %line = $urlc($1-)
 
   
 
   
   echo -mt $nick $theme_nick($nick) %line
+
   echo $color(normal text) -mt $nick $theme_nick($nick) %line
 
  }
 
  }
  
Line 239: Line 232:
 
   ;take it off from the 2nd
 
   ;take it off from the 2nd
 
   
 
   
   echo -mt $iif($chan,$chan,$nick) $theme_system(action) $nick $1-
+
   echo $color(action text) -mt $iif($chan,$chan,$nick) $theme_system(action) $nick $1-
   ;echo -mt $iif($chan,$chan,$nick) $+($clr($color(Action text)),*) $nick $1-
+
   ;echo $color(action text) -mt $iif($chan,$chan,$nick) * $nick $1-
 
  }
 
  }
  
Line 258: Line 251:
 
   ;if it's you who joins the chan, echo "You have entered #channel"
 
   ;if it's you who joins the chan, echo "You have entered #channel"
 
   if ($nick == $me) {
 
   if ($nick == $me) {
     echo -t $chan $theme_system(join) You have entered $chan
+
     echo $color(join) -t $chan $theme_system(join) You have entered $chan
 
   }
 
   }
 
   
 
   
Line 264: Line 257:
 
   ;show "Nick sets usermode +x" instead of quit and join
 
   ;show "Nick sets usermode +x" instead of quit and join
 
   elseif ($($+($(%registered.,0),$cid,.,$nick),2)) {
 
   elseif ($($+($(%registered.,0),$cid,.,$nick),2)) {
     echo -t $chan $theme_system(usermode) $nick sets usermode +x
+
     echo $color(join) -t $chan $theme_system(usermode) $nick sets usermode +x
 
   }  
 
   }  
 
   
 
   
 
   ;else show the normal join
 
   ;else show the normal join
 
   else {
 
   else {
     echo -t $chan $theme_system(join) $nick $site  
+
     echo $color(join) -t $chan $theme_system(join) $nick $site  
 
   }
 
   }
 
  }
 
  }
Line 280: Line 273:
 
   haltdef
 
   haltdef
 
   var %message = $1-
 
   var %message = $1-
   echo -t $chan $theme_system(part) $nick $site %message
+
   echo $color(part) -t $chan $theme_system(part) $nick $site %message
 
  }
 
  }
  
Line 304: Line 297:
 
     var %x = 1
 
     var %x = 1
 
     while ($comchan($nick,%x)) {
 
     while ($comchan($nick,%x)) {
       echo -t $comchan($nick,%x) $theme_system(quit) $nick $address %message  
+
       echo $color(quit) -t $comchan($nick,%x) $theme_system(quit) $nick $address %message  
 
       inc %x  
 
       inc %x  
 
     }
 
     }
Line 320: Line 313:
 
   ;check if you were kicked
 
   ;check if you were kicked
 
   if ($knick == $me) {  
 
   if ($knick == $me) {  
     echo -t $chan $theme_system(kick) You were kicked from $chan by $nick $+ : %message   
+
     echo $color(kick) -t $chan $theme_system(kick) You were kicked from $chan by $nick $+ : %message   
 
   }
 
   }
 
   
 
   
 
   ;else if you kicked someone
 
   ;else if you kicked someone
 
   elseif ($nick == $me) {  
 
   elseif ($nick == $me) {  
     echo -t $chan $theme_system(kick) You kicked $knick from $chan $+ : %message  
+
     echo $color(kick) -t $chan $theme_system(kick) You kicked $knick from $chan $+ : %message  
 
   }
 
   }
 
   
 
   
 
   ;else someone else kicked someone else
 
   ;else someone else kicked someone else
 
   else {
 
   else {
     echo -t $chan $theme_system(kick) $knick was kicked from $chan by $nick $+ : %message
+
     echo $color(kick) -t $chan $theme_system(kick) $knick was kicked from $chan by $nick $+ : %message
 
   }
 
   }
 
  }
 
  }
Line 344: Line 337:
 
     var %chans = 1
 
     var %chans = 1
 
     while ($chan(%chans)) {
 
     while ($chan(%chans)) {
       echo -t $chan(%chans) $theme_system(nick) You morphed to $newnick
+
       echo $color(nick) -t $chan(%chans) $theme_system(nick) You morphed to $newnick
 
       inc %chans  
 
       inc %chans  
 
     }
 
     }
Line 353: Line 346:
 
     var %chans = 1
 
     var %chans = 1
 
     while ($comchan($newnick,%chans) ) {
 
     while ($comchan($newnick,%chans) ) {
       echo -t $comchan($newnick,%chans) $theme_system(nick) $nick morphed to $newnick
+
       echo $color(nick) -t $comchan($newnick,%chans) $theme_system(nick) $nick morphed to $newnick
 
       inc %chans  
 
       inc %chans  
 
     }
 
     }
Line 367: Line 360:
 
   var %line = $urlc($1-)
 
   var %line = $urlc($1-)
 
   
 
   
   echo -at $theme_system(notice) $nick $+ : %line
+
   echo $color(notice) -at $theme_system(notice) $nick $+ : %line
 
  }
 
  }
  
Line 376: Line 369:
 
   ;we're gonna echo irssi-style "session started with $nick" when someone querys you
 
   ;we're gonna echo irssi-style "session started with $nick" when someone querys you
 
   
 
   
   echo -t $nick $theme_system(query) session started with $nick
+
   echo $color(info text) -t $nick $theme_system(query) session started with $nick
 
  }
 
  }
  
Line 387: Line 380:
 
   ;we'll check if you are affected by the mode change, and highlight the text if so
 
   ;we'll check if you are affected by the mode change, and highlight the text if so
 
   if ($me isin $1-) {
 
   if ($me isin $1-) {
     echo -t $chan $theme_system(chan mode,highlight) $nick sets mode: $1- on $chan
+
     echo $color(highlight) -t $chan $theme_system(chan mode) $nick sets mode: $1- on $chan
 
   
 
   
 
     ;if the active window isn't the same as the window where the highlight was; echo it to the active
 
     ;if the active window isn't the same as the window where the highlight was; echo it to the active
 
     ;you can take this off if you don't like to see it coming into active window
 
     ;you can take this off if you don't like to see it coming into active window
     if ($active != $chan) { echo -at $theme_system(chan mode,highlight) $nick sets mode: $1- on $chan }
+
     if ($active != $chan) { echo $color(highlight) -at $theme_system(chan mode) $nick sets mode: $1- on $chan }
 
   }
 
   }
 
   
 
   
 
   ;else, it doesn't affect you
 
   ;else, it doesn't affect you
 
   else {
 
   else {
     echo -t $chan $theme_system(chan mode) $nick sets mode: $1- on $chan
+
     echo $color(mode) -t $chan $theme_system(chan mode) $nick sets mode: $1- on $chan
 
   }
 
   }
 
  }
 
  }
Line 408: Line 401:
 
   ;check if there are no words, ($0 returns tokens seperated by $chr(32)), if this happens, the topic has been cleared
 
   ;check if there are no words, ($0 returns tokens seperated by $chr(32)), if this happens, the topic has been cleared
 
   if ($0 == 0) {  
 
   if ($0 == 0) {  
     echo -mt $chan $theme_system(topic) $chan $+ : $nick clears the topic
+
     echo $color(topic) -mt $chan $theme_system(topic) $chan $+ : $nick clears the topic
 
   }
 
   }
 
   
 
   
 
   ;else the topic is set or changed
 
   ;else the topic is set or changed
 
   else {  
 
   else {  
     echo -mt $chan $theme_system(topic) $chan $+ : $nick changes topic to $chr(34) $+ $1- $+ $chr(15) $+ $chr(34)
+
     echo $color(topic) -mt $chan $theme_system(topic) $chan $+ : $nick changes topic to $chr(34) $+ $1- $+ $chr(15) $+ $chr(34)
 
   }
 
   }
 
  }
 
  }
Line 429: Line 422:
 
   
 
   
 
   ;we'll echo a system message "whois Nick", name and host into seperate lines  
 
   ;we'll echo a system message "whois Nick", name and host into seperate lines  
   echo -at $theme_system(whois $2)  
+
   echo $color(whois) -at $theme_system(whois $2)  
   echo -at - name: $6-  
+
   echo $color(whois) -at - name: $6-  
   echo -at - host: $3 $+ @ $+ $4
+
   echo $color(whois) -at - host: $3 $+ @ $+ $4
 
  }
 
  }
 
   
 
   
Line 450: Line 443:
 
   
 
   
 
   ;we also echo how many channels the user is seen on
 
   ;we also echo how many channels the user is seen on
   echo -at - chans $+($chr(40),$numtok($3-,32),$chr(41),) %chans
+
   echo $color(whois) -at - chans $+($chr(40),$numtok($3-,32),$chr(41),) %chans
 
  }
 
  }
 
   
 
   
Line 456: Line 449:
 
  raw 312:*:{  
 
  raw 312:*:{  
 
   haltdef
 
   haltdef
   echo -at - using $3-  
+
   echo $color(whois) -at - using $3-  
 
  }
 
  }
 
   
 
   
Line 462: Line 455:
 
  raw 330:*: {
 
  raw 330:*: {
 
   haltdef
 
   haltdef
   echo -at - authed as $3  
+
   echo $color(whois) -at - authed as $3  
 
  }
 
  }
 
   
 
   
Line 470: Line 463:
 
   
 
   
 
   ;we will use $duration to calculate users idle and how long he has been connected to server
 
   ;we will use $duration to calculate users idle and how long he has been connected to server
   echo -at - idle: $duration($3) $+ ,  irc: $duration($calc( $ctime - $4 )) $+ , signon: $date($4) $time($4)
+
   echo $color(whois) -at - idle: $duration($3) $+ ,  irc: $duration($calc( $ctime - $4 )) $+ , signon: $date($4) $time($4)
 
  }
 
  }
 
   
 
   
  ''';raw 313 returns if the user is an IRC operator on network (quite rare ;)'''
+
  ''';raw 313 returns if the user is an IRC operator on network'''
 
  raw 313:*:{  
 
  raw 313:*:{  
 
   haltdef
 
   haltdef
   echo -at - $2 is an IRC operator on $network
+
   echo $color(whois) -at - $2 is an IRC operator on $network
 
  }
 
  }
 
   
 
   
Line 482: Line 475:
 
  raw 318:*:{
 
  raw 318:*:{
 
   haltdef
 
   haltdef
   ;echo -at $theme_system(whois $2)  
+
   ;echo $color(whois) -at $theme_system(whois $2)  
 
  }
 
  }
  
Line 491: Line 484:
 
  raw 331:*: {
 
  raw 331:*: {
 
   haltdef
 
   haltdef
   echo -t $2 $theme_system(topic,topic) No topic is set for $2
+
   echo $color(topic) -t $2 $theme_system(topic,topic) No topic is set for $2
 
  }
 
  }
 
   
 
   
Line 497: Line 490:
 
  raw 332:*: {
 
  raw 332:*: {
 
   haltdef
 
   haltdef
   echo -t $2 $theme_system(topic,topic) Topic is " $+ $3- $+ $chr(15) $+ "
+
   echo $color(topic) -t $2 $theme_system(topic,topic) Topic is " $+ $3- $+ $chr(15) $+ "
 
  }
 
  }
 
   
 
   
Line 503: Line 496:
 
  raw 333:*: {
 
  raw 333:*: {
 
   haltdef
 
   haltdef
   echo -t $2 $theme_system(topic,topic) Topic set by $gettok($3,1,33) on $asctime($4)
+
   echo $color(topic) -t $2 $theme_system(topic,topic) Topic set by $gettok($3,1,33) on $asctime($4)
 
  }
 
  }
 +
  
 
== Own input ==
 
== Own input ==
Line 511: Line 505:
 
=== /query ===
 
=== /query ===
 
Here we also add the irssi-style "session started with Someone", this can be used /query nick blaa blaa, or by doubleclicking a nick in nicklist or channel (if you have doubleclick action set to /query $$1 in options, alt+o -> mouse)
 
Here we also add the irssi-style "session started with Someone", this can be used /query nick blaa blaa, or by doubleclicking a nick in nicklist or channel (if you have doubleclick action set to /query $$1 in options, alt+o -> mouse)
 
 
  alias query {
 
  alias query {
 
   ;first, a silent query to open the chatwindow, we don't want to send anything yet
 
   ;first, a silent query to open the chatwindow, we don't want to send anything yet
Line 517: Line 510:
 
   
 
   
 
   ;we're adding the irssi-style "session started with Someone"
 
   ;we're adding the irssi-style "session started with Someone"
   echo -t $$1 $theme_system(query) session started with $$1
+
   echo $color(info) -t $$1 $theme_system(query) session started with $$1
 
   
 
   
 
   ;now we check if we had anything to send, if so, we'll do a silent msg for the nick
 
   ;now we check if we had anything to send, if so, we'll do a silent msg for the nick
 
   if ($2) {  
 
   if ($2) {  
 
     .msg $$1 $2-
 
     .msg $$1 $2-
     echo -t $$1 $theme_nick($me) $2-  
+
     echo $color(own text) -t $$1 $theme_nick($me) $2-  
 
   }
 
   }
 
  }
 
  }
Line 533: Line 526:
 
   
 
   
 
   .me $1-  
 
   .me $1-  
   echo -at $theme_system(action,action) $me $1-  
+
   echo $color(action) -at $theme_system(action) $me $1-  
   ;echo -at $+($clr($color(Action text)),*) $me $1-
+
   ;echo $color(action) -at * $me $1-
 
  }
 
  }
  
Line 542: Line 535:
 
   ;same goes for notice, we don't need to add haltdef's here since we do the commands silent
 
   ;same goes for notice, we don't need to add haltdef's here since we do the commands silent
 
   .notice $$1 $2-
 
   .notice $$1 $2-
   echo -t $theme_system(notice,notice) $$1 $+ : $2-  
+
   echo $color(notice) -t $theme_system(notice) $$1 $+ : $2-  
 
  }
 
  }
  

Revision as of 14:38, 17 June 2007

This tutorial is going to give you an overview on how to create your own theme by modifying various events and aliases. I'm not making a theme-engine here, just showing how to get things going. There are several ways to make your own theme, hope you get some ideas from this tutorial.
At this point you should already know basics of mircscripting, if you are still having some difficulties, take a look at How to start

Start

We'll start with 2 aliases that returns colorcodes, and delimiters (ie < or > for <nick>). You can leave some of the returned values blank like ts_right and ts_right (in theme_delimiter, timestamp delimiters), so there won't be anything around the timestamp.

alias theme_color {
 ;color of timestamp
 if ($1 == timestamp) { return 03 }

 ;color of @-prefix
 if ($1 == prefix-op) { return 10 }

 ;color of +-prefix
 if ($1 == prefix-voice) { return 11 }

 ;color of %-prefix
 if ($1 == prefix-hop) { return 06 }

 ;color of nick 
 if ($1 == nick) { return 14 }

 ;color of link
 if ($1 == link) { return 07 }

 ;color of left and right delimiters ie: <nick> (the < and > in there)
 if ($1 == delimiter) { return 05 }

 ;color of event name
 if ($1 == sysmsg) { return 04 }

 ;color of system message delimiter ie: [highlight] (the [ and ] in there)
 if ($1 == sysdelimiter) { return 05 }
}

alias theme_delimiter {
 ;left delimiter of system messages ($chr(91) = [ and $chr(93) = ])
 if ($1 == sys_left) { return $chr(91) }

 ;right delimiter of system messages
 if ($1 == sys_right) { return $chr(93) }

 ;left delimiter of timestamp
 if ($1 == ts_left) { return ( }

 ;right delimiter of timestamp
 if ($1 == ts_right) { return ) }

 ;left delimiter of nick
 if ($1 == nick_left) { return ( }

 ;right delimiter of nick
 if ($1 == nick_right) { return ) }
}

Helpful aliases

These aliases are meant to make things easier with the theme. I chose to do a couple of aliases, that returns stuff we need several times, it would be pointless to do same things over and over again. This makes the theme more easily modified, since you only need to change things in one place.

$clr

First we have clr alias (short for color), so we don't have to use ctrl+k in the script, just $clr(control code), ie. $clr(03) is the same as ctrl+k 3, (works with background colors), zeropads the given number to 2, ie. 3 -> 03.

alias clr { return $+($chr(3),$base($1,10,10,2)) $+ $iif($2,$+($chr(44),$base($2,10,10,2)),) }

$urlc

This is an alias which underlines and colors links, i use this in several places, so if you don't want to use this, replace all $urlc($1-) with $1- in the future
You can find a complete version of this URL-logger & coloring system from here

alias urlc {
 ;assign $1- into a variable
 var %line = $1-

 ;check with regex if the line includes www. or http://
 if ($regex(%line,/(\b(www.?\.|https?:\/\/|ftp:\/\/).)/i)) {

   var %x = 1 

   ;loop through the line
   while (%x <= $numtok(%line,32)) { 

     ;check if a link is found
     if ($regex($gettok(%line,%x,32),/(\b(www.?\.|https?:\/\/|ftp:\/\/).)/i)) { 
       ;put some colors and underline to the link, $chr(31) is the underline
       var %l2 = $+($clr($theme_color(link)),$chr(31),$gettok(%line,%x,32),$chr(31),$clr)

       ;replace the old link with the new, colored one
       %line = $puttok(%line,%l2,%x,32)
     } 
     inc %x 
   }
 }
 return %line
}

$modeprefix

An alias to return colored modeprefix of a nick, usage: $modeprefix($nick,$chan), you shouldn't modify this (except $chr(160) to $chr(32), read below) since the colors are in variables that we set earlier

alias modeprefix {
 ;we will use $matchtok to find out if modeprefix is one of @,+ or % and then replace them with colored ones
 ;if you don't like the space between left delimiter and nick when there's no mode, change the $chr(160) to $chr(32) or leave it blank

 return $iif( $&
   $matchtok(@.+.%,$left($nick($2,$1).pnick,1),1,46), $&
   $replace($ifmatch, $&
   @,$+($clr($theme_color(prefix-op)),@,$clr), $&
   +,$+($clr($theme_color(prefix-voice)),+,$clr), $&
   %,$+($clr($theme_color(prefix-hop)),%,$clr) $&
   ),$chr(160))
}

$theme_nick

An alias to return nick with modeprefix and delimiters, ie. (@Cail) This alias is used everytime someone says something/you do something. The purpose of this alias is to use it in events, and everytime you wish to change how your nick looks like, you only need to change it in one place.

alias theme_nick {
 ;this alias return colored timestamp, modeprefix, nick
 ;with custom delimiters


 return $+( $&
   $clr($theme_color(delimiter)),$theme_delimiter(nick_left), $&
   $modeprefix($1,$chan), $&
   $clr($theme_color(nick)),$1, $&
   $clr($theme_color(delimiter)),$theme_delimiter(nick_right), $&
   $clr $&
   )
}

$theme_system

Same purpose as $theme_nick, but used to return event names, ie. [join] with colors

alias theme_system {
 ;this alias returns colored system messages. ie: highlight, topic, etc.
 ;with custom delimiter


 return $+( $&
   $clr($theme_color(sysdelimiter)),$theme_delimiter(sys_left), $&
   $clr($theme_color(sysmsg)),$1, $&
   $clr($theme_color(delimiter)),$theme_delimiter(sys_right), $&
   $clr $&
   )
}

Events

These are the modified events to prevent mIRC from showing default text, and echo messages the way we want. Here are only a few common events, some of them even are a bit repetitive, but should give you an expression on how to handle the events.

On Start

For on start event, i only set the timestamp at this point.

on *:start:{ 
 ;we'll set this timestamp everytime when you start mirc, so the colors won't disappear
 ;i'm using timestamp format HH:nn:ss in here, you can ofcourse change it to whatever you like (/help time and date identifiers for format) 
 ;note that you shouldn't add ( and ) around the timestamp, since they are already in a variable (which you can change).
 .timestamp -f $+( $&
   $clr($theme_color(timestamp)),$theme_delimiter(ts_left), $&
   HH:nn:ss, $&
   $theme_delimiter(ts_right), $&
   $clr) 
}

On Input

Replacing our own input. We will be sending the same line we input, but echo a modified line. Note that on input event won't need ^ to trigger before default actions.

on *:INPUT:*: {
 ;we will check that ctrl wasn't pressed while pressing enter, and that it's not a command
 if ($left($1,1) === $readini(mirc.ini,text,commandchar)) && (!$ctrlenter) { return }

 ;halt the default actions
 haltdef

 ;we'll put the line into a variable, in case we want to modify it for the echo
 ;in this case i have an alias called urlc to underline and color links
 var %line = $urlc($1-)

 ;here is the part what we send as msg, we want to send $1- and not the modified variable
 .msg $target $1-

 ;then we have the echo, where we get to use $theme_nick, which returns
 ;modeprefix, and the brackets around the nick (see above)
 echo $color(own text) -at $theme_nick($nick) %line 
}

On Text (channel)

Replacing incoming text from a channel. Here we also make our own highlight system.

on ^*:TEXT:*:#: {
 ;again halt the default actions and assign $1- into a variable
 haltdef
 var %line = $urlc($1-)

 ;a regular expression to check if the line contains your nick
 ;triggers for Cail, Caili, Cail:, Caili: basically nick + 2 characters 
 ;('i' in [i,$chr(44),:] is 'cause i'm sometimes referred to Caili, you can ofcourse remove it, or change it/add other characters)

 var %hlpattern = $+(/(^|\s),$me,([i,$chr(44),:]{0,2})?\b/i)
 if ($regex($1-,%hlpattern)) {

   ;if the active window isn't the same as the window where the highlight was; echo it to the active
   if ($active != $chan) { echo -at $theme_system(highlight,highlight) $+($chan,/,$nick,:) %line }

   echo $color(highlight) -mt $chan $theme_nick($nick) %line
 }
 else {
   echo $color(normal text) -mt $chan $theme_nick($nick) %line
 }
} 

On Text (query)

Replacing incoming text from query.

on ^*:TEXT:*:?: {
 ;halt default actions, and set $1- into a variable
 haltdef
 var %line = $urlc($1-)

 echo $color(normal text) -mt $nick $theme_nick($nick) %line
}

On Action

Replacing action texts.

on ^*:ACTION:*:*: {
 haltdef

 ;if you like to see actions like: timestamp * nick does stuff, you can add ; in front of the 1st line and
 ;take it off from the 2nd

 echo $color(action text) -mt $iif($chan,$chan,$nick) $theme_system(action) $nick $1-
 ;echo $color(action text) -mt $iif($chan,$chan,$nick) * $nick $1-
}

On Join

Replacing join event. Also modified to show "Nick sets usermode +x", so you don't have to see the quit and join when a user sets mode +x.

Before:

(1359 04) [quit] Cail ~user@dsl-xx-xx-xx-xx.dhcp.inet.fi Registered
(1359 04) [join] Cail ~user@Cail.users.quakenet.org

After:

(1400 46) [usermode] Cail sets usermode +x

On to the script:

on ^*:JOIN:#: { 
 haltdef

 ;if it's you who joins the chan, echo "You have entered #channel"
 if ($nick == $me) {
   echo $color(join) -t $chan $theme_system(join) You have entered $chan
 }

 ;else if the nick has quit setting usermode +x
 ;show "Nick sets usermode +x" instead of quit and join
 elseif ($($+($(%registered.,0),$cid,.,$nick),2)) {
   echo $color(join) -t $chan $theme_system(usermode) $nick sets usermode +x
 } 

 ;else show the normal join
 else {
   echo $color(join) -t $chan $theme_system(join) $nick $site 
 }
}

On Part

Replacing part event (! means it won't trigger if you part).

on !^*:PART:#: {
 ;this event only triggers if someone else parts
 haltdef
 var %message = $1-
 echo $color(part) -t $chan $theme_system(part) $nick $site %message
}

On Quit

Replacing quit event, "Registered quits" aren't shown. This event works in conjunction with on join event to hide the quit and join when a user sets mode +x (see above). We have to use $comchan in here, since $chan doesn't exist in on quit event

on ^*:QUIT: {
 haltdef

 ;check if the quit message is "registered", this means the user is setting usermode +x
 ;we don't show the quit here, we only show "Nick sets usermode +x" when the user joins back

 if ($1 == registered) { 
   ;set a variable for ConnectionID and nick that unsets after 5 seconds.
   set -u5 $($+($(%registered.,0),$cid,.,$nick),1) $true
 } 

 ;else the quit is normal, and is looped through $comchans
 ;and echoed into each channel

 else { 
   var %message = $1-
   var %x = 1
   while ($comchan($nick,%x)) {
     echo $color(quit) -t $comchan($nick,%x) $theme_system(quit) $nick $address %message 
     inc %x 
   }
 }
}

On Kick

Replacing kick event, "you kicked", "you were kicked" and "someone was kicked by somebody".

on ^*:KICK:#: {
 ;halt default actions and assign kick message into a variable
 haltdef
 var %message = $1-

 ;check if you were kicked
 if ($knick == $me) { 
   echo $color(kick) -t $chan $theme_system(kick) You were kicked from $chan by $nick $+ : %message  
 }

 ;else if you kicked someone
 elseif ($nick == $me) { 
   echo $color(kick) -t $chan $theme_system(kick) You kicked $knick from $chan $+ : %message 
 }

 ;else someone else kicked someone else
 else {
   echo $color(kick) -t $chan $theme_system(kick) $knick was kicked from $chan by $nick $+ : %message
 }
}

On Nick

Replacing nick event, "you morphed to Somenick" and "Someone morphed to Someguy". Another place to use $comchan.

on ^*:NICK: {
 haltdef

 ;see if it's you who changed the nick and loop through all the channels
 if ($nick == $me) { 
   var %chans = 1
   while ($chan(%chans)) {
     echo $color(nick) -t $chan(%chans) $theme_system(nick) You morphed to $newnick
     inc %chans 
   }
 }

 ;else it's someone else who changed the nick, now we have to loop through $comchans
 else {
   var %chans = 1
   while ($comchan($newnick,%chans) ) {
     echo $color(nick) -t $comchan($newnick,%chans) $theme_system(nick) $nick morphed to $newnick
     inc %chans 
   }
 }
}

On Notice

Replacing notice event.

on ^*:NOTICE:*:?: {
 ;halt default actions, assign $1- into a var and acho notice into active window
 haltdef
 var %line = $urlc($1-)

 echo $color(notice) -at $theme_system(notice) $nick $+ : %line
}

On Open (Query)

Adding irssi-style "session started with $nick" to on open event.

on *:open:?:*:{ 
 ;we're gonna echo irssi-style "session started with $nick" when someone querys you

 echo $color(info text) -t $nick $theme_system(query) session started with $nick
}

On Rawmode

We're using rawmode to affect all the mode changes at the same, you can ofcourse do ON OP, ON VOICE, and other events if you wish to do them differently.

on ^*:RAWMODE:#: {
 haltdef

 ;we'll check if you are affected by the mode change, and highlight the text if so
 if ($me isin $1-) {
   echo $color(highlight) -t $chan $theme_system(chan mode) $nick sets mode: $1- on $chan

   ;if the active window isn't the same as the window where the highlight was; echo it to the active
   ;you can take this off if you don't like to see it coming into active window
   if ($active != $chan) { echo $color(highlight) -at $theme_system(chan mode) $nick sets mode: $1- on $chan }
 }

 ;else, it doesn't affect you
 else {
   echo $color(mode) -t $chan $theme_system(chan mode) $nick sets mode: $1- on $chan
 }
}

On Topic

We'll handle topic in 2 different places now, the other is on topic to see the topic changes, and other is raw's 331, 332 and 333, which are returned by /topic #channel when joining a channel.

on ^*:TOPIC:#: {
 haltdef 

 ;check if there are no words, ($0 returns tokens seperated by $chr(32)), if this happens, the topic has been cleared
 if ($0 == 0) { 
   echo $color(topic) -mt $chan $theme_system(topic) $chan $+ : $nick clears the topic
 }

 ;else the topic is set or changed
 else { 
   echo $color(topic) -mt $chan $theme_system(topic) $chan $+ : $nick changes topic to $chr(34) $+ $1- $+ $chr(15) $+ $chr(34)
 }
}


Raws

I'm not gonna add all of the raw events here, only a few common ones, like whois and topic. You should check Raws-section for more information on raws.

Whois

;raw 311 returns name and host after /whois
raw 311:*:{ 
 haltdef

 ;we'll echo a system message "whois Nick", name and host into seperate lines 
 echo $color(whois) -at $theme_system(whois $2) 
 echo $color(whois) -at - name: $6- 
 echo $color(whois) -at - host: $3 $+ @ $+ $4
}

;raw 319 returns channels where the user is
raw 319:*:{
 haltdef 
 var %x = 1,%chans

 ;we loop through the channels and put some colors to modeprefix and comchans
 while (%x <= $numtok($3-,32)) {
   %chan = $gettok($3-,%x,32)
   %mode = $iif($left(%chan,1) != $chr(35),$+($clr(3),$left(%chan,1),$clr),)
   %chan = $iif($left(%chan,1) != $chr(35),$right(%chan,-1),%chan)
   %chan = %mode $+ $iif($me ison %chan,$+($clr(12),%chan,$clr),%chan)
   %chans = %chans %chan
   inc %x
 }

 ;we also echo how many channels the user is seen on
 echo $color(whois) -at - chans $+($chr(40),$numtok($3-,32),$chr(41),) %chans
}

;raw 312 returns the server that the user is connected to
raw 312:*:{ 
 haltdef
 echo $color(whois) -at - using $3- 
}

;raw 330 returns authname of the user (only in Quakenet)
raw 330:*: {
 haltdef
 echo $color(whois) -at - authed as $3 
}

;raw 317 returns idletime and signontime of the user
raw 317:*:{ 
 haltdef

 ;we will use $duration to calculate users idle and how long he has been connected to server
 echo $color(whois) -at - idle: $duration($3) $+ ,  irc: $duration($calc( $ctime - $4 )) $+ , signon: $date($4) $time($4)
}

;raw 313 returns if the user is an IRC operator on network
raw 313:*:{ 
 haltdef
 echo $color(whois) -at - $2 is an IRC operator on $network
}

;raw 318 is the "end of whois", i usually like to hide it, but you can take the ; off from the echo.
raw 318:*:{
 haltdef
 ;echo $color(whois) -at $theme_system(whois $2) 
}

Topic

This is the other modification we make to affect the topic. These raws are sent to you when you join a channel or do /topic #channel.

;raw 331 is returned when you join a channel, or when you do /topic #channel, you'll get this raw instead of raw 332 if there is no topic on the channel
raw 331:*: {
 haltdef
 echo $color(topic) -t $2 $theme_system(topic,topic) No topic is set for $2
}

;raw 332 is the same as raw 331, but returns the topic if it's set
raw 332:*: {
 haltdef
 echo $color(topic) -t $2 $theme_system(topic,topic) Topic is " $+ $3- $+ $chr(15) $+ "
}

;raw 333 returns who set the topic and when, after joining a channel or by /topic #channel
raw 333:*: {
 haltdef
 echo $color(topic) -t $2 $theme_system(topic,topic) Topic set by $gettok($3,1,33) on $asctime($4)
}


Own input

These are just modified aliases to match the theme, you can modify other aliases the same way.

/query

Here we also add the irssi-style "session started with Someone", this can be used /query nick blaa blaa, or by doubleclicking a nick in nicklist or channel (if you have doubleclick action set to /query $$1 in options, alt+o -> mouse)

alias query {
 ;first, a silent query to open the chatwindow, we don't want to send anything yet
 .query $$1

 ;we're adding the irssi-style "session started with Someone"
 echo $color(info) -t $$1 $theme_system(query) session started with $$1

 ;now we check if we had anything to send, if so, we'll do a silent msg for the nick
 if ($2) { 
   .msg $$1 $2-
   echo $color(own text) -t $$1 $theme_nick($me) $2- 
 }
}

/me

This is quite a simple modification, pretty much all the aliases are modified the same way.

alias me { 
 ;silent /me $1- and echo, here you can also choose to show it like: * Nick does some action
 ;or by the theme

 .me $1- 
 echo $color(action) -at $theme_system(action) $me $1- 
 ;echo $color(action) -at * $me $1-
}

/notice

Yet one simple modification.

alias notice { 
 ;same goes for notice, we don't need to add haltdef's here since we do the commands silent
 .notice $$1 $2-
 echo $color(notice) -t $theme_system(notice) $$1 $+ : $2- 
}

Miscellaneous

Now you should be able to continue modifying other events and aliases on your own, here are just a few tips what you can do.

How to pad text, example:

1717 48           Cail@» hello
1718 01            Anu+» hello
1718 03           Cail@» ahii
1718 32       chan mode» @Cail sets mode: +o Anu: #channel

Since you cannot do that with $chr(32), you'll need to use $chr(160), and calculate how many of those you need to put before the nick:

$str($chr(160),$calc(15 - $len($nick))) $nick

15 is the max. lenght of nickname in Quakenet (you might set this into a variable when you connect to a server). This way all the nicknames will end in same place. Ofcourse you can do variations of this method like:

1717 48 @Cail__________» hello
1718 01 +Anu___________» hello
1718 03 @Cail__________» ahii
1718 32 chan mode______» @Cail sets mode: +o Anu: #channel