Google define: script usage:
[19:34] !d Onions
[19:34] Onion is a term used for many plants in the genus Allium. They are known by the common name "onion" but, used without qualifiers, it usually refers to Allium cepa.
[19:34] !d This shouldn't return any results :o
[19:34] No definitions were found for: This shouldn't return any results :o
Tinyurl command:
!tinyhelp - explains how to use the tinyurl.
!tinyurl link - shortens the link.
;Aliases not made by me.
alias -l htmlfree {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&,$chr(9))
return %x
}
alias -l urlencode {
var %a = $regsubex($$1,/([^\w\s])/Sg,$+(%,$base($asc(\t),10,16,2)))
return $replace(%a,$chr(32),$chr(43))
}
;Rest made by me:
on *:INPUT:#:{
if ($1 == !d) {
if ($sock(google)) sockclose google
set %chan $chan | set %define $2- | google.sock
}
}
on *:text:!d*:#:{
if ($1 == !d) {
if ($sock(google)) sockclose google
set %chan $chan | set %define $2- | google.sock
}
}
alias google.sock sockopen google www.google.com 80
on *:SOCKOPEN:google:{
sockwrite -n $sockname GET /search?q=define: $+ $urlencode(%define) HTTP/1.1
sockwrite -n $sockname Host: www.google.com $+ $crlf $+ $crlf
}
ON *:SOCKREAD:google: {
var %google
sockread %google
if ($regex(%google,/No definitions were found for <b>(.+?)<\/b>\./)) {
msg %chan No definitions were found for: $regsubex($regml(1),/&#(\d+);/g,$chr(\1))$regml(1)
sockclose $sockname
}
if ($regex(%google,/<li>(.+?)<br>/)) {
var %def = $regsubex($replace($regml(1),","),/&#(\d+);/g,$chr(\1))
msg %chan $remove($upper($left(%def,1)) $+ $right(%def, $calc($len(%def) - 1)),<li>,...)
sockclose $sockname
}
}
on *:TEXT:!tiny*:#: {
if ($1 == !tinyurl) || ($1 == !tiny) {
if ($sockerr) msg $chan $sockerr
if ($sock(turl)) sockclose turl
if ($2) {
/sockopen turl tinyurl.com 80
set %tiny $2
set %tchan $chan
}
else {
msg $chan You need something to make tiny!
}
}
elseif ($1 == !tinyhelp) {
msg $chan To shorten a link, type !tinyurl link.
}
}
on *:SOCKOPEN:turl:{
if ($sockerr) msg %tchan $sockerr
sockwrite -n $sockname GET /api-create.php?url= $+ $iif(http://* !iswm %tiny,http://) $+ %tiny HTTP/1.1
sockwrite -n $sockname Host: tinyurl.com $+ $crlf $+ $crlf
}
on *:SOCKREAD:turl:{
if ($sockerr) msg %tchan $sockerr
var %turl | sockread %turl
if ($regex(%turl,/http:\/\/tinyurl.com\/(.+?)/Si)) msg %tchan Here is your tinyurl link: %turl - This was $iif($calc($len(%tiny) - $len(%turl)) < $len(%turl),made longer!,shortened by $calc($len(%tiny) - $len(%turl)) characters!)
}
;Thanks to Plornt for help with the regex and pointing out why my socket failed in the first instance.
;Please tell me what needs updating/adding/changing.
tinyurl one is pretty useless seeing as you already posted the link to make it a tinyurl
maybe make it only work on Msg command i.e:
!tiny linkwhtever.co.org.uk #chan
Then it posts the link as bellow to the chan specified;
Tiny: http://tinyurl.com/4rnoe93 $nick
Would be better and more useful IMO
anyways Tinyurl asks you to not scrape their site and to use their API
from their HTML:
/////////////////////////////////////////////////////////////////////////////////
///// DON'T SCREEN-SCRAPE, PLEASE CONTACT US TO FIND OUT HOW TO USE OUR API /////
/////////////////////////////////////////////////////////////////////////////////
so you would think to honor their wishes one would use their API
unless one wants to be a prick, and disregard their wishes an scrape their main site.
a few comments above I had made an example using their API.
API link: http://tinyurl.com/api-create.php?url=
so as a test link it would look like this
http://tinyurl.com/api-create.php?url=http://www.hawkee.com/snippet/8401/
Also @ Conscious it's good to see you grasping sockets now.
Keep at it...
you're probably a dyslexicWould you please stop judging people when you know nothing about them? By calling me or them a name doesn't make you stand out as being smart but ignorant and disrespectful. This is why you get many of us annoyed as being a desperate, upsetting character that don't get along with this community.
"In this case" doesn't apply to what you have been told about "non-greed" regex. You just stand by your belief that, in this case, it works the way I want it to without putting more thought into this subject more logically.
Let's say that there is more than
as i said, in ur examples, u used more things on it, but, as i said, in this case, there is no difference, i know that i some cases u could use that, but as i said "IN THIS CASE" there is no difference, seems that u dont read my posts as ever
you're probably a dyslexic
As you mentioned, we can also place the first <\/b> for the regex to prevent regex from matching the rest, but you don't have to when you use a question mark. It serves as a convenient, useful character in regex. That is what napa and I have been trying to explain to you as "non-greedy" with the ? being utilized.
Dean, you're being a little stubborn. The matter at hand is this - Let's say that there is more than > <\/b> blah blah blahWithout the ?, it wil match them all.
Now you can either put them OUTSIDE the match to keep the $regml(1) from matching them, or you can simply insert a question mark to stop regex from reading them further.
I hope this gets through your thickheaded mentality.
u just gave a pointless example,
alias test {
if ($regex(<blockquote><b>http://tinyurl.com/1c2</b>,/<blockquote><b>(http://tinyurl.com/1c2.*)/i)) echo -a $regml(1)
}
if we already know, what we are looking for, there is no needed it
$regex(<blockquote><b>http://tinyurl.com/1c2</b>,/<blockquote><b>(.+)<\/b>/i) $regml(1)
look, its not about the grammar
since we know the link its on
http://tinyurl.com/1c2<\/b> i dont see a real reason to use (.+?) when in this case will do the same thing as (.+) cause matching, all things after , it will stop on <\/b> and, in this case, it will only match the links
Dean, look:> alias test {
if ($regex(
http://tinyurl.com/1c2,/(http://tinyurl.com/1c2.*)/i)) echo -a $regml(1)
}This will return > http://tinyurl.com/1c2Now when you add the question mark again:> alias test {
if ($regex(http://tinyurl.com/1c2,/(http://tinyurl.com/1c2.***?**)/i)) echo -a $regml(1)
}It will print out> http://tinyurl.com/1c2without the html tag.
All "e-verbal abuse" aside :P, when you use it like .+, the regex will match as one many as it can, but when you add a ? after the + , it'll stop any further match. In other words, It forces a non-greedy scan within the regex engine. Let's conduct a simple test here:
alias test {
if ($regex(Dean has made 56 posts thus far!,/(dean.+)/i)) echo -a $regml(1)
}
This will return the exact sentence "Dean has made 56 posts thus far!"
Now let's place the question mark next to the plus sign:
alias test {
if ($regex(Dean has made 56 posts thus far!,/(dean.+?)/i)) echo -a $regml(1)
}This will only return "Dean"
Please note that the question mark also has another meaning to mean optional in regex.
As for the aforementioned mIRC socket methods, the POST method is almost similar to the GET method. The only difference is that the info isn't fetched in the URL itself, but instead is sent at the end of your requests. Depending on a website, some websites only require the POST, which often happen to user log-in, and some support both GET and POST.
For one I never said I was an expert so get ur facts straight lil boy and 2 ur regex is greedy but that has nothing to do with this. It's the way you comment back to others.
You come off as an arrogant lil prick.
and lol @ me being the only asshole on this site.. thats ur opinion, and as you know ur opinion don't mean much around here...
btw you still crack me up trying ur hardest to be all E-tough
retort if you like it will only fall upon deaf ears..
I wont feed ur pathetic lil ego.
the only asshole here on this website is u napa, the guy who really think its an expert here,
first: u said that my regex way, was a greedy regex, i just showed to u, that both ways, catch the same information
by the way, seems that some ppl dont read the posts, and then comment at this
i just mentioned that in this way, u can use both methods
Dean Wrote:
if you didnt explain it, i probably wouldnt know the difference between the method POST and GET, thanks for explain mr.khaled, i posted that cause using the method POST and GET for tinyurl, you can catch the same information
lol you come off as such a lil asshole that is so full of them selves.
you crack me up tho acting all E-tough
for this site it may be so but in reality they are 2 completely different methods
if you didnt explain it, i probably wouldnt know the difference between the method POST and GET, thanks for explain mr.khaled, i posted that cause using the method POST and GET for tinyurl, you can catch the same information
lol @ the preview link
and using $sock($sockname).addr is not about the size of it. It's there to use so why not use it?
plus i never said to use it so w/e
But anyways Tinyurl asks that you do not scrape their site but w/e most people don't give a crap about what sites say... =/
if you want to fallow tinyurls rules heres a fast mock up using their API
alias turltest {
if ($sock(turl)) sockclose turl
sockopen turl tinyurl.com 80
sockmark turl $+(/api-create.php?url=,$$1)
}
on *:sockopen:turl:{
sockwrite -n turl GET $sock(turl).mark HTTP/1.1
sockwrite -n turl Host: $+($sock(turl).addr,$str($crlf,2))
}
on *:sockread:turl: {
var %turl | sockread %turl
if ($regex(%turl,/(http\S+)/)) {
echo -a $regml(1)
}
}
it is best if you are going to use a regex not to use a greedy one^^
the "greedy one" will catch only links of tinyurl and the preview, so i dont see a any difference, to use
/<blockquote><b>(.+)<\/b>/
or
<blockquote.+>(.+?)<\/b>/)
since both, will do the same thing... (except mine, will catch the preview links)
by the way, the POST method its just a preference, cause u can catch the same information by GET
as preference, the $sock(turl).addr its just the way u script, since the
tinyurl.com has 11 bytes, and $sock(turl).addr has 16, it will not "short" nothing
here is a fast mock up of a POST socket for the tinyurl
it is best if you are going to use a regex not to use a greedy one^^
alias turltest {
if ($sock(turl)) sockclose turl
sockopen turl tinyurl.com 80
sockmark turl $$1 $replace($2-,$chr(32),+)
}
on *:sockopen:turl:{
var %turl $+(&url=,$gettok($sock(turl).mark,1,32),&submit=Make+TinyURL!$&
&alias=,$iif($gettok($sock(turl).mark,2,32),$v1,"")),$&
%turl2 = sockwrite -n turl
%turl2 POST /create.php?source=indexpage HTTP/1.0
%turl2 Host: $sock(turl).addr
%turl2 Content-Type: application/x-www-form-urlencoded
%turl2 Content-Length: $len(%turl)
%turl2 $+($crlf,%turl)
}
on *:sockread:turl: {
var %turl | sockread %turl
if ($regex(%turl,/<blockquote.+>(.+?)<\/b>/)) {
echo -a $regml(1)
sockclose turl
}
}
But it would be better to use tinyurls api this is from them not me...
DON'T SCREEN-SCRAPE, PLEASE CONTACT US TO FIND OUT HOW TO USE OUR API
this
if ($sockerr) msg %tchan $sockerr
will only return a number... if you want to send something more specifically
try $sock($sockname).wsmsg
.wsmsg returns the last winsock error message match the error number
from the help file
by the way, if you used regex on it, this is a tip
this
on *:SOCKREAD:turl:{
if ($sockerr) msg %tchan $sockerr
var %turl | sockread %turl
var %a = copy('http://tinyurl.com/
var %b = ');
if (%a $+ * $+ %b iswm %turl) {
var %link = $remove(%turl,$left(%turl,6),$right(%turl,3))
if ($remove(%link,$left(%link,19)) != %alias) && (%alias) { msg %tchan This custom alias ( $+ %alias $+ ) is not available or is being used. You may try again by typing !tinyurl link alias.
msg %tchan Here is another link: %link
}
else { msg %tchan Here is the link: %link }
}
}
as Jethro_ said you could use sockmark instead
i will give you some examples using ur vars
on *:SOCKREAD:turl:{
if ($sockerr) msg %tchan $sockerr
var %turl,%y = /<blockquote><b>(.+)<\/b>/
sockread %turl
if $regex(%turl,%y) {
msg %tchan here is your link: $regml(1)
}
if (The custom alias isin %turl) {
msg %tchan The custom alias you've chosen is not available. We've created a random one for you
}
}
this will return, if the alias already exist, and then return another one
Does it? I haven't tried recently.