Just a chat acronym lookup socket
Bot version:
copy/paste into ur bot's remotes
trigger is @acro acronym
<@napa182> @acro wb
<@Sick0> wb = Write back
<@Sick0> wb = Welcome back
<@Sick0> wb = Way bored
<~napa182> @acro lol
<&Sick0> lol = Laughing out loud
<~napa182> @acro sfb
<&Sick0> sfb = S*** for brains
<~napa182> @acro lollll
<&Sick0> lollll was not found in the database.
<~napa182> @acro smh
<&Sick0> smh = Shaking my head
<~napa182> @acro smdh
<&Sick0> smdh = Shaking my d*** head
also added a dialog version of it so you can pick either one or both .
Dialog version:
pic of the dialog
Rip strip or screw up this snippet anyway you see fit IDC.
/*
Bot version of the Acronym Lookup. If you want to use it as a bot trigger instead of a dialog.
*/
on $*:text:/^@acro\s(.+)$/iS:#: {
if (!%F) { inc -u4 %F
if ($sock(acro)) sockclose acro
sockopen acro www.sharpened.net 80
sockmark acro $+(/acronyms/meaning/,$remove($regml(1),$chr(32))) msg #
}
}
on *:sockopen:acro: {
sockwrite -n acro GET $gettok($sock(acro).mark,1,32) HTTP/1.1
sockwrite -n acro Host: $+($sock(acro).addr,$str($crlf,2))
}
on *:sockread:acro: {
var %acro | sockread %acro
if ($regex(%acro,/<title>(.+Found)<\/title>/)) {
$gettok($sock(acro).mark,2-,32) $regml(1)
sockclose acro
}
if ($regex(%acro,/<th.+right">(.+?)<\/th>/)) {
$gettok($sock(acro).mark,2-,32) $regml(1)
}
}
/*
Dialog version of the Acronym Lookup. If you want to use it in a dialog instead of the bot script.
*/
dialog acro {
title "Acronym"
size -1 -1 83 71
option dbu
box "Enter Acronym", 1, 2 2 79 19
edit "", 2, 3 10 54 9, autohs
button "Check", 3, 57 10 22 9, flat
box "Outcome", 4, 2 22 79 47
list 5, 3 30 54 38, size hsbar vsbar
button "Clear", 6, 57 31 22 9, flat
button "Msg", 7, 57 40 22 9, flat
button "Clip", 8, 57 49 22 9, flat
button "Close", 9, 57 58 22 9, flat cancel
}
on *:load: {
echo 12 -a You Have Just Loaded Napa182's Acronym Lookup
echo 12 -a An Irc.EzzyChat.Com Production
}
menu menubar,channel {
.Acronym Finder:dialog $iif($dialog(acro),-v,-md acro) acro
}
on *:dialog:acro:init:0:{ did -b $dname 3,6-8 }
on *:dialog:acro:edit:2:{ did -e $dname 3,6-8 }
on *:dialog:acro:sclick:*: {
if ($did == 3) {
did -r $dname 5
if ($sock(acro2)) sockclose acro2
sockopen acro2 www.sharpened.net 80
sockmark acro2 $+(/acronyms/meaning/,$remove($did(2).text,$chr(32)))
}
if ($did == 6) { did -r $dname 2,5 | did -b $dname 3,6-8 }
if ($did == 7) { $iif(!$did(5).seltext,noop $input(Please Select An Acro To Message,uhod,ERROR!),msg $active $did(5).seltext) }
if ($did == 8) { $iif(!$did(5).seltext,noop $input(Please Select An Acro To Add To Clipboard,uhdo,ERROR!),clipboard $did(5).seltext) }
}
on *:sockopen:acro2: {
sockwrite -nt $sockname GET $sock(acro2).mark HTTP/1.1
sockwrite -nt $sockname Host: $+($sock(acro2).addr,$str($crlf,2))
}
on *:sockread:acro2: {
var %acro2 | sockread %acro2
if ($regex(%acro2,/<title>(.+Found)<\/title>/)) {
didtok acro 5 32 $regml(1)
sockclose acro2
}
if ($regex(%acro2,/<th.+right">(.+?)<\/th>/)) { did -az acro 5 $regml(1) }
}
@RIcko The site seems to redirect to pc.net .. This should work for you.
on $*:text:/^@acro\s(.+)$/iS:#: {
if (!%F) { inc -u4 %F
if ($sock(acro)) sockclose acro
sockopen acro pc.net 80
sockmark acro $+(/slang/meaning/,$remove($regml(1),$chr(32))) msg #
}
}
on *:sockopen:acro: {
sockwrite -n acro GET $gettok($sock(acro).mark,1,32) HTTP/1.1
sockwrite -n acro Host: $+($sock(acro).addr,$str($crlf,2))
}
on *:sockread:acro: {
var %acro | sockread %acro
if ($regex(%acro,/<th class="right">(.+?)</th>/)) {
$gettok($sock(acro).mark,2-,32) Meaning: $regml(1)
}
}
Your regex will allow for multiple words as the search query, while the actual code only uses the first word. Edit: To clarify, it also puts all the words into the sockmark.
Your regex should probably instead be:
/^@acro\s(\S+)$/iS
Or perhaps simply remove spaces from $regml(1) when you create the sockmark.
Thanks for another handy distribution of napa socket collection. This is actually pretty useful, as it makes $replace or $reptok look bad...lol It's also convenient to seek out the meanings of acronym that we don't know or understand. Perhaps it's even better to automatically replace any acronym with the actual word itself upon typing as an option.