this is my first snippit that u can search youtube and google
commands are
!youtube your youtube search
!google your google search
i have tested it and it works
***********************************************
created by toclafane1
***********************************************
on *:TEXT:*:#:{
if ($1 == !youtube) msg $chan 3Your Youtube Search: $$2- $+ : http://www.youtube.com/results?search_query= $+ $$2- $+ &search_type=&aq=f
if ($1 == !google) msg $chan 3your google search: $+(http://www.google.com/search?q=,$replace($$2-,$chr(32),+))
}
Why check for the regml match, just use $regml(1) :)? $+(http://,$iif($regml(1) != google,youtube,google),.com) => $+(http://,$regml(1),.com). But wouldn't $regml(1) match the (?i)? Also you need a /i switch, to match an incasesensitive match.
Dani, neither your example will respond. You changed the variable name to %floodnick, which doesn't match the first conditional check for it. This is efficiently done with a regex though:
on $*:TEXT:/^!(?i)(youtube|google)( |$)/S:#:{
if (%floodnick [ $+ [ $nick ] ]) halt | set -u3 %Floodnick [ $+ [ $nick ] ] . | var %s $replace($$2-,$chr(32),+)
if !$strip($2) { notice $nick $+(http://,$iif($regml(1) != google,youtube,google),.com) }
elseif ($regml(1) == google) msg # 3your google search: $+(http://www.google.com/search?q=,%s)
else msg # 3Your Youtube Search: $2- $+ : http://www.youtube.com/results?search_query= $+ %s $+ &search_type=&aq=f
}
You don't really need the -e switch because upon existing, the timed var will be unset anyway. And you only need one check for $2 and $replace($2,$chr(32),+) with a variable to apply to all the routines.
It's far from perfect, but keep up the good work :) I'll give you a 7.
@Bielie:
That won't work. You gotta use
on *:TEXT:*:#:{
if (%flood [ $+ [ $nick ] ]) halt
set -eu3 %Floodnick [ $+ [ $nick ] ] .
if ($1 == !youtube) {
if (!$2) notice $nick http://youtube.com
else msg $chan 3Your Youtube Search: $$2- $+ : http://www.youtube.com/results?search_query= $+ $$2- $+ &search_type=&aq=f
}
if ($1 == !Google) {
if (!$2) notice $nick http://google.com
else msg $chan 3your google search: $+(http://www.google.com/search?q=,$replace($$2-,$chr(32),+))
}
}
This code is a bit safer and always responds
on *:TEXT:*:#:{
if (%flood [ $+ [ $nick ] ]) { return }
set -eu3 %flood [ $+ [ $nick ] ] $true
if ($1 == !youtube) && ($2 != $null) { msg $chan 3Your Youtube Search: $$2- $+ : http://www.youtube.com/results?search_query= $+ $$2- $+ &search_type=&aq=f
else { notice $nick http://youtube.com | return }
}
if ($1 == !google) && ($2 != $null) { msg $chan 3your google search: $+(http://www.google.com/search?q=,$replace($$2-,$chr(32),+))
else { notice $nick http://google.com | return }
}
}
This is how I would do it.
on $*:TEXT:/^!(youtube|google)(.+?)/Si:#: msg $chan $+(3Your $iif($regml(1) == youtube,Youtube,Google) Search: $$2-,: $iif($regml(1) == youtube,http://www.youtube.com/results?search_query=,http://www.google.com/search?q=),$replace($regsubex($2-,/([^\w\s])/Sg,$+(%,$base($asc(\t),10,16,2))),$chr(32),$chr(43)))
No offence, but it isnt sorted Callum.
It definatly still needs the url encode plus the youtube one doesnt even encode the space.
Not trying to bog you down or anything but I just wanted to say....
Search Hawkee for somthing like a URL encode alias or just url encode and then pop that in the script and use the alias around your search parameters (ie $$2-)
toclafane1, Check this out http://www.hawkee.com/snippet/8499/ :) Might help