Difference between revisions of "How to make your own theme"
m |
m (added kick, nick, notice, open events, changed $clr to support backgroundcolors) |
||
Line 57: | Line 57: | ||
=== $clr === | === $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 | 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 | ||
− | alias clr { return $+($chr(3),$ | + | alias clr { return $+($chr(3),$base($1,10,10,2)) $+ $iif($2,$+($chr(44),$base($2,10,10,2)),) } |
=== $urlc === | === $urlc === | ||
Line 224: | Line 224: | ||
=== On Join === | === On Join === | ||
− | Replacing join | + | Replacing join event. |
on ^*:JOIN:#: { | on ^*:JOIN:#: { | ||
Line 247: | Line 247: | ||
=== On Part === | === On Part === | ||
− | Replacing part | + | Replacing part event (! means it won't trigger if you part). |
on !^*:PART:#: { | on !^*:PART:#: { | ||
Line 257: | Line 257: | ||
=== On Quit === | === On Quit === | ||
− | Replacing quit | + | Replacing quit event, "Registered quits" aren't shown. |
on ^*:QUIT: { | on ^*:QUIT: { | ||
Line 282: | Line 282: | ||
} | } | ||
+ | === 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- | ||
+ | |||
+ | ;if you were kicked | ||
+ | if ($knick == $me) { | ||
+ | echo -t $chan $theme_system(kick) You were kicked from $chan by $nick $+ : %message | ||
+ | } | ||
+ | |||
+ | ;else if you kicked someone | ||
+ | elseif ($nick == $me) { | ||
+ | echo -t $chan $theme_system(kick) You kicked $knick from $chan $+ : %message | ||
+ | } | ||
+ | |||
+ | ;else someone else kicked someone else | ||
+ | else { | ||
+ | echo -t $chan $theme_system(kick) $knick was kicked from $chan by $nick $+ : %message | ||
+ | } | ||
+ | } | ||
+ | |||
+ | === On Nick === | ||
+ | Replacing nick event, "you kicked", "you were kicked" and "someone was kicked by somebody". | ||
+ | |||
+ | 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 -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 -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 -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 -t $nick $theme_system(query) session started with $nick | ||
+ | } | ||
[[Category:Tutorials]] | [[Category:Tutorials]] |
Revision as of 19:35, 2 October 2006
Contents
Start
We'll start off with some variables, these all need to be set for theme to work
alias setvars { ;color of timestamp set %color_timestamp 03 ;color of @-prefix set %color_op 10 ;color of +-prefix set %color_voice 11 ;color of %-prefix set %color_hop 06 ;color of nick set %color_nick 14 ;color of highlight line set %color_highlight 04 ;color of link set %color_link 07 ;color of left and right delimiters ie: <nick> set %color_delimiter 05 ;color of a system message set %color_sysmsg 04 ;color of system message delimiter ie: !highlight> set %color_system_delimiter 05 ;left delimiter of system messages set %delimiter_system_left ! ;right delimiter of system messages set %delimiter_system_right > ;left delimiter of timestamp set %delimiter_timestamp_left ( ;right delimiter of timestamp set %delimiter_timestamp_right ) ;left delimiter of nick set %delimiter_left ( ;right delimiter of nick set %delimiter_right ) }
Helpful aliases
These aliases are meant to make things easier with the theme
$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
alias clr { return $+($chr(3),$base($1,10,10,2)) $+ $iif($2,$+($chr(44),$base($2,10,10,2)),) }
$urlc
Then an alias which underlines and colors links
alias urlc { ;assign $1- into a variable var %line = $1- ;check with regex if the line includes www. or http:// if ($regex(%line,(\bwww\.|http:\/\/))) { var %x = 1 ;loop through the line while (%x <= $numtok(%line,32)) { ;check if a link is found if ($regex($gettok(%line,%x,32),(www\.|http:\/\/))) { ;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) ;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)
alias modeprefix { ;we will uset $matchtok to find out if modeprefix is one of @,+ or % ;and then replace to color them ;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 blanc return $iif( $& $matchtok(@.+.%,$left($nick($2,$1).pnick,1),1,46), $& $replace($ifmatch, $& @,$+($clr(%color_op),@,$clr), $& +,$+($clr(%color_voice),+,$clr), $& %,$+($clr(%color_hop),%,$clr) $& ),$chr(160)) }
$theme_nick
An alias to return nick with modeprefix and delimiters, ie. (@Cail)
alias theme_nick { ;this alias return colored timestamp, modeprefix, nick ;with custom delimiters return $+( $& $clr(%color_delimiter),%delimiter_left, $& $modeprefix($1,$chan), $& $clr(%color_nick),$1, $& $clr(%color_delimiter),%delimiter_right, $& $clr $& ) }
$theme_system
An alias, same as Theme_nick but return system messages, ie. (join) with colors
alias theme_system { ;this alias returns colored system messages. ie: highlight, topic, etc. ;with custom delimiter ;use the mirc event colors for text color if ($event) && ($event != text) { var %event_color = $color($event) } return $+( $& $clr(%color_system_delimiter),%delimiter_system_left, $& $clr(%color_sysmsg),$1, $& $clr(%color_system_delimiter),%delimiter_system_right, $& $clr(%event_color) $& ) }
Events
These are the modified events to prevent the mirc default text with haltdef, and echo messages the way we want.
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 .timestamp -f $+( $& $clr(%color_timestamp),%delimiter_timestamp_left, $& HHnn ss, $& %delimiter_timestamp_right, $& $clr) }
On Input
Replacing our own input.
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, that underlines and colors links var %line = $urlc($1-) ;here is the part what we send as msg, we want to send $1- and not the variable .msg $target $1- ;then we have the echo, where i'm also using my own alias theme_nick, which returns ;modeprefix, and the brackets around the nick echo -at $theme_nick($nick) %line }
On Text (channel)
Replacing incoming text from a channel.
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:, basically nick + 1 character if ($regex($1-,$+(/\b,$me,.?\b/i))) { ;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) $+($clr(4),$chan,/,$nick,:) %line } echo -mt $chan $theme_nick($nick) $+($clr(%color_highlight),%line) } else { echo -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 -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 ; infront of the 1st line and ;take it off from the 2nd echo -mt $iif($chan,$chan,$nick) $theme_system(action) $nick $1- ;echo -mt $iif($chan,$chan,$nick) $+($clr($color(Action text)),*) $nick $1- }
On Join
Replacing join event.
on ^*:JOIN:#: { haltdef ;if it's you who joins the chan, echo "You have entered #channel" if ($nick == $me) { echo -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 -t $chan $theme_system(usermode) $nick sets usermode +x } ;else show the normal join else { echo -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 -t $chan $theme_system(part) $nick $site %message }
On Quit
Replacing quit event, "Registered quits" aren't shown.
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 -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 -t $comchan($nick,%x) $theme_system(quit) $nick $site %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- ;if you were kicked if ($knick == $me) { echo -t $chan $theme_system(kick) You were kicked from $chan by $nick $+ : %message } ;else if you kicked someone elseif ($nick == $me) { echo -t $chan $theme_system(kick) You kicked $knick from $chan $+ : %message } ;else someone else kicked someone else else { echo -t $chan $theme_system(kick) $knick was kicked from $chan by $nick $+ : %message } }
On Nick
Replacing nick event, "you kicked", "you were kicked" and "someone was kicked by somebody".
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 -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 -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 -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 -t $nick $theme_system(query) session started with $nick }