URL Bot v3

By sk68 on Jun 11, 2009

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 }

Comments

Sign in to comment.
Jethro   -  Feb 07, 2010

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.

 Respond  
sk68   -  Feb 07, 2010

thats weird, on my mIRC start events trigger when the script is loaded, or I thought they did :S

ok, fixed

 Respond  
Jethro   -  Feb 07, 2010

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.

 Respond  
sk68   -  Feb 07, 2010

ok, I swear I tested all of these before I posted them, wtf is going on? T-T

 Respond  
Lenooox   -  Jan 30, 2010

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....

 Respond  
sk68   -  Aug 05, 2009

you obviously didnt see my store script >.<

 Respond  
Kirbeh_Pr0nz   -  Aug 05, 2009

;O Bracket Heaven

 Respond  
sk68   -  Jul 26, 2009

well, that depends...what?

 Respond  
Xaric   -  Jul 25, 2009

Can you add success string entries for the url?

 Respond  
sk68   -  Jul 22, 2009

uh...yea...I knew that >.>

 Respond  
Jonesy44   -  Jul 22, 2009

Replace "str" with $3 :)

 Respond  
sk68   -  Jul 22, 2009

UPDATE

 Respond  
Jonesy44   -  Jun 16, 2009

I'd use regex to match URL's, something like,

$regex(str,/((http:\/\/?)(www\.?).*.\.*)/Si)

$regml(1) - URL string

 Respond  
PATX   -  Jun 14, 2009

sk86 dis is like my script. ppl said da same thing use ini use hash. i personally like vars, tho hash is probaly ur best bet here. tho u went w. ini oh well.

 Respond  
sk68   -  Jun 12, 2009

oops, I guess I didnt think about the number of vars and invalid inputs, Im not really good with ini files but Ill read up on it and get to work ASAP :D

 Respond  
Jethro   -  Jun 11, 2009

I'd opt for hash tables if I had a chance for similar script.

 Respond  
Aucun50   -  Jun 11, 2009

Also this could use a lot of vars, maybe go with a ini file.

 Respond  
Jethro   -  Jun 11, 2009

What if the add is not even a link or url? You should use a regex to match only URLs.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.