mIRC Home    About    Download    Register    News    Help

Print Thread
Page 3 of 4 1 2 3 4
Re: a ZBOT script for mIRC #160020 22/09/06 10:54 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Scorpwanna, hash tables are very easy to use with multiple words if needed. As I stated in my original post, I could easily add that if he wanted it added. They are definitely faster than reading the data and the script can be much smaller.

Sukai:
Ok, you're right that I forgot about the test I was doing and didn't change it. Here's the update including the other information you asked for. If you need anything else added, just let me know.

Code:
alias -l CreateHelp {
  hmake Help 100
  if ($isfile(Help.hsh)) { hload Help Help.hsh }
}

on *:start: {
  CreateHelp
}

on *:text:*:#: {
  if ($1 != !learn && $1 != !replace && $1 != !append && $1 != !delete && $1 != $chr(63)) { return }
  if (!$2) { msg $chan Please include a keyword with the command | return }
  if ($hget(Help) == $null) { CreateHelp }
  if ($1 == !learn) {
    if ($hget(Help,$2)) { msg $chan That keyword is already used.  Please choose another, or use !replace or !append. | return }
    msg $chan Learned $3-
    hadd Help $2-
  }
  elseif ($1 == $chr(63)) {
    var %data = $hget(Help,$2-)
    if (%data == $null) { msg $chan No help available on that item. }
    else {
      msg $chan %data
    }
  }
  elseif ($1 == !replace) {
    if ($hget(Help,$2)) {
      msg $chan Replaced $hget(Help,$2).data with $2-
      hadd Help $2-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !append) {
    if ($hget(Help,$2)) {
      msg $chan Appended $3- to $hget(Help,$2).data
      hadd Help $2 $hget(Help,$2) $3-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !delete) {
    if ($hget(Help,$2)) {
      msg $chan Deleted $2 -- $hget(Help,$2).data
      hdel Help $2
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  hsave Help Help.hsh
}



USE:
!learn keyword description
!replace keyword new_description
!append keyword new_part_of_description
!delete keyword
? keyword

I didn't include !set as I'd have to redo a little of the hash table's data on the script. If you really want it, I can add it easily enough.

Scorpwanna did have a good idea of listing the keywords, though if there are too many of them, this can be a problem. If you want that feature, it is also really easy to add with a hash table.

Note that I would also recommend making these commands only available to certain people. Otherwise, some malicious person could come through and either add all kinds of fake stuff or delete everything you have.

And, feel free to edit or remove the msg lines that tell the channel what happened if you don't like them. And adding color would probably look good as well.


Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160021 22/09/06 11:22 PM
Joined: Sep 2003
Posts: 261
S
Scorpwanna Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
Quote:
Scorpwanna, hash tables are very easy to use with multiple words if needed.

Ahh, multiple words for item? Cool could you show me how that's done? I've always wanted to use hash tables but never could get it right. Yeah, hash from what i've seen is faster. Storing the information in memory is always a plus for speed. smile They should be aware that if using hash, they might need to save the hash to a file every so often incase mIRC or their computer crashes/gets shut off.
Yeah the listing, was what they wanted, that would really be a huge list over time, causing problems later on. I wouldn't use it myself, but hey it's what they wanted smile.

As far as hash tables I always had a problem with:

hadd "switch" item data

Item would always have to be 1 word. I tryed using quotes around the item area and everything and never was able to do it. I had always thought maybe the only way was to replace the spaces with . or _'s frown

How do I make it multiple? smile hadd "switch" "item with multiple words" "data"


We don't just write the scripts, we put them to the test! (ScriptBusters)
Re: a ZBOT script for mIRC #160022 23/09/06 12:13 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
LOL oiiii

now i dont know which one to use

both got its pros

x___x im so confused

Re: a ZBOT script for mIRC #160023 23/09/06 12:35 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Scorpwanna,
Yes, you need to replace $chr(32) (spaces) with another character that you're not planning on using... usually you'd pick a character like -- $chr(222) -- as you're unlikely to ever use that in your commands. You can use _ or . if you like, but it could be an issue if you want to use those in your keywords.

It may seem like replacing isn't ideal, but it's really easy and works without a problem and the user doesn't need to do anything special if you automatically use $replace rather than make them do it when using the command.

One thing to keep in mind however you do it... if you want to use more than one word, then you really need to have some kind of character that designates what is the keyword and what isn't when using the commands...

!learn this is the keyword this is the description

That won't work because there isn't any way to know what is the keyword and what is the description.

!learn this is the keyword = this is the description

That would work because you have something to denote what the keyword is. But you have to use a character that will never be in the keyword, so again, it's good to choose something like to prevent that problem.

============

Sukai,
What would you like to include besides what I've already done? Do you want multiple words? You can do them already by using _'s or something else instead of spaces, or I can add it so you can do it with spaces. Just remember that you need a character in your commands between the keyword and the description (see above).

Do you want to list the keywords? Do you want the !set command? Is there anything else?

The nice thing with hash tables, besides speed, is that they are very easy to modify how they work.


Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160024 23/09/06 01:05 AM
Joined: Sep 2003
Posts: 261
S
Scorpwanna Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
Ahh yeah, I figured replacing would be needed. Hrm, I think a good char would be 160 the invisible space. Only accessible using alt+0160 or $chr(160) and I don't know many users that would use that. Thanks Riamus2


We don't just write the scripts, we put them to the test! (ScriptBusters)
Re: a ZBOT script for mIRC #160025 23/09/06 01:10 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
maybe something that tells you who was the last person who altered or created the specific keyword?

?whoset mirc
<bot>mirc was set by Sukai

or something

its not really necessary but it would be a cool feature to have

Re: a ZBOT script for mIRC #160026 23/09/06 01:44 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, here's an update to allow inclusion of who changed the keyword last. I'm going to use !whoset instead of ?whoset to keep it matching the rest of the commands. You can always change it if you want to.

Keep in mind that this will require you to clear your current hash file and start fresh if you've already used this script because it is now storing the nicks. To do so, you'll want to type:

/hfree Help
/remove Help.hsh

Then, you can use the updated script.

Code:
alias -l CreateHelp {
  hmake Help 100
  if ($isfile(Help.hsh)) { hload Help Help.hsh }
}

on *:start: {
  CreateHelp
}

on *:text:*:#: {
  if ($1 != !learn &amp;&amp; $1 != !replace &amp;&amp; $1 != !append &amp;&amp; $1 != !delete &amp;&amp; $1 != !whoset &amp;&amp; $1 != $chr(63)) { return }
  if (!$2) { msg $chan Please include a keyword with the command | return }
  if ($hget(Help) == $null) { CreateHelp }
  if ($1 == !learn) {
    if ($hget(Help,$2)) { msg $chan That keyword is already used.  Please choose another, or use !replace or !append. | return }
    msg $chan Learned $3-
    hadd Help $2 $nick $3-
  }
  elseif ($1 == $chr(63)) {
    var %data = $gettok($hget(Help,$2),2-,32)
    if (%data == $null) { msg $chan No help available on that item. }
    else {
      msg $chan %data
    }
  }
  elseif ($1 == !replace) {
    if ($hget(Help,$2)) {
      msg $chan Replaced $gettok($hget(Help,$2),2-,32) with $2-
      hadd Help $2 $nick $3-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !append) {
    if ($hget(Help,$2)) {
      msg $chan Appended $3- to $hget(Help,$2)
      hadd Help $2 $nick $gettok($hget(Help,$2),2-,32) $3-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !delete) {
    if ($hget(Help,$2)) {
      msg $chan Deleted $2 -- $gettok($hget(Help,$2),2-,32)
      hdel Help $2
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !whoset) {
    if ($hget(Help,$2)) {
      msg $chan $gettok($hget(Help,$2),1,32) was the last person to update $2 $+ .
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  hsave Help Help.hsh
}


USE:
!learn keyword description
!replace keyword new_description
!append keyword new_part_of_description
!delete keyword
!whoset keyword
? keyword

Need anything else that I listed?

And I still would recommend limiting this to specific users. If you want to do that, let me know. The easiest way would be to add them to your user list and then set the on text to only trigger for that user level. Then we'd just pull the viewing trigger out of that on text and put it on its own. It's up to you.

*EDIT* Updated after realizing I forgot to change some things after adding !whoset support.

Last edited by Riamus2; 23/09/06 02:15 AM.

Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160027 23/09/06 01:47 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Oh, Scorpwanna, I am saving the hash file anytime it's updated... originally, it was saved inside the command's IF section and now it's saved at the very end to cut down on the number of lines. I always make sure to have hash files saved. laugh

And, I agree that $chr(160) is a really good character for replacing spaces with hash tables.


Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160028 23/09/06 02:07 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
Quote:

And I still would recommend limiting this to specific users. If you want to do that, let me know. The easiest way would be to add them to your user list and then set the on text to only trigger for that user level. Then we'd just pull the viewing trigger out of that on text and put it on its own. It's up to you.


i dont think its necessary

the channel is private only a few of us in there lol, but the scripts looks awesome

i really dont know what else can be improved to be honest

Re: a ZBOT script for mIRC #160029 23/09/06 02:12 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Ok, well let me know if you want something added or changed. Like I said, most hash table stuff is easy to modify when you know how to use them. Learning them can be confusing at first, but they are very powerful when you know them. laugh

BTW, I updated it above... I forgot to change some things after adding !whoset support. If you tried the above code, you'd have noticed the nick appearing where it shouldn't. That's fixed now.


Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160030 23/09/06 02:34 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
AAHH sorry man but i just thought of one thing

the !listall and !last feature scorpwanna had

!listall ( lists every key word in this fashion <bot> entry1, entry2, entry3, etc it does not include the definitions only the keyword )

and !last N

replace N with 10 or 20 or 100 whatever, it ll list the (example) 10 most recently added keywords

hope thatd not to difficult to alter frown

Re: a ZBOT script for mIRC #160031 23/09/06 02:52 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Code:
alias -l CreateHelp {
  hmake Help 100
  if ($isfile(Help.hsh)) { hload Help Help.hsh }
}

on *:start: {
  CreateHelp
}

on *:text:*:#: {
  if ($1 != !learn &amp;&amp; $1 != !replace &amp;&amp; $1 != !append &amp;&amp; $1 != !delete &amp;&amp; $1 != !whoset &amp;&amp; $1 != !listall &amp;&amp; $1 != !last &amp;&amp; $1 != $chr(63)) { return }
  if ($hget(Help) == $null) { CreateHelp }
  if ($1 == !listall) {
    var %list.cnt = 1
    var %line.cnt = 1
    while (%list.cnt &lt;= $hget(Help,0).item) {
      if ($len(%list [ $+ [ %line.cnt ] ]) &gt; 300) { inc %line.cnt }
      var %list. $+ %line.cnt = %list [ $+ [ %line.cnt ] ] $+ , $+ $hget(Help,%list.cnt).item
      inc %list.cnt
    }
    var %list.cnt = 1
    while (%list.cnt &lt;= %line.cnt) {
      msg $chan $right(%list [ $+ [ %line.cnt ] ],-1)
    }
    return
  }
  if (!$2) { msg $chan Please include a keyword with the command | return }
  if ($1 == !learn) {
    if ($hget(Help,$2)) { msg $chan That keyword is already used.  Please choose another, or use !replace or !append. | return }
    msg $chan Learned $3-
    hadd Help $2 $nick $3-
  }
  elseif ($1 == $chr(63)) {
    var %data = $gettok($hget(Help,$2),2-,32)
    if (%data == $null) { msg $chan No help available on that item. }
    else {
      msg $chan %data
    }
  }
  elseif ($1 == !replace) {
    if ($hget(Help,$2)) {
      msg $chan Replaced $gettok($hget(Help,$2),2-,32) with $2-
      hadd Help $2 $nick $3-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !append) {
    if ($hget(Help,$2)) {
      msg $chan Appended $3- to $hget(Help,$2)
      hadd Help $2 $nick $gettok($hget(Help,$2),2-,32) $3-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !delete) {
    if ($hget(Help,$2)) {
      msg $chan Deleted $2 -- $gettok($hget(Help,$2),2-,32)
      hdel Help $2
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !whoset) {
    if ($hget(Help,$2)) {
      msg $chan $gettok($hget(Help,$2),1,32) was the last person to update $2 $+ .
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !last) {
    if ($2 !isnum) { msg $chan You need to enter a number with that command. | return }
    var %list.cnt = $calc($hget(Help,0).item - $2)
    if (%list.cnt &lt; 1) { var %list.cnt = 1 }
    var %line.cnt = 1
    while (%list.cnt &lt;= $hget(Help,0).item) {
      if ($len(%list [ $+ [ %line.cnt ] ]) &gt; 300) { inc %line.cnt }
      var %list. $+ %line.cnt = %list [ $+ [ %line.cnt ] ] $+ , $+ $hget(Help,%list.cnt).item
      inc %list.cnt
    }
    var %list.cnt = 1
    while (%list.cnt &lt;= %line.cnt) {
      msg $chan $right(%list [ $+ [ %line.cnt ] ],-1)
      inc %list.cnt
    }
  }
  hsave Help Help.hsh
}


USE:
!learn keyword description
!replace keyword new_description
!append keyword new_part_of_description
!delete keyword
!whoset keyword
!listall
!last number
? keyword


Ok, I didn't test this, but it should work. If not, let me know. You may want to adjust the 300's for each of those commands to something higher or lower. That's the *approximate* number of characters you want per line when listing all of your commands. What will happen is that it will display about that many characters' worth of keywords, then go to the next line and keep doing more lines until it reaches the end of the keywords. Keep in mind that if you have enough keywords to send more than 5 or so lines, you'll get flooded off. This is done so you don't try displaying more characters than the network allows on a single line and also prevents you from making the variable length too long.


Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160032 23/09/06 03:56 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
unfortunately the !last n and !listall isnt working :~(

Re: a ZBOT script for mIRC #160033 23/09/06 02:52 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Sorry.. fixed the !listall. As for !last... I forgot that hash tables never put things in the right order unless you use numbers for the items. If you want a !last command, I can have it write the keywords to a file and then read in the last N keywords for you. Or, I can possibly set it up to work with /filter and put numbers in front of the item names and sort them. Up to you if you want that command.

Code:
alias -l CreateHelp {
  hmake Help 100
  if ($isfile(Help.hsh)) { hload Help Help.hsh }
}

on *:start: {
  CreateHelp
}

on *:text:*:#: {
  if ($1 != !learn &amp;&amp; $1 != !replace &amp;&amp; $1 != !append &amp;&amp; $1 != !delete &amp;&amp; $1 != !whoset &amp;&amp; $1 != !listall &amp;&amp; $1 != !last &amp;&amp; $1 != $chr(63)) { return }
  if ($hget(Help) == $null) { CreateHelp }
  if ($1 == !listall) {
    var %list.cnt = 1
    var %line.cnt = 1
    while (%list.cnt &lt;= $hget(Help,0).item) {
      if ($len(%list [ $+ [ %line.cnt ] ]) &gt; 300) { inc %line.cnt }
      var %list. $+ %line.cnt %list. [ $+ [ %line.cnt ] ] $+ , $+ $hget(Help, [ %list.cnt ] ).item
      inc %list.cnt
    }
    var %list.cnt = 1
    while (%list.cnt &lt;= %line.cnt) {
      msg $chan $right(%list. [ $+ [ %line.cnt ] ],-1)
      inc %list.cnt
    }
    return
  }
  if (!$2) { msg $chan Please include a keyword with the command | return }
  if ($1 == !learn) {
    if ($hget(Help,$2)) { msg $chan That keyword is already used.  Please choose another, or use !replace or !append. | return }
    msg $chan Learned $3-
    hadd Help $2 $nick $3-
  }
  elseif ($1 == $chr(63)) {
    var %data = $gettok($hget(Help,$2),2-,32)
    if (%data == $null) { msg $chan No help available on that item. }
    else {
      msg $chan %data
    }
  }
  elseif ($1 == !replace) {
    if ($hget(Help,$2)) {
      msg $chan Replaced $gettok($hget(Help,$2),2-,32) with $2-
      hadd Help $2 $nick $3-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !append) {
    if ($hget(Help,$2)) {
      msg $chan Appended $3- to $hget(Help,$2)
      hadd Help $2 $nick $gettok($hget(Help,$2),2-,32) $3-
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !delete) {
    if ($hget(Help,$2)) {
      msg $chan Deleted $2 -- $gettok($hget(Help,$2),2-,32)
      hdel Help $2
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  elseif ($1 == !whoset) {
    if ($hget(Help,$2)) {
      msg $chan $gettok($hget(Help,$2),1,32) was the last person to update $2 $+ .
    }
    else msg $chan No such keyword ( $+ $2 $+ ).
  }
  hsave Help Help.hsh
}


Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160034 23/09/06 06:34 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
in the !listall

say if the amount of keywords is too much to be displayed in one line ( in mirc theres a limit to how much you can type in one line)

will it continue displaying into a second line ?

if the keyword/definition database grows (into the hundredths) it may not display it all, if its limited to one line only

Last edited by Sukai; 23/09/06 06:34 PM.
Re: a ZBOT script for mIRC #160035 23/09/06 09:55 PM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Yes. Read what I wrote in the first post that included !listall. I mentioned possibly needing to change 300 to another number if it's too short of a line or too long of a line. I also mentioned that if you get too many (more than 5 lines or so), you'll probably be flooded off.


Invision Support
#Invision on irc.irchighway.net
Re: a ZBOT script for mIRC #160036 23/09/06 11:59 PM
Joined: Sep 2003
Posts: 261
S
Scorpwanna Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
Riamus2 is right, to much text all at once and you could flood off a server. If your still wanting to keep the listall command, you might want to make it a dcc chat connection to a user and then have it send the information that way. In a dcc chat you're not bound by flooding off. Though I'm not saying the listall command is a bad one, but over time that could be a large amount of text to shell out all at once.

Oh and Riamus2 smile, now I know why you love hash tables so much, they are kick ass. I've been modifying an old socketbot to act more like an infobot using hash tables for the info. Very nice results.


We don't just write the scripts, we put them to the test! (ScriptBusters)
Re: a ZBOT script for mIRC #160037 24/09/06 01:10 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
sorry Riamus2 i must of overlooked it, but well what if its made to delay between the lines ? most networks kick you off because you typed too many lines too fast (at least thats what they do over at QuakeNet)

Re: a ZBOT script for mIRC #160038 24/09/06 02:12 AM
Joined: Sep 2003
Posts: 261
S
Scorpwanna Offline
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
Hrm, you could have it dump the learned keywords to a file (using some mirc magic) then have it use the play command to play back one line at a time using the play delay. Say for example, you want it only to put 10 keywords on a line at a time.
keyword, keyword, keyword etc... until 10

make a new line

keyword, keyword, keyword etc...

would use a while loop to start the 10 count over anyway. It would write the info to the file once it reaches 10, they use play to play it back without flooding. Course that could take some coding.

Code:
var %i = 1
var %i2 = 1
var %totalhash = $hget() etc.... for the number of total entries
var %writetoline

while (%i &lt;= %totalhash) {
  %writetoline = %writetoline $hget(table,%i).item
  if (%i2 == 10) { 
    write templistall.txt %writetoline
    %writetoline = ""
    %i2 = 0
  }
  inc %i 
  inc %i2
}


then use: play $chan/$nick templistall.txt


We don't just write the scripts, we put them to the test! (ScriptBusters)
Re: a ZBOT script for mIRC #160039 24/09/06 03:10 AM
Joined: Oct 2004
Posts: 8,330
Riamus2 Online
Hoopy frood
Online
Hoopy frood
Joined: Oct 2004
Posts: 8,330
Good idea, Scorpwanna, but a hidden custom window would avoid the need for writing to a file and would allow you to /play from it.

I'll see about adding that to it maybe tomorrow. Remind me. laugh


Invision Support
#Invision on irc.irchighway.net
Page 3 of 4 1 2 3 4