mIRC Home    About    Download    Register    News    Help

Print Thread
#230108 25/02/11 02:07 PM
Joined: Feb 2011
Posts: 3
I
Self-satisified door
OP Offline
Self-satisified door
I
Joined: Feb 2011
Posts: 3
I have a script that when people type a command it will send them a link to click. I was wondering if there is a way that I could enable other users to make changes to the script remotely like through mirc. Is that possible? Or is the current way (updating the .mrc file then loading it) the only way?

Id like them to be able to type a command like !addlink, then they can enter a name, then enter a new link, and have it save on the bot thats running the script.

Joined: Sep 2006
Posts: 59
R
Babel fish
Offline
Babel fish
R
Joined: Sep 2006
Posts: 59
Try this, I haven't tested it though.

To add a link use !addlink name link and to retrieve a link type !link then its name

Code:
on *:START:{
 if (!$hget(Links)) { hmake Links 10 }
 if ($exists(Links.dat)) { hload Links Links.dat }
}
on *:TEXT:*:#:{
 tokenize 32 $strip($1-)
 if ($1 == !addlink) {
  if (!$2) { msg # Not enough information to add a link <name> <link> }
  elseif (!$regex($3,([\d\w-.]+?\.(a[cdefgilmnoqrstuwz]|b[abdefghijmnorstvwyz]|c[acdfghiklmnoruvxyz]|d[ejkmnoz]|e[ceghrst]|f[ijkmnor]|g[abdefghilmnpqrstuwy]|h[kmnrtu]|i[delmnoqrst]|j[emop]|k[eghimnprwyz]|l[abcikrstuvy]|m[acdghklmnopqrstuvwxyz]|n[acefgilopruz]|om|p[aefghklmnrstwy]|qa|r[eouw]|s[abcdeghijklmnortuvyz]|t[cdfghjkmnoprtvwz]|u[augkmsyz]|v[aceginu]|w[fs]|y[etu]|z[amw]|aero|arpa|biz|com|coop|edu|info|int|gov|mil|museum|name|net|org|pro)(\b|\W(?<!&|=)(?!\.\s|\.{3}).*?))(\s|$))) {
   msg # $3 is an invalid link
  }
  elseif ($hfind(Links,$2,0,w)) { msg # Link is already in the database }
  else { hadd Links $+($2,$chr(126),$ctime,$chr(126),$nick) $3 | msg # Added link: $3 to the database }
 }
 elseif ($1 == !link) {
   if (!$2) { msg # Not enough information to retrieve a link <name> }
   elseif ($hfind(Links,$+($2,$chr(126),*),1,w)) { 
    msg # Link $+($gettok($v1,1,126),:) $hget(Links,$v1) Added by: $gettok($v1,3,126) $duration($calc($ctime - $gettok($v1,2,126))) ago.
   }
   else { msg # Link not found in database }
 }
}
on *:EXIT:{
 if ($hget(Links)) { hsave Links Links.dat }
}

Joined: Feb 2011
Posts: 3
I
Self-satisified door
OP Offline
Self-satisified door
I
Joined: Feb 2011
Posts: 3
Thanks for the response.

I put that in a .mrc and loaded it, and from a seperate computer I did !addlink name weblink and it said it "added link to the database".

So the way my script is, I basically just have a simple word command trigger like

on 1:text:!NAMEHERE:#CHANNELNAMEHERE: {

/msg $chan THIS WILL DISPLAY THE NAME THIS WILL DISPLAY THE WEB LINK
}

So with the code you posted, do you think would be possible to add a new line with the new !trigger name and new weblink?

It would also be great if there is a broken link the person could do something like !editname or !editlink and then they could post the new proper link. Like !editlink name newlinkhere

Hope im explaining that properly.

Joined: Feb 2011
Posts: 3
I
Self-satisified door
OP Offline
Self-satisified door
I
Joined: Feb 2011
Posts: 3
Where does it write to? I was looking for a file called links.dat but didnt find anything. I changed links.dat to a test name like test.mrc and it created a file called that, but it basically copied all the code and put it in there. Im not finding where its actually saving the information.

Someone types !addlink showname linkyhere <-- looking for where that info would save.

and thanks again, very cool how that works.

Joined: Sep 2006
Posts: 59
R
Babel fish
Offline
Babel fish
R
Joined: Sep 2006
Posts: 59
The information is stored in your computers memory (RAM) using something called "Hash Tables", you won't see the file "Links.dat" until mIRC has been closed as this is when it saves to the file, it may also be hidden by your version of Windows.

If you do a search for a "Hash Tables Editor" or even a viewer you will find a few that you can load into mIRC and will allow you to manually view/edit the data.

As far as a !editlink commnd is concerned, would you want just the person that added the link to be able to modify it?


Link Copied to Clipboard