$addedtok

By zonirc on Apr 17, 2006

To added the specified text into Nth specified token.

Have been updated:

  • fixed Nth bugs
  • added .case properties
  • now accepting multi value of wildtext
/*
Name: $addedtok
Author: zonirc
Email: zonirc@email.com
mIRC version: 6.15 and above

ENGLISH
--------------------

Install:
type '/load -rs <this file address>' where <this file address> is the location where you save
this file. Type it in your mirc and when asked for authorization, click on any button to
continue, it does not have any effect on this file (no on load event)  

$addedtok(token,text,wildmatch character,position,separator,wildtext).case
to add the specified text into Nth specified position.

text:
the text that will be added into Nth matched token  

wildmatch character:
- the character that will act as a replacement for Nth matched token, for example when you
want to add text 'oy' into 2nd token, you can use like the example below:
    $addedtok(a b c d,*oy,*,2,32)
It means the character '*' in the specified text(*oy) will be replaced by 2nd token matched
which is 'b'. So it will return 'a boy c d'.
So how when you want to add text '*oy'? This what this parameter come handy where it allow
you to choose and specified any character that you wish that will be act as a replacement
of the Nth matching token. So you can use like the example below:
    $addedtok(a b c d,+*oy,+,2,32)
It means the character '+' inside the specified text(+*oy) will be replaced by the Nth
matching token which is 'b' and it will returning 'a boy c d'
However there are some problem with a space. When you use it like below:
    $addedtok(a b c d, oy , ,2,32)
This will return nothing and echoing the error message(Missing Wildmatch Character) into
your active and status window.
To overcame this problem, you can use like the example below:
    $addedtok(a b c d,* *oy,* *,2,32)
This will returning 'a boy c d' since it will replaced the character '* *' inside the
specified text(* *oy) with the 2nd token which is 'b'.
However there will be a problem with a double space like below example:
    $addedtok(a b c d,*  *oy* *,*  *,2,32)
This will return 'a boyb c d' as supposed to 'a boy* * c d' since mIRC will get rid the
extra space in the specified text and the specified wildmatch character. So mIRC will pass
'* *oy* *' as a text parameter and '* *' as a wilmatch character parameter. Then this will
return the wrong result which is 'a boyb c d'.
Other than that, you can specified more than 1 character as a wildmatch character like
the example below:
    $addedtok(a b c d,+*oy,++,2,32)
    $addedtok(a b c d,+*oy,+*,2,32)
Both will return the same result which is 'a boy c d'.

position:
- the position of the token to be matched. Specify it as '0', to add the specified text
into all token. Specify it as negative to add beginning from right

separator:
- the separator of the token is where the value must be a number in the form of ascii  
character code value. To get any available value you can use '$asc(<character>)' where
<character> is any character that mirc supports. For example, you can use '$asc(#)' and
it will return '35'.  

wildtext:  
- this is an optional parameter, if specified, it will match only the token that matched
the wildtext. Its now accepting multi value such as below:
    $addedtok(a b ae a,*o,*,1,32,*a*,*b*)
This will return 'ao bo aeo ao'.

.case:
- this is an optional properties, when specified it will matching with a case-sensitivity
version.

Example:

$addedtok(a b ae a,+oy,+,2,32) return a boy ae a
$addedtok(a b ae a,+oy,+,0,32) return aoy boy aeoy aoy
$addedtok(a b ae a,+oy,+,-2,32) return a b aeoy a
$addedtok(a b ae a,+oy,+,2,32,*a*) return a b aeoy a
$addedtok(a b ae a,+oy,+,2,32,a) return a b ae aoy
$addedtok(a b ae a,+oy,+,0,32,a) return aoy b ae aoy
$addedtok(a b ae a,+oy,+,0,32,a,b) return aoy boy ae aoy

Example Script:
on ^*:text:$($+(*,$me,*)):#:{
  echo $chan $+(<,$nick,>) $addedtok($1-,2*,*,1,32,$+(*,$me,*))
  haltdef
}
This example will result your nickname in colour when ever its included in any channel
messages.  

on ^*:text:*fuck*:#:{
  echo $chan $+(<,$nick,>) $addedtok($1-,$+(,$color(background),*),*,1,32,*fuck*)
  haltdef
}
 This will hide the word 'fuck' by giving it the same as the background. To see the text
you can change your background to other color or simply highlight the hidden text.

Credits:
- bruas@biase
- da^hype
- h3lp@ArePie
- MoJacKo^pIkO, [aM], bLuE_irC (coz allow me to test the sample script)
- Mpdreamz (coz find the bugs, comment of my grammar and typos error and also for advised 
me to renamed 'character' parameter as a 'wildmatch parameter')
- marlboro21 (coz editing some of my english)

BAHASA MALAYSIA
----------------------------------------------

Install:
Taip '/load -rs <fail nie punya lokasi>' dimana <fail nie punya lokasi>
merupakan lokasi fail nie di save oleh anda. Taip ia di mIRC anda dan
kemudian bila mirc memintak 'authorization', klik saja memana butang
yg terdapat pada message dialog tu.

$addedtok(token,teks,karekter penganti,kedudukan,pembahagi,wildteks).case
untuk menambah teks kedalam token berkedudukan seperti di nyatakan.

teks:
- teks yang akan di tambah ke dalam token yang berpadanan

karekter penganti:
- karekter yang akan di gunakan sebagai penganti bagi token yang ditemui, dimana sebagai
contoh sekiranya anda ingin menambah perkataan 'as' ke dalam token ke-2 maka anda boleh
menggunakan contoh di bawah:
    $addedtok(a b c d,*as,*,2,32)
Di mana ianya bermaksud karekter '*' di dalam teks yang dinyatakan(*as) akan digantikan
dengan token ke-2 yang di jumpai iaitu 'b'. Maka ianya akan menghasilkan 'a bas c d'.
Jadi, bagaimana pula sekiranya anda ingin menambah perkataan '*as'? Di sinilah bergunanya
parameter karekter penganti ini, di mana ia membenarkan anda memilih dan menyatakan
karekter yang anda suka sebagai pengganti kepada token yang berpadanan. Oleh itu, jika anda
menggunakan contoh pertama tadi, ia akan menghasilkan jawapan yang salah iaitu 'a bas c d'.
Di mana sepatutnya ia menghasilkan 'a b*as c d'. Oleh itu, anda boleh menggunakan contoh
seperti di bawah:
    $addedtok(a b c d,+*as,+,2,32)
Ini akan menghasilkan jawapan yang betul iaitu 'a b*as c d', di mana ianya bermaksud
karekter '+' di dalam teks(+*as) akan di ganti dengan token ke-2 iaitu 'b'.
Begitupun, ruang kosong(space) tidak dapat di sokong memandangkan mIRC secara automatik akan
memadam sebarang ruang kosong di hadapan dan belakang setiap parameter dan juga sebarang
lebihan ruang kosong di dalam parameter terbabit. Sebagai contoh anda boleh perhatikan
contoh yang di beri di bawah ini:
    $addedtok(a b c d, as , ,2,32)
Ini tidak akan memulangkan sebarang hasil dan akan memaparkan mesej ralat(Missing Wildmatch
Character Parameter) di tetingkap aktif dan status anda.
Untuk mengatasi permasalahan ini anda bolehlah menggunakan contoh seperti di bawah:
    $addedtok(a b c d,* *as,* *,2,32)
Ini akan menghasilkan 'a bas c d' yang bermaksud karekter '* *' di dalam teks '* *as' akan
diganti dengan token ke-2 iaitu 'b'.
Seperti dinyatakan di atas, ruang kosong tidak boleh dinyatakan berlebihan seperti contoh
di bawah ini:
    $addedtok(a b c d,*  *as* *,*  *,2,32)
Di mana, ianya sepatutnya akan menghasilkan 'a bas* * c d'. Begitupun oleh kerana masalah
ruang kosong berlebihan ianya tidak akan memulangkan jawapan tersebut sebaliknya ialah
'a basb c d'. Ini disebabkan mIRC akan menganggap karekter pembahagi yang di beri ialah
'* *'(tanpa dua ruang kosong) dan juga teks akan dianggap '* *as* *'(juga tanpa dua ruang 
kosong). Oleh itu, ia akan menggantikan karekter '* *' di dalam teks '* *as* *' dengan
token ke-2 iaitu 'b'.
Selain itu anda juga boleh menetapkan karekter penganti ini melebihi satu karekter seperti
contoh di bawah:
    $addedtok(a b c d,++as,++,2,32)
    $addedtok(a b c d,+*,as,+*,2,32)
Kedua-duanya akan menghasilkan jawapan yang sama iaitu 'a bas c d'.

kedudukan:
- kedudukan token yang ingin dipadankan. Nyatakan ia sebagai '0', untuk menambah teks
pada semua token. Nyatakan ia sebagai nombor negatif bagi memulakan carian daripada
sebelah kanan.

pembahagi:
- merupakan nombor karekter ascii yang bertindak sebagai pembahagi kepada token. Untuk
mendapatkan senarai nombor yang di sokong anda boleh gunakan '$asc(<karekter>)' dimana
<karekter> merupakan sebarang karekter kecuali ruang kosong(space). Sebagai contoh:
$asc(#) memulangkan '35'

wildteks:
- ini merupakan parameter pilihan iaitu jika dinyatakan ia akan memadankan token ke-N
yang berpadanan dengan wildteks ini. Sekarang ianya menerima pelbagai nilai seperti
contoh di bawah:
    $addedtok(a b ae a,*o,*,1,32,*a*,*b*)
Ini akan menghasilkan 'ao bo aeo ao'.

.case:
- ini merupakan pilihan 'properties' iaitu jika dinyatakan ia akan memadankan dengan
menitikberatkan persamaan huruf besar dan kecil pada wildtext.

Contoh:
$addedtok(a b ae a,+oy,+,2,32) menghasilkan a boy ae a
$addedtok(a b ae a,+oy,+,0,32) menghasilkan aoy boy aeoy aoy
$addedtok(a b ae a,+oy,+,-2,32) menghasilkan a b aeoy a
$addedtok(a b ae a,+oy,+,2,32,*a*) menghasilkan a b aeoy a
$addedtok(a b ae a,+oy,+,2,32,a) menghasilkan a b ae aoy
$addedtok(a b ae a,+oy,+,0,32,a) menghasilkan aoy b ae aoy
$addedtok(a b ae a,+oy,+,0,32,a,b) menghasilkan aoy boy ae aoy

Contoh Skrip:
on ^*:text:$($+(*,$me,*)):#:{
  echo $chan $+(<,$nick,>) $addedtok($1-,2*,*,1,32,$+(*,$me,*))
  haltdef
}
Contoh nie utk mengwarnakan nickname ade kepada warna biru(2) kalau ianya
ada di dalam mesej tersebut

on ^*:text:*babi*:#:{
  echo $chan $+(<,$nick,>) $addedtok($1-,$+(,$color(background),*),*,1,32,*babi*)
  haltdef
}
Contoh yang nie pula utk menapis perkataan 'babi' jadi kau takkan nampak
teks tu kat skrin kau. Sebenarnya dia hanya menggunakan trick iaitu mengwarnakan
teks 'babi' tu kepada warna latar belakang mirc window korang. So kalau nak
nengok teks ape yg di sensor tu korang leh tukarkan warna latar belakang korang
kepada warna lain, kalau camtu susah(pasal kena buat 2-3 kali kerja) korang leh
hilightkan aje teks yg tak nampak tu ... nanti nampak la.

Penghargaan:
- bruas@biase
- da^hype
- h3lp@ArePie
- MoJacKo^pIkO, [aM], bLuE_irC (sbb kasi aku test cth skrip tu pada dia)
- Mpdreamz (sebab menjumpai bugs, komen terhadap tatabahasa dan kesilapan taip pada bahagian
english dan juga atas cadangan mengubah nama parameter 'karekter' kepada 'wildmatch character')
- marlboro21 (sebab menyunting bahasa inggeris aku)

*/

alias addedtok {
  var %e = echo -ftsca Info * $!addedtok:, %f, %r = $1
  if (!$isid) $replace(%e,$,/) Unknown Command
  elseif (!$1) %e Missing Token Parameter
  elseif (!$2) %e Missing String Parameter
  elseif (!$3) %e Missing Ascii Parameter
  elseif ($4 !isnum) %e $iif($4,Invalid,Missing) N Parameter
  elseif ($5 !isnum) %e $iif($6,Invalid,Missing) C Parameter
  else {
    var %x = 5, %s = $2 $+ $iif($3 !isincs $2,$3)    
    %f = $!findtok $+ $iif($prop = case,cs) $+ (%r,%v,%n,$5)
    while ($0 $iif($6,>,>=) %x) {   
      var %n = $iif($4,$4,1), %w = $iif($ [ $+ [ $calc(%x + 1) ] ],$v1,*)
      while ($($replacex(%f,fin,wil,% $+ r,$1,v,w),2)) {
        var %v = $v1
        %r = $puttok(%r,$replacex(%s,$3,%v),$iif($(%f,2),$v1,$($replacex(%f,% $+ n,1),2)),$5)
        if (%n = $4) break
        inc %n
      }
      inc %x
    }
    return %r
  }
}

Comments

Sign in to comment.
QuickStep   -  Apr 17, 2006

Pretty Nice, Well done

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.