My first script where i experimented with writeini and readini
Seemed to have worked out pretty well :D
Pulls insults from http://www.randominsults.net/
If you have any improvements at all please post
!insult = Insult Your self xD
!insult = Insult that person
Eg:
<~ES> !insult
<~^o0^> • ES: Save your breath... you'll need it to blow up your date. • [Times Insulted: 12]
<~ES> !insult ^o0^
<^o0^> • ^o0^: Your face reminds me of a movie star. Lassie! • [Times Insulted: 1]
on *:TEXT:!insult*:#: {
sockopen insulter www.randominsults.net 80
if ($rand(1,10) == 1) set %insultee $nick
elseif ($2) set %insultee $2-
else set %insultee $nick
set %insulterchan $chan
writeini insult.ini insults %insultee $calc($readini(insult.ini,insults,%insultee) + $chr(49))
set %timesinsul $readini(insult.ini,insults,%insultee)
}
on *:sockopen:insulter: {
sockwrite -n $sockname GET / HTTP/2.0
sockwrite -n $sockname Host: www.randominsults.net
sockwrite -n $sockname Connection: close
sockwrite -n $sockname $crlf
}
on *:sockread:insulter: {
sockread %insulterpage
if (<i> isin %insulterpage) {
set %insulterquote $nohtml(%insulterpage)
}
}
on *:sockclose:insulter: {
msg %insulterchan 10•04 %insultee $+ $chr(58) %insulterquote 10• 14[Times Insulted: %timesinsul $+ $chr(93)
}
alias nohtml {
var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x, )
return %x
}
Thanks for this fix:
on 1:TEXT:!insult*:#: {
if ($2 == $null) { notice $nick Please add a nickname after !insult | halt }
if ($2 ison #) {
sockopen insulter www.randominsults.net 80
if ($rand(1,10) == 1) set %insultee $nick
elseif ($2) set %insultee $2
elseif set %insultee $nick }
else { msg $chan $nick Do you see $2 in here anywhere? Try again! | halt }
set %insulterchan $chan
writeini insult.ini insults %insultee $calc($readini(insult.ini,insults,%insultee) + $chr(49))
set %timesinsul $readini(insult.ini,insults,%insultee)
}
I'm playing around with pulling insults from http://www.insultbox.com/
I'll let you know if I get it working.
Works pretty well, but if its going to count total insults, it should be nickname specific, so if someone types a nickname that’s not on the channel its rejects it. As it is now you can type in any random name and it will insult it. People typically call one another by shortened versions of their nick, or even by their first name, the count isn’t going to be accurate unless you make it so they have to type in the full nick.
Also line 4 has $2- at the end. The - after the $2 allows you to enter a random number after the nick, that number will then be added onto the total insults.
Replace the first section of the code with this to correct both issues:
Code:
on 1:TEXT:!insult*:#: {
if ($2 == $null) { notice $nick Please add a nickname after !insult | halt }
if ($2 ison #) {
sockopen insulter www.randominsults.net 80
if ($rand(1,10) == 1) set %insultee $nick
elseif ($2) set %insultee $2
elseif set %insultee $nick }
else { msg $chan $nick Do you see $2 in here anywhere? Try again! | halt }
set %insulterchan $chan
writeini insult.ini insults %insultee $calc($readini(insult.ini,insults,%insultee) + $chr(49))
set %timesinsul $readini(insult.ini,insults,%insultee)
}
[size=14]heres one for real foul insults ;x Just don't use it in +G rooms[/size]
on $*:text:/^@insult\s(\S+)$/iS:#: {
if (!%f && $regml(1) ison #) {
inc -u4 %f
if ($sock(ins)) sockclose ins
sockopen ins www.beleaguer.com 80
sockmark ins $+($regml(1),$chr(44)) msg #
}
}
on *:sockopen:ins: {
sockwrite -nt $sockname GET / HTTP/1.1
sockwrite -nt $sockname Host: $+($sock(ins).addr,$str($crlf,2))
}
on *:sockread:ins: {
var %ins | sockread %ins
if ($regex(%ins,/<span class="b">(.+)<\/span><br>(.+)<\/span><\/td>/)) {
$gettok($sock(ins).mark,2-,32) $regml(1) $gettok($sock(ins).mark,1,32) $regml(2)
sockclose ins
}
}