mIRC Homepage
Posted By: Sukai a ZBOT script for mIRC - 22/09/06 02:21 AM
im not sure if you guys are familiar with zbot (some irc networks have this script(?) in their chanservs

if you dont know what im talking about, basically what it does is

you type this:

!learn definition thedefinitiongoeshere

example:

!learn mIRC the site for mIRC is www.mirc.com

once thats done it saves it (somewhere) so whenever one of your channel's user do

? mIRC

the following happens

<bot> the site for mIRC is www.mirc.com

!learn is the command

mIRC is the keyword

"the site for mIRC is www.mirc.com" is the definition

..ok my question is ..i know its possible to make a script to do this in mIRC (instead of the networks chanserv) is there something like this out there ? (for download) if not, would it be too difficult to script? (i have very little scripting knowledge, i just started)

can someone help me out here? point me to the right direction?

thanks in advance
Posted By: FNar Re: a ZBOT script for mIRC - 22/09/06 02:53 AM
Quote:
can someone help me out here? point me to the right direction?
There are a few mIRC quote databases you might be able to adapt. (if you use Google, MIRC database and mIRC database aren't the same thing in the returns you get - MIRC is a medical database.)
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 03:22 AM
i guess i could try that smirk

dont know if i can do it tho
Posted By: Firestarter Re: a ZBOT script for mIRC - 22/09/06 03:34 AM
A bit of googling explains what ZBOT is, Its an info bot module for Anope irc services. So I would search for an info bot script for mIRC. Must be thousands out there somewhere.
Good luck
Fire
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 04:24 AM
this is hard smirk

im reading up on mirc's help file ..to see if any variables/comands etc can help me out
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 07:25 AM
So in other words, it's an infobot. And yes it's possible, i've made something like that in the past. Virtually anything is possible when it comes to mIRC. smile

Simply message it: this is that, then have it write the information to a file something like
we'll assume $1- is "this entry is that info"
Code:
on *:text:*:#: {
  if ($findtok($1-,is,1,32)) {
    var %text = $1-
    %text = $reptok(%text,is,=&gt;,1,32)
    write learnt.txt %text
    ;write this to a file: this entry =&gt; that info
    ;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
    if ($read(learnt.txt,w,%text)) { msg $chan ok }
    else { msg $chan I pooped my pants }
  }
}

the above method for finding is is a bit old, but it's fast and works.

Trigger it by using an on text event: or if your socketing, which you should be just having it match the first information on the left side of the =>.

Say in your file learnt.txt you have these lines.
this entry => that info
worms => live in dirt

Search the file for a beginning line that matches the string "this entry*".
If found return that line.

Assume you say in the room "this entry".
Code:
on *:text:*:#: {
  var %text = $read(learnt.txt, w,  $1- $+ *)
 ;if "this entry*" is found at the beginning of a line,
  if (%text) {
    var %split=&gt; = $calc($findtok(%text,=&gt;,1,32) +1)
    msg $chan hmm, $gettok(%text,%split=&gt; $+ -,32)
  }
}


Here's how the conversation would go:
<you> this entry
<bot> hmm, that info

Hope this info helps get you started. I didn't test any of this so if it doesn't work right, play with it some.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 01:31 PM
i used your code snippet with a few changes

it records the info just fine

but it doesnt respond back when i type the keyword, using your example

if i type "this entry"

it doesnt reply at all
Posted By: Riamus2 Re: a ZBOT script for mIRC - 22/09/06 01:36 PM
The fastest method would probably be hash tables:

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

on *:start: {
  CreateHelp
}

on *:text:*:#: {
  if ($1 == !learn) {
    if ($hget(Help) == $null) { CreateHelp }
    hadd Help $2-
    hsave Help Help.hsh
  }
  elseif ($1 == $chr(63)) {
    var %data = $hget(Help,test)
    if (%data == $null) { msg $chan No help available on that item. }
    else {
      msg $chan %data
    }
  }
}


Ok, this is not tested, but should work fine. If not, let me know and I'll see what is going on with it. It will be very fast and easy to use. As you asked, here are the uses of it:

!learn keyword description

? keyword

If you want it to respond to !help or something instead of ?, then replace $chr(63) in the script with !help or whatever you're going to use. I used ? since that was what you said the bot used.

Keep in mind that I did this for one-word keywords because that's what you were giving as an example. If you want multiple-word keywords, let me know and I can easily edit it.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 01:49 PM
the !learn keyword definitionhere

isnt working :~(

EDITED: ok nevermind, its making the keyword/definition ..it seems the problem is in the ? keyword portion of the code

i get the "No help available on that item." message everytime
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 03:54 PM
Heh, Riamus2 you are obsessed with hash tables smile. There's only 1 drawback to the hash table item definition thing. the item can only be 1 word. frown

Sukai
When I gave you the examples I separated them, all in all they should be under the same on text event:

Code:
on *:text:*:#: {
  var %text = $read(learnt.txt, w,  $1- $+ *)
  ;if "this entry*" is found at the beginning of a line,
  if (%text) {
    var %split=&gt; = $calc($findtok(%text,=&gt;,1,32) +1)
    msg $chan hmm, $gettok(%text,%split=&gt; $+ -,32)
  }
  if ($findtok($1-,is,1,32)) {
    var %text = $1-
    %text = $reptok(%text,is,=&gt;,1,32)
    write learnt.txt %text
    ;write this to a file: this entry =&gt; that info
    ;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
    if ($read(learnt.txt,w,%text)) { msg $chan ok }
    else { msg $chan I pooped my pants }
  }
}


If 2 of the same events exist inside of a remote script file, the first one is evaluated and the second is ignored.

K I just tested this myself and it works:

[11:03:32] <brandon> this is a test
[11:03:32] <@Scorpwanna> ok
[11:03:47] <brandon> this
[11:03:47] <@Scorpwanna> hmm, a test
[11:04:06] <brandon> this script is awesome
[11:04:06] <@Scorpwanna> ok
[11:04:09] <brandon> this script
[11:04:09] <@Scorpwanna> hmm, awesome
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 04:13 PM
Code:
on *:text:*:#: {
  if ($1 == ?) {
    var %text = $2- =&gt;
    %text = $read(learnt.txt, w, %text $+ *)
    ;if "this entry*" is found at the beginning of a line,
    if (%text) {
      var %split=&gt; = $calc($findtok(%text,=&gt;,1,32) +1)
      msg $chan hmm, $gettok(%text,%split=&gt; $+ -,32)
    }
  }
  if ($1 == !learn) {
    if ($findtok($2-,is,1,32)) {
      var %text = $2-
      %text = $reptok(%text,is,=&gt;,1,32)
      write learnt.txt %text
      ;write this to a file: this entry =&gt; that info
      ;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
      if ($read(learnt.txt,w,%text)) { msg $chan ok }
      else { msg $chan I pooped my pants }
    }
  }
}


[11:11:23] <brandon> !learn this bathroom is full
[11:11:23] <@Scorpwanna> ok
[11:11:28] <brandon> ? this bathroom
[11:11:28] <@Scorpwanna> hmm, full
[11:12:14] <brandon> !learn whoa whoa whoa whoa Lois this is not my drinking glass!
[11:12:14] <@Scorpwanna> ok
[11:12:27] <brandon> ? whoa whoa whoa whoa Lois this
[11:12:27] <@Scorpwanna> hmm, not my drinking glass!

Course this is just a sample. It will have flaws, but that's for you to figure out smile.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 04:22 PM
both versions work great

but instead of having the second event ignored cant it just be appended to the first event ( add a comma then have it follow afterwards) OR show both in two different sentences?

EDITED: i also found out what was wrong with the hash table version of this script

instead of having var %data = $hget(Help,test)

it should of been var %data = $hget(help,$2-)

that worked
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 04:25 PM
Hi, I just edited the post to take out a var infront of a line. So check out what I just changed. Test it for your self. Yes append. I showed you an appended one up a few posts. smile
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 04:31 PM
i entered several entries of "cool"

it doesnt show them all or append, only shows the first "cool" entry made
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 04:31 PM
Hrm, you've just inspired me to add something like this to a socketbot i have. smile Thanks. Yep, first come first serve. To append data, i'd say you'd need to have it take what's there already, and (if you use mine) addon to the nth line of text. Infobot use to have this "is also" trigger which if said would append the data to the already existing data.

Like:

<nick> cow tipping is fun
<bot> ok
<nick> cow tipping is also a way to be mean to cows
<bot> ok
<nick> cow tipping
<bot> hmm, cow tipping is fun or a way to be mean to cows
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 04:38 PM
i see

hrmmz, i have no idea how to approach this to be honest

EDITED: the thing is with the is also trigger

people wont know if the keyword already has a definition so if add a new defintion to that keyword ..they would never notice it unless later on they did a ? keyword
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 05:03 PM
I see, might be best to just have it go right ahead and append, and if it does update itself, have it message back to the channel. "Updated entry for blah." Question is, would you want it to overwrite the data completely, or add it to the data that already exists? I'll work with it smile. Not gunna leave you in the woods by yourself.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 05:12 PM
thank you laugh

to answer your question, why not both? ...something else came to mind, like ...what if we wanted to replace the whole entry itself? !replace keyword definitionhereblahblah

i think that would also be a good feature (im thinking ZBOT for anope irc servers)

if i remember correctly it was in this format

!<command> <keyword> <entrydefintion>

the commands for it was !append (to add something to an already existing entry), !replace (completely replaces the entry), !delete (deletes the entry), !learn (creates an entry), !set (view who edited or created the entry)

that would be awesome but a bit time consuming i would think

anyway thanks for taking the time to help me really appreciate it
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 05:26 PM
Sounds like great fun, I'll do it! heh

Edited: Try this out.
Code:
on *:text:*:#: {
  if ($1 == ?) {
    var %text = $2- =&gt;
    %text = $read(learnt.txt, w, %text $+ *)
    ;if "this entry*" is found at the beginning of a line,
    if (%text) {
      var %term = $reptok(%text,=&gt;,is,1,32)
      msg $chan hmm, %term
    }
  }
  if ($1 == !append) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=&gt;,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        var %append = $gettok(%text,$calc(%islocation +1) $+ -,32)
        write -l $+ $readn learnt.txt %findentry or %append
        msg $chan Appended data.
      }
    }
  }
  if ($1 == !replace) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=&gt;,1,32)
      write -l $+ $readn learnt.txt %text
      msg $chan Replaced entry.
    }
  }
  if ($1 == !learn) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=&gt;,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        msg $chan Already have something for that.
      }
      else {
        write learnt.txt %text
        ;write this to a file: this entry =&gt; that info
        ;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
        if ($read(learnt.txt,w,%text)) { msg $chan ok }
        else { msg $chan I pooped my pants }
      }
    }
  }
}

[12:42:53] <Sporc> !learn variable is a percent
[12:42:53] <@Scorpwanna> ok
[12:43:13] <Sporc> !learn variable is yo momma
[12:43:13] <@Scorpwanna> Already have something for that.
[12:43:25] <Sporc> !replace variable is yo momma
[12:43:25] <@Scorpwanna> Replaced entry.
[12:43:50] <Sporc> !append variable is bringing down the house
[12:43:50] <@Scorpwanna> Appended data.
[12:43:57] <Sporc> ? variable
[12:43:57] <@Scorpwanna> hmm, variable is yo momma or bringing down the house
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 05:43 PM
LOL

your too nice laugh

im reading over the /help file in mirc to better understand some of the stuff used in here
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 05:47 PM
shocked that seems to work pretty well
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 05:48 PM
I was once where you are, and never recieved the help I could of then. So I feel obligated to help you out smile.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 05:52 PM
haha your awesome

and whoever didnt help you sucks :~(

thanks you really helped me out but i wondering if its not too much trouble (so i can better understand what you did here ...i understand some of it) could you explain what each line does some what ?
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 06:00 PM
Sure I'll give it a shot in my next post. But right now i'm making the !delete function smile.
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 06:06 PM
Code:
on *:text:*:#: {
  if ($1 == ?) {
    var %text = $2- =&gt;
    %text = $read(learnt.txt, w, %text $+ *)
    ;if "this entry*" is found at the beginning of a line,
    if (%text) {
      var %term = $reptok(%text,=&gt;,is,1,32)
      msg $chan hmm, %term
    }
  }
  if ($1 == !append) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=&gt;,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        var %append = $gettok(%text,$calc(%islocation +1) $+ -,32)
        write -l $+ $readn learnt.txt %findentry or %append
        msg $chan Appended data.
      }
    }
  }
  if ($1 == !replace) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=&gt;,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        var %replace = $gettok(%text,$calc(%islocation +1) $+ -,32)
        write -l $+ $readn learnt.txt %newentry %replace
        msg $chan Replaced entry.
      }
    }
  }
  if ($1 == !learn) {
    var %islocation = $findtok($2-,is,1,32)
    if (%islocation) {
      var %text = $2-
      %text = $reptok(%text,is,=&gt;,1,32)
      var %newentry = $gettok(%text,1- $+ %islocation,32)
      var %findentry = $read(learnt.txt,w,%newentry $+ *)
      var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
      if (%newentry == %foundentry) {
        msg $chan Already have something for that.
      }
      else {
        write learnt.txt %text
        ;write this to a file: this entry =&gt; that info
        ;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
        if ($read(learnt.txt,w,%text)) { msg $chan ok }
        else { msg $chan I pooped my pants }
      }
    }
  }
  if ($1 == !delete) {
    var %text = $2- =&gt;
    %text = $read(learnt.txt, w, %text $+ *)
    if (%text) {
      write -dl $+ $readn learnt.txt
      msg $chan Deleted entry.
    }
    else { msg $chan Info does not exist to delete }
  }
}

[13:04:12] <Sporc> !delete variable
[13:04:12] <@Scorpwanna> Deleted entry.
[13:04:19] <Sporc> !delete variable
[13:04:19] <@Scorpwanna> Info does not exist to delete
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 06:07 PM
Ok, this may take me a while so I'm going to go ahead and post this here edit the post to then describe what each line does:

on *:text:*:#: {
on "anylevel" "text" "anytext" "anychannel"

if ($1 == ?) {
if the first word is a question mark

var %text = $2- =>
create the temporary variable %text which equals the second word to the end and add to it a =>

%text = $read(learnt.txt, w, %text $+ *)
reads learnt.txt for a line beginning with %text (plus our =>) and anything after it. using a => makes sure it finds the right line info because only 1 line will be exactly what it's looking for.

;if "this entry*" is found at the beginning of a line,
if (%text) {
if %text exists/is found/is not empty but is actually something

var %term = $reptok(%text,=>,is,1,32)
create the temporary variable %term and replace the first => found with the word "is". Since we added it to make sure it searched and found exactly what we wanted, we don't need it anymore so we change it back to "is". The tokens as they are called in this example separated by the character 32 (which is a space) so every word is a token because it's separated by a space

msg $chan hmm, %term
message to the active channel hmm, %term information it found
}
}
if ($1 == !append) {
if the first word is !append

var %islocation = $findtok($2-,is,1,32)
create temporary variable %islocation to find where "is" is we use $findtok to search the "second word to the end" for the word "is" only looking for the "first" one and separate the information using character 32/a space
When found returns it's position in the text.

if (%islocation) {
if %islocation is found, not empty etc...

var %text = $2-
create temporary varilable %text from the second word until the end of the sentance

%text = $reptok(%text,is,=>,1,32)
we update the %text variable into: replace "in the text" the first "is" with "=>" separating the text by a space character 32
that way we transform the %text with is, into the %text with =>

var %newentry = $gettok(%text,1- $+ %islocation,32)
create temporary variable %newentry, get the tokens (words in this case) in %text, from first word until where %islocation/"is" was found. Returns the text entry only until where is was found. "the information =>" (remembering we replaced is with => instead of "the information => found"

var %findentry = $read(learnt.txt,w,%newentry $+ *)
create temporary variable %findentry which reads learnt.txt searching for a line beginning with the data %newentry returns
So it searches for a line beginning with "the information =>" and returns "the information => found"

var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
create temporary variable %foundentry get the tokens (words in this case) from the first word until where %islocation/"is" was found. Returns the text entry only until where is was found. "the information =>".

You may be saying that this looks familiar to %newentry, only difference is, one is reading text from the text you supply, one is reading from a file.

if (%newentry == %foundentry) {
if %newentry is equal to %foundentry (if "the information =>" is equal to "the information =>" use the functions within the { }'s

var %append = $gettok(%text,$calc(%islocation +1) $+ -,32)
create temporary variable %append, get the tokens (words in this case) starting from %islocation plus 1 (making it skip showing the => in the results all the way to the end of the new information. Separated by a space/character 32. so instead of returning "=> the new info" it returns "the new info"

write -l $+ $readn learnt.txt %findentry or %append
write "on line $readn" (the line read in a text file during this operation) to the file "learnt.txt" "%findentry" (which returned "the information => found") and add to the end of it "or %append" (which returned "the new info")
the updated line written is "the information => found or the new info"

msg $chan Appended data.
messages the active channel "Appended data."

}
}
}
if ($1 == !replace) {
if the first word is !replace

var %islocation = $findtok($2-,is,1,32)
again we search for the first is location in the text starting from the second word until the end

if (%islocation) {
if %islocation is found, not empty etc...

var %text = $2-
create temporary varilable %text from the second word until the end of the sentance

%text = $reptok(%text,is,=>,1,32)
we update the %text variable into: replace "in the text" the first "is" with "=>" separating the text by a space character 32
that way we transform the %text with is, into the %text with =>. Which returns "the information => the new info"

var %newentry = $gettok(%text,1- $+ %islocation,32)
var %findentry = $read(learnt.txt,w,%newentry $+ *)
var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
if (%newentry == %foundentry) {
var %replace = $gettok(%text,$calc(%islocation +1) $+ -,32)
does the same as the above does for append but!

write -l $+ $readn learnt.txt %newentry %replace
instead of appending, it overwrites the entire line with the new data, without saving the old with it.

msg $chan Replaced entry.
messages the active channel Replaced entry.

}
}
}
if ($1 == !learn) {
if the first word is !learn

var %islocation = $findtok($2-,is,1,32)
again find the location of is

if (%islocation) {
yada yada yada

var %text = $2-
create temp variable %text using the second word until the end

%text = $reptok(%text,is,=>,1,32)
var %newentry = $gettok(%text,1- $+ %islocation,32)
var %findentry = $read(learnt.txt,w,%newentry $+ *)
var %foundentry = $gettok(%findentry,1- $+ %islocation,32)
if (%newentry == %foundentry) {
same as above but! if it's found it tells you it already exists rather than doing anything about it.

msg $chan Already have something for that.
messages active channel "Already have something for that.
}
else {
if the %newentry isn't %foundentry or default to using this

write learnt.txt %text
write to a new line in learnt.txt "the information => the info"

;write this to a file: this entry => that info
;after it's done writing verify that the data did write to the file and if so have it tell you "ok".
remark lines in mirc

if ($read(learnt.txt,w,%text)) { msg $chan ok }
reads learnt.txt for a line matching "the information => the info" if it exists and matches, messages active channel ok, verifying that it learned the information

else { msg $chan I pooped my pants }
if it failed to write the information successfully it messages the active channel that it pooped it's pants smile
}
}
}
if ($1 == !delete) {
if the first word is !delete

var %text = $2- =>
create the temporary variable %text which equals the second word to the end and add to it a =>

%text = $read(learnt.txt, w, %text $+ *)
update the variable %text with the information found from reading learnt.txt for a line beginning with "the information =>"

if (%text) {
if found/exists/is not empty...

write -dl $+ $readn learnt.txt
use write to delete the line read during the $read operation, removing the entry from the learnt.txt file.

msg $chan Deleted entry.
message active channel "Deleted entry.

}
else { msg $chan Info does not exist to delete }
if not found/edists/or is empty(nothing returned) message the active channel "Info does not exists to delete"
}
}


Hope that helps you understand more about mirc smile.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 06:12 PM
thanks alot

REALLY appreciate it
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 07:01 PM
You're welcome. smile
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 07:37 PM
man you should teach web programming at college or something LOL

i thought of another idea to go along with this script

would it be possible to add a

!last 100

command or something? (to list the most recent 100 keywords added for easy reference)

and a !listall ? (to list all keyword entries)
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 08:03 PM
Yes that could be possible. However, I can't work on it much more today, maybe later though. But, I'll give it a shot smile.
hrm a ("!last" 100), perhaps it would be good to use a hash table for this, or a separate file just for that info. "!listall ?" can be achieved by just having it return every line of text from the file before the separateor =>. Possibly using a whileloop, but depending on how much data there is, it would take a while to get the data ready. I'll look into it later this evening smile.

Nah I never could teach at a college. I had a good teacher when I first started learning mIRC. Once I got use to how it's coding worked it sort of caught on over the years. It gets easier once you've started projects. Best way to learn, is to get an idea of something to make happen, and go for it.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 08:32 PM
i say you can :P

thanks for all your help mannn i ll look into adding new stuff to this script (or at least try to x.x)

practice makes perfect right ? haha

cya later this evening then! thanks again
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 08:56 PM
I dunno if this is what you mean by a !listall command. But I like it.

Code:
  if ($1 == !listall) {
    if ($2 == stop) { play stop }
    else { play $chan learnt.txt }
  }


Will have the bot read back the learnt.txt file to the channel
typing !listall stop

stops it.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 09:10 PM
something like that

i was thinking making it show only the keyword (not the definition) in this format

example:

<bot> entry1, entry2, blah, it goes on, number2, chickens, entry1, entry2, blah, it goes on, number2, chickens, entry1, entry2, blah, it goes on, number2, chickens, entry1, entry2, blah, it goes on, number2, chickens, entry1, entry2, blah, it goes on, number2, chickens,
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 09:14 PM
Ahh, ok. So we wouldn't need the play option, play plays back a files contents to the chat. I had made this just now:
Code:
  if ($1 == !last) {
    var %last = $2
    if (%last isnum) {
      var %lines = $lines(learnt.txt)
      var %startat $calc(%lines - %last +1)
      play -f $+ %startat $chan learnt.txt
    }
    else { msg $chan no number specified }
  }


But I see where you're going with this.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 09:26 PM
that works better

but is there anyway to make it show only the keyword? in the format i showed in the previous post
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 09:31 PM
Code:
  if ($1 == !listall) {
    var %i = 1
    var %lines = $lines(learnt.txt)
    var %result
    while (%i &lt;= %lines) {
      var %line = $read(learnt.txt,%i)
      var %islocation = $findtok(%line,=&gt;,1,32)
      var %keyword = $gettok(%line,1- $+ $calc(%islocation -1),32)
      if (%result) { %result = %result $+ , %keyword }
      else { %result = %keyword }
      inc %i
    }
    msg $chan %result
  }


Explained:
if ($1 == !listall) {
if first word equals !listall

var %i = 1
create temporary variable %i equaling 1 (needed for the loop below)

var %lines = $lines(learnt.txt)
create temporary variable %lines which returns the total lines in the learnt.txt file
for this sample lets say %lines equals 12

var %result
create temporary variable %result for use later on

while (%i <= %lines) {
whileloop if %i (1) is less than or equal to %lines (12)

var %line = $read(learnt.txt,%i)
create temporary variable %line having it read learnt.txt line %i (1) to start

var %islocation = $findtok(%line,=>,1,32)
create temporary variable %islocation to get the location of =>

var %keyword = $gettok(%line,1- $+ $calc(%islocation -1),32)
create temporary variable %keyword to return just the keyword of the %line + %islocation results. Returns "word" and not "word =>"

if (%result) { %result = %result $+ , %keyword }
if %result is true/is something/not empty/etc... update the variable with the information it already has plus the new %keyword

else { %result = %keyword }
else if %result is false/is nothing update %result with %keyword

inc %i
increase the variable %i plus 1, %i was 1 now it's 2
the loop then goes back to the start and performs the same routine replacing %i = 1 with %i = 2

}
msg $chan %result
when the loop is completed message active channel the results
}

results will show as follows:
<nick> this entry, apple, grey matter, red, spoon, PIM, word, words, ammo, pistol

now to create the !last num thing
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 09:40 PM
Code:
  if ($1 == !last) {
    var %last = $2
    if (%last isnum) {
      var %lines = $lines(learnt.txt)
      var %i = $calc(%lines - %last +1)
      var %result
      while (%i &lt;= %lines) {
        var %line = $read(learnt.txt,%i)
        var %islocation = $findtok(%line,=&gt;,1,32)
        var %keyword = $gettok(%line,1- $+ $calc(%islocation -1),32)
        if (%result) { %result = %result $+ , %keyword }
        else { %result = %keyword }
        inc %i
      }
      msg $chan Results: %result
    }
    else { msg $chan no number specified }
  }


The above will seem familiar to the !listall except all it does is start on a particular line smile.

I'll explain some:
var %last = $2
create a temporary variable for %last which is a number you provide after "!last"

var %i = $calc(%lines - %last +1)
create a temporary variable taking the total %lines minus the %last (the number you provide this gets us the remaining lines) and add 1 to it. Adding one shifts it down 1 line, to start on the line we want to begin at.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 09:46 PM
haha looks great so far, awesome

i think i just ran out of ideas o_o;;
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 09:58 PM
Well, that should be enough to get you started. Just review over it, and try things out yourself. Bug check it etc... Never hold back asking a question on here, there's always an answer smile.
Posted By: Sukai Re: a ZBOT script for mIRC - 22/09/06 10:06 PM
thanks Scorpwanna i ll keep you updated if i make any changes, oh and let me know how your socketbot turns out

for now i go

bye and thanks again
Posted By: Riamus2 Re: a ZBOT script for mIRC - 22/09/06 10:54 PM
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 &amp;&amp; $1 != !replace &amp;&amp; $1 != !append &amp;&amp; $1 != !delete &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-
  }
  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.
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 22/09/06 11:22 PM
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"
Posted By: Sukai Re: a ZBOT script for mIRC - 23/09/06 12:13 AM
LOL oiiii

now i dont know which one to use

both got its pros

x___x im so confused
Posted By: Riamus2 Re: a ZBOT script for mIRC - 23/09/06 12:35 AM
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.
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 23/09/06 01:05 AM
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
Posted By: Sukai Re: a ZBOT script for mIRC - 23/09/06 01:10 AM
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
Posted By: Riamus2 Re: a ZBOT script for mIRC - 23/09/06 01:44 AM
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.
Posted By: Riamus2 Re: a ZBOT script for mIRC - 23/09/06 01:47 AM
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.
Posted By: Sukai Re: a ZBOT script for mIRC - 23/09/06 02:07 AM
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
Posted By: Riamus2 Re: a ZBOT script for mIRC - 23/09/06 02:12 AM
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.
Posted By: Sukai Re: a ZBOT script for mIRC - 23/09/06 02:34 AM
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
Posted By: Riamus2 Re: a ZBOT script for mIRC - 23/09/06 02:52 AM
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.
Posted By: Sukai Re: a ZBOT script for mIRC - 23/09/06 03:56 AM
unfortunately the !last n and !listall isnt working :~(
Posted By: Riamus2 Re: a ZBOT script for mIRC - 23/09/06 02:52 PM
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
}
Posted By: Sukai Re: a ZBOT script for mIRC - 23/09/06 06:34 PM
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
Posted By: Riamus2 Re: a ZBOT script for mIRC - 23/09/06 09:55 PM
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.
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 23/09/06 11:59 PM
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.
Posted By: Sukai Re: a ZBOT script for mIRC - 24/09/06 01:10 AM
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)
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 24/09/06 02:12 AM
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
Posted By: Riamus2 Re: a ZBOT script for mIRC - 24/09/06 03:10 AM
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
Posted By: Riamus2 Re: a ZBOT script for mIRC - 24/09/06 03:18 AM
Quote:
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.


Heh. Yeah, they really are useful. I have a nice card dealing hash table script that I made that deals out cards and include colors (white background and red/black based on suit). I made it for my Cribbage script I'm working on. I kind of put that on hold, though... along with my Scattergories script. I should finish those... My monopoly script is also on hold, but from much longer ago. Oh well.

I haven't released to many scripts... a few are on my site (Weather script, Dictionary script, $DateXpander (do a search here for info on that if you want)) and a few were released on the invision forum (Kick/Ban window, Playlist script for Invision, etc.), but otherwise I've not really released much.

Btw, you don't have to include "2" when saying my nick. It's only there because I forgot my password for Riamus and had a different e-mail, so couldn't retrieve it.
Posted By: Sukai Re: a ZBOT script for mIRC - 24/09/06 07:55 AM
you guys are awesome!, really helped me out

how did you guys learn mirc scripting? played with it? any good tutorials or sites?

i only know of here and www.mircscripts.org
Posted By: Scorpwanna Re: a ZBOT script for mIRC - 24/09/06 08:59 AM
Ahh I gotcha, yeah same deal with me and my nickname on the scifi.com board. Yeah, i've got scripts laying around almost done or half way done that I never finish. frown I think the only one i ever finished completely was the huge mp3player script I created with the help of a few people's ideas. But that was years ago, I took a break from mirc scripting to learn some perl and a bit of php. Just recently started back up with mirc stuff, all these languages can get confuseing at times.

Sukai I never could find a tutorial that would match the mirc help file. I got started by a friend I met in chat teaching me simple on text events. First thing i ever made myself was a bot. smile Best way to learn is just get an idea, and think about how each thing of that idea is going to work. If you can't figure it out ask questions. smile
Posted By: Riamus2 Re: a ZBOT script for mIRC - 27/09/06 09:34 PM
Quote:
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)


Sorry I didn't get to this right away. This should give you your delay.

Apparently, I was wrong... you can't play a custom window. Well, you can by using an alias, but it still wants a filename. So, here's writing it to a file and playing that. Note that I changed the RED part from what it used to be and I added the GREEN part. Nothing else has changed.

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) {
      [color:red]write list.tmp [/color]$right(%list. [ $+ [ %line.cnt ] ],-1)
      inc %list.cnt
    }
    [color:green]play $chan list.tmp 1500
    .remove list.tmp[/color]
    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
}
Posted By: Riamus2 Re: a ZBOT script for mIRC - 27/09/06 09:52 PM
Quote:
you guys are awesome!, really helped me out

how did you guys learn mirc scripting? played with it? any good tutorials or sites?

i only know of here and www.mircscripts.org


I learned by doing it. Back in 2001, I started running TrivBot 2000 and after not very long, I realized that I wanted it to do more than it did. So, I started looking at the scripting and tried to figure out how to make it do what I wanted. Now our trivia bot is more advanced than any other trivia bot I've ever seen and it has around 10,000 questions specifically about old (classic) games for PC, console, and handheld. Of course, I have a lot of prior programming knowledge, so the scripting language isn't really that hard to figure out (or at least get a general idea of what is happening) with that prior knowledge.

I was on Dalnet at the time and it had 2 good #scripting channels... #scripthelp and #scripting, or something like that. I have no idea if those are the correct names or if they are still around. Anyhow, I always went there to ask questions.

As I got more involved with scripting, I started looking at other peoples' scripts to see how they worked. Combining that with mIRC's help file and this forum and the scripting channels, I have been able to figure out what I wanted to do without too much difficulty.

The real trick is this...

1) You need to really *want* to learn it. Otherwise, you won't put in enough effort and it will just be a waste of your time to try.

2) You need to script regularly (or at least play around with scripts, even if you're not writing new ones). When learning any language (computer or human), you learn through use. If you rarely use it, you won't succeed. I would love to relearn C++ (I haven't used it in so long that I forgot most of it), but I don't really have any need for writing programs in it, so learning it isn't really possible --- without needing to use it, I have no incentive to learn it and I don't get enough practice using it. With mIRC, I use it almost every day, so I'm always finding things that I can script or improve or change in scripts, so I have plenty of practice.

3) Learn to use the help file. Many people complain about it because it really isn't all that user friendly. However, it is a GREAT source of information if you know how to use it properly so that you can find what you are looking for.

4) Get some simple scripts from mircscripts.org and see how they do what they do. See if you can edit them to do something else. Start with simple things like on TEXT triggers. Try something like having the script send a message to anyone who says hello. As you progress, you can pick up more difficult scripts... but if you try to skip the easy scripts because you think they are "kid stuff", then you'll never really get very far.

5) Once you have a handle on the easier scripting skills, start paying attention to what people here are writing. Don't start answering scripting questions unless you're sure you know how to do it, but just read the answers others give. If the question is about sockets, for example, and you think you want to try to learn how to use sockets, then look at how the script in the answer looks and try to see how it works. Then start looking at other socket answers in the forum to see similarities. Try changing some things to see if you can make it do something different. Eventually, you can try writing your own. Keep in mind that sockets is advanced and I just used it as an example. The idea is that you see how people do something and then try to make it work for yourself.

6) Ask questions!! However, if you are learning to script, don't just ask if someone can write a script for you. Even just saying, "How can I make a script do ____?" will usually get you a script for an answer. That isn't what you want. Instead, ask the question, but include what you've already tried to create. And make sure to point out that you are trying to learn to do it yourself so that, hopefully, you'll get a good explanation on how to do it.
Posted By: billythekid Re: a ZBOT script for mIRC - 28/09/06 08:20 PM
7) remember your scripts do what you tell them to do, not what you want them to do....

smirk

btk
© mIRC Discussion Forums