Finally got around to updating this one ^^
Allow users to store a link on the bot
Commands:
!url add - add URL(only stores 1)
!url edit - replace URL with a new one
!url del - delete your URL
!url view - view another nick's URL
The HasURL level is mostly for easy tracking of who has added a URL
I could use a script that lists the nicks that have URLs, if anyone would like to help out with this, it would be appreciated ^^
Updates: URLs are now stored in a hash table
non-links are filtered by bot
jonesy44's regex used
/*
<:>:<:>:<:>:<:>:<:>:<:>:<:>
WEBSITE BOT<:>:<:>:<:>:<:>:
BY SK68<:>:<:>:<:>:<:>:<:>:
<:>:<:>:<:>:<:>:<:>:<:>:<:>
Syntax: !url <add | edit | del | view> <link(for add and edit) | nick(for view)>
*/
on *:START: { hmake urls 10
if ($isfile(urls.hsh)) hload urls urls.hsh
}
else
on *:TEXT:!url*:#: { if (!$2) {
.notice $nick please use !url <add/del/edit/view>
}
else {
if ($2 == add) {
if ($regex($3,/((http:\/\/?)(www\.?).*.\.*)/Si)) {
if (!$hget(urls,$nick)) {
hadd -m urls $nick $3
privmsg $chan $nick $+ 's URL set to $3
}
else {
privmsg $chan I already have a URL for you, $nick
}
}
else {
privmsg $chan that is not a valid link
}
}
elseif ($2 == edit) { if ($regex($3,/((http:\/\/?)(www\.?).*.\.*)/Si)) {
if (!$hget(urls,$nick)) {
privmsg $chan You dont have a URL to edit, $nick
}
else {
hadd -m urls $nick $3
privmsg $chan $nick $+ 's URL has been changed to $3
}
}
else {
privmsg $chan that is not a valid link
}
}
elseif ($2 == view) { if (!$hget(urls,$3)) {
privmsg $chan I dont have a URL for $+($3,$chr(44),$nick,$chr(44)) why dont you ask them to add one
}
else {
notice $nick $3 $+ 's URL is $hget(urls,$3)
}
else {
privmsg $chan that is not a valid link
}
}
elseif ($2 == del) {
if (!$hget(urls,$nick)) {
privmsg $chan You dont have a URL to delete, $nick
}
else {
hdel urls $nick
privmsg $chan $nick $+ 's URL has been deleted
}
}
else {
privmsg $chan Incorrect syntax
}
}
}
on *:EXIT: { hsave -o urls urls.hsh | hfree urls }
You're looking at the on load event, not on start. But even if you use the on load event, you will only get the script loaded once to have the hash table created. (hash tables are temporary stored in pc ram) The best approach is to just use the -m switch as mentioned. This won't fret about people not starting their mircs every time and can still have the script working as it should.
sk68, I will locate:> hadd urls $nick $3and add the -m switch:
hadd -m urls $nick $3
Some people don't even bother restarting their mirc after installing the script to have the hash table made. By using the -m switch, mirc will make sure the urls hash table has been made if it doesn't already exist. Leenoox is one living proof you see here.
hmm i tried this script
!url add http://www.xxxx.com
Lenooox's URL set to http://www.xxxx.com/
and i got this msg when i typed !url view : I dont have a URL for ,Lenooox, why dont you ask them to add one....