How to make your own theme: Difference between revisions
m added own input-section, query, me, notice aliases |
m some corrections |
||
| Line 369: | Line 369: | ||
on ^*:TOPIC:#: { | on ^*:TOPIC:#: { | ||
haltdef | haltdef | ||
;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 -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 { | ||
Revision as of 05:31, 5 October 2006
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, 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_system(topic,topic)
if (($event) && ($event != text) && ($event !isnum)) || ($2) { var %event_color = $color($replace($iif($2,$2,$event),rawmode,mode)) }
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
}
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
echo -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
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 -mt $chan $theme_system(topic) $chan $+ : $nick clears the topic
}
;else the topic is set or changed
else {
echo -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.
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 -at $theme_system(whois $2)
echo -at - name: $6-
echo -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 -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 -at - using $3-
}
;raw 330 returns authname of the user (only in Quakenet)
raw 330:*: {
haltdef
echo -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 -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:*:{
haltdef
echo -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 -at $theme_system(whois $2)
}
Topic
This is the other modification we make to affect the topic.
;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 -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 -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 -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
/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 -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 -t $$1 $theme_nick($me) $2-
}
}
/me
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 -at $theme_system(action,action) $me $1-
;echo -at $+($clr($color(Action text)),*) $me $1-
}
/notice
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 -t $theme_system(notice,notice) $$1 $+ : $2-
}