mIRC Home    About    Download    Register    News    Help

Print Thread
#270168 15/04/22 08:46 AM
Joined: Apr 2022
Posts: 11
T
Trinity Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Apr 2022
Posts: 11
I have this code and as you can see it sets Variables.
Code
on *:sockread:radiotest: {
  if ($sockerr > 0) return
  var %radiotest | sockread -fn %radiotest
  if ($regex(%radiotest,/<body>(.*)<\/body>/)) {
    set %radiotest.song $gettok($regml(1),7-,44)
    if (%radiotest.song != %radiotest.lastsong) {
      msg %radiotest.room 4 DJ 11 %dj 4: %radiotest.song 
      set %radiotest.lastsong %radiotest.song
    }
  }
}

The variable is set like this
Code
%radiotest.song Drivin&apos; N&apos; Cryin&apos; - Fly Me Courageous

The output to the chat room is the same, whereas I want it like this.
Drivin' N' Cryin' - Fly Me Courageous
There are a couple of others with instances like this with chars. &, " etc.
I have seen code like
Code
$replace($1-,&apos;,')
but don't know how to implement it to get the variable changed to present to the chat room.
Thanks in advance for any help.

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
I am not the author of these, as I found them in my aliases. Put these aliases in any remote script. the '-l' switch makes the last 2 aliases 'local' so they can only be seen by another alias in the same script file, so remove the -l if you want to access them directly

Code
//echo -a $html2ascii(test1 &apos; test2 &#x2d; test3)

//var %text %radiotest.song Drivin&apos; N&apos; Cryin&apos; - Fly Me Courageous | echo -a $html2ascii(%text)

alias html2ascii return $regsubex($1-,/&(.{2,6});/Ug,$ht2chr(\t))
alias -l ht2chr if (#x* iswm $1) return $chr($base($mid($1, 3), 16, 10)) | elseif (#* iswm $1) return $chr($mid($1, 2)) | else return $ht2as($1)
alias -l ht2as {
  var %A quot amp apos lt gt nbsp iexcl cent pound curren yen brvbar sect uml copy ordf laquo not shy reg macr deg plusmn sup2 sup3 acute micro para middot cedil sup1 ordm raquo frac14 frac12 frac34 iquest Agrave Aacute Acirc Atilde Auml Aring AElig Ccedil Egrave Eacute Ecirc Euml Igrave Iacute Icirc Iuml ETH Ntilde Ograve Oacute Ocirc Otilde Ouml times Oslash Ugrave Uacute $&
    Ucirc Uuml Yacute THORN szlig agrave aacute acirc atilde auml aring aelig ccedil egrave eacute ecirc euml igrave iacute icirc iuml eth ntilde ograve oacute ocirc otilde ouml divide oslash ugrave uacute ucirc uuml yacute thorn yuml,%B 34 38 39 60 62 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 $&
    192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255
  return $chr($gettok(%B,$findtokcs(%A,$1,32),32))
}


If you need to modify the script to add additional symbols, be sure to test after you add them. The table works by having the same number of &symbol; as it has replacement codepoints, so you should add new items to the tail end of both 'halves', then test to make sure one of the other symbols still works correctly too.

Joined: Apr 2022
Posts: 11
T
Trinity Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Apr 2022
Posts: 11
Sorry that didn't work, but thanks for your reply

Joined: Jan 2004
Posts: 2,127
Hoopy frood
Offline
Hoopy frood
Joined: Jan 2004
Posts: 2,127
Would help if you were a wee bit more descriptive. Does 'didn't work' mean it did something wrong? Or didn't change anything? Didn't output anything? etc?

First, it would help with scripts so that any time you call an identifier that doesn't exist, that it halts the script with an error to status window instead of treating the identifier call as returning $null. That way you know that 'no output' is because of your scripting error to $no_such_identifier, and not because of the identifier not working right.

To do this, simply pull open the 'options' dropdown in the remote script editor and make sure 'identifier warning' is checked.

Assuming your existing code already works, and assuming you added these aliases as I explained, it should work to fix the line

set %radiotest.song $gettok($regml(1),7-,44)

and editing it to become

set %radiotest.song $html2ascii( $gettok($regml(1),7-,44) )

... though actually the way your code works, you do not need this to be a global variable, so you can create this as a local variable using var instead of set. But it should work fine both ways.

Joined: Apr 2022
Posts: 11
T
Trinity Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Apr 2022
Posts: 11
Sorry, been away for Easter break. Yes that works great thank you for your help..

Joined: Apr 2022
Posts: 11
T
Trinity Offline OP
Pikka bird
OP Offline
Pikka bird
T
Joined: Apr 2022
Posts: 11
Building a whole new IRC/IRCX chat network with a full Html 5 web chat.
Will Call on you again, Maroon nice work and will give details of the development.


Link Copied to Clipboard