Coders-IRC


IRC for Coders

Google serach


image
; ============================================
; Google Search Script for mIRC - Fixed Version By Chain
; Commands: /google <search> or !google <search>
; ============================================

; --- Main Alias ---
alias google {
  if (!$1-) {
    if ($isid) return $null
    echo -ac info * Usage: /google <search terms>
    return
  }
  
  var %rawquery = $1-
  ; Replace spaces with + for Google (Google prefers + over %20)
  var %query = $replace(%rawquery,$chr(32),+)
  ; Also encode special characters
  var %query = $urlencode(%query)
  ; Fix: $urlencode might encode the + signs, so we rebuild properly
  var %query = $replacex(%rawquery,$chr(32),+,$chr(38),%26,$chr(61),%3D,$chr(43),%2B,$chr(37),%25,$chr(35),%23)
  
  var %url = https://www.google.com/search?q= $+ %query
  var %displayUrl = https://www.google.com/search?q= $+ %rawquery
  
  ; If called from channel, announce to channel
  if ($chan) {
    msg $chan 12[Google Search]  $+ %rawquery $+  2-> 4 $+ %url $+ 
  }
  else {
    echo -ac info * Google Search: %rawquery -> %url
  }
  
  ; Open in browser
  run %url
}

; --- Channel Trigger (!google) ---
on *:TEXT:!google *:#: {
  if ($0 < 2) {
    msg $chan 4[Error] Usage: !google <search terms> | Example: !google mIRC scripting tutorial
    return
  }
  google $2-
}

; --- Private Message Trigger (!google) ---
on *:TEXT:!google *:?: {
  if ($0 < 2) {
    notice $nick Usage: !google <search terms>
    return
  }
  google $2-
}

; --- Right-click menu ---
menu channel {
  Google Search: google $$input(Enter search term:,eo,Google Search for $chan)
}

; ============================================
; Alternative: Use $+() to ensure proper concatenation
; ============================================

; Even simpler fixed version:
alias google2 {
  if (!$1-) {
    echo -ac info * Usage: /google2 <search terms>
    return
  }
  
  ; Build URL manually to avoid encoding issues
  var %q = $1-
  var %url = $+(https://www.google.com/search?q=,%q)
  ; Replace spaces with +
  var %url = $replace(%url,$chr(32),+)
  
  msg $chan 12[Google Search]  $+ $1- $+  2-> 4 $+ %url $+ 
  run %url
}

Comments 0