I made this a while ago, changed it to a dialog, but I've changed it back to a trigger:
To use type: !rjoke
Example: > [2:21pm] <~Stewie> !rjoke
[2:21pm] <&thunderbolt> [Random Joke] A rather confident man walks into a bar and takes a seat next to a very attractive woman. He gives her a quick glance, then casually looks at his watch for a moment.The woman notices this and asks, "Is your date running late?""No," he replies, "I just bought this state-of-the-art watch and I was just testing it."The intrigued woman says, "A state-of-the-art watch? What's so special
[2:21pm] <&thunderbolt> about it?""It uses alpha waves to telepathically talk to me," he explains."What's it telling you now?" she asked."Well, it says you're not wearing any panties." he said.The woman giggles and replies, "Well it must be broken then because I am wearing panties!"The man explains, "Damn thing must be an hour fast."
[2:21pm] <~Stewie> !rjoke
[2:21pm] thunderbolt This command can only be used once ever 6 seconds.
alias -l NoHTML {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
on $*:text:/^!rjoke( |$)/iS:#:{
if ($($+(%,rjoke,$remove(#,$chr(35))),5) == $null) {
set -u6 $+(%,rjoke,$remove(#,$chr(35))) flood
rjoke msg #
}
else { .notice $nick This command can only be used once every 6 seconds. }
}
alias -l rjoke {
if ($sock(rjoke)) sockclose rjoke
sockopen rjoke www.randomfunnyjokes.com 80
sockmark rjoke $1-2
}
on *:sockopen:rjoke:{
sockwrite -nt rjoke GET / HTTP/1.0
sockwrite -nt rjoke Host: $+($sock(rjoke).addr,$str($crlf,2))
}
on *:sockread:rjoke:{
var %rjoke | sockread %rjoke
if ($regex(%rjoke,/<font face="Verdana" size="2">(.+?)</font>/i)) {
tokenize 32 $sock(rjoke).mark
$gettok($sock(rjoke).mark,1-2,32) [Random Joke] $NoHTML($regml(1))
}
}
I'd like to suggest this website below that offers one-line joke, which I believe it's ideal. Keep the joke short but funny. I don't reckon people like to read a bunch of words in paragraph before they can grasp the meaning of and laugh at it.
http://www.jokesclean.com/OneLiner/Random/
P.S. This goes the same when you make a presentation in the public. You don't want people who listen to you to get bored in the middle of your speech as you drag on for too long. Just food for thought.
toclafane1, aren't you suppose to send a random joke to the channel? Now it's dialog based and for yourself to see only? Remember that some people are using older mIRC versions so the auto message split won't work for them. I'm pretty sure there are shorter random jokes out there you can take advantage of.
-edit- I see users may have to copy and paste the whole thing to the channel...
ummmm, there is msg split on mIRC already, you should make sure that's enabled, my version does work, i would never of posted it if i never seen it working. > [2:10pm] <~toclafane|away> !joke
[2:11pm] <&thunderbolt> An Irish man walks into a bar. The bartender looks at him and notices he has a steering wheel stuck down the front of his pants. "Hey," he says, "What's with the steering wheel down your pants?" "Ach," says the Irish man, "it's drivin' me nuts!" my version.
perhaps you should make it split the text in 2 if the input is too long
<- :NICKNAME@HOST PRIVMSG #carebox :!joke
-> port80a.se.quakenet.org PRIVMSG #carebox :After successfully passing the bar exam, a man opened his own law office. He was sitting idle at his desk when his secretary announced that a Mr. Jones had arrived to see him. "Show him right in!" our lawyer replied.As Mr. Jones was being ushered in, our lawyer had an idea. He quickly picked up the phone and shouted into it " ...and you tell them that we won't accept less then fifty thousand dollars, and don't even call me until you agree to that amount!" Slamming the phone down he stood up and greeted Mr. Jones; "Good Morning, Mr. Jones, what can I do for you?""I'm from the phone company," Mr. Jones replied, "I'm here to connect your phone."
<- :port80a.se.quakenet.org 417 NICKNAME :Input line was too long
edit: this is Jethro's version of the code. toclafne1's code didnt work at all for me.
edit2: Some texts even makes me excess flood
Wims, I tend to offer my so-called advices by way of demonstration. Some people may not buy 'em much, but I like the idea of showing what you mean by what you say. (people who use English as a second language may not process the meaning out of you easily) As the saying goes, "a picture is worth a thousand words." I really don't give a flying F I make "enemies" as a result, unless you give out something sensible for me to agree upon. I'm not here to prove people wrong and be argumentative. I do, from time to time, admit my mistakes. Again, you have your own opinion toward this matter, and I have mine. Thanks for your constructive comment.
err ? the broswer has nothing to do with the problem, a socket is a socket and you are responsible for what you read and what you write to it: what you get from the socket is the same as what the browser get and what OP's script get, he was using $nohtml for a reason :p.
I also think that rewritting every code that are posted on this website is not necessary, giving advice is better than giving a whole new code and saying "use it", users can't learn that way. You also cannot do that on large script, which is why giving advice on the methods used (sockmark for example) is preferable imo :)
If that's the case, this edit should do the trick:
on $*:text:/^!joke$/iS:*:{
if (!$($+(%,fp,.,$site,.,#,.,$network),2)) {
inc -u3 $+(%,fp,.,$site,.,#,.,$network)
var %j = joke. $+ $r(1,9999)
sockopen %j www.randomfunnyjokes.com 80
sockmark %j .msg $iif(#,#,$nick)
halt
}
.notice $nick please wait at least 3 seconds before using $1 again!
.ignore -cpu3 $nick 2
}
on *:sockopen:joke.*:{
if ($sockerr) {
$sock($sockname).mark Error's Occurred!
halt
}
sockwrite -nt $sockname GET / HTTP/1.0
sockwrite -nt $sockname Connection: close
sockwrite -nt $sockname Host: $+($sock($sockname).addr,$str($crlf,2))
}
on *:sockread:joke.*:{
if ($sockerr) {
$sock($sockname).mark Error's Occurred!
halt
}
var %joke
sockread %joke
if (<br><br> isin %joke) {
$sock($sockname).mark $regsubex(%joke,/<[^>]*>|&.*/g,)
}
}
when i tryed your version > [11:44pm] <~toclafane> !joke
[11:44pm] <&thunderbolt>
Apologies, I was distracted. It did work. lol
Well, you really didn't need regex nor the alias. Here is my take on yours:
on $*:text:/^!joke$/iS:*:{
if (!$($+(%,fp,.,$site,.,#,.,$network),2)) {
inc -u3 $+(%,fp,.,$site,.,#,.,$network)
var %j = joke. $+ $r(1,9999)
sockopen %j www.randomfunnyjokes.com 80
sockmark %j .msg $iif(#,#,$nick)
halt
}
.notice $nick please wait at least 3 seconds before using $1 again!
.ignore -cpu3 $nick 2
}
on *:sockopen:joke.*:{
if ($sockerr) { $sock($sockname).mark Connection Error's Occurred! | halt }
sockwrite -nt $sockname GET / HTTP/1.1
sockwrite -nt $sockname Connection: close
sockwrite -nt $sockname Host: $+($sock($sockname).addr,$str($crlf,2))
}
on *:sockread:joke.*:{
if ($sockerr) { $sock($sockname).mark Connection Error's Occurred! | halt }
var %joke | sockread %joke
if (<br><br> isin %joke) { $sock($sockname).mark $remove(%joke,$v1) }
}
I've taken the liberty of adding the trigger flood control and sockerr checks, making the script more secure if someone malicious wants to tamper with you, or the socket runs into errors.
You should learn about the use of sockmark so you don't have to rely on the global variable and then get it unset.
I've made it capable of listening to both channel and pm.
yes i tested it, i wouldn't of posted it if never worked > [10:47pm] <~toclafane> !joke
[10:47pm] <&thunderbolt> A man walks into a drug store with his 8-year-old son. They happen to walk by the condom display, and the boy asks, "What are these, Dad?"The man matter-of-factly replies, "Those are called condoms, son. Men use them to have safe sex." "Oh I see," replied the boy. "I've heard of that in health class at school."He looks over the display and picks up a package of three and asks, "Why are
[10:47pm] <&thunderbolt> there three in this package."The dad replies, "Those are for high-school boys. One for Friday, one for Saturday, and one for Sunday." "Cool!" says the boy. He notices a pack of six and asks "Then who are these for?""Those are for college men," the dad answers, "Two for Friday, two for Saturday, and two for Sunday.""WOW!" exclaimed the boy. "Then who uses these?" he asks, picking up a
[10:47pm] <&thunderbolt> 12-pack.With a sigh, the dad replied, "Those are for married men. One for January, one for February, one for March..."