mIRC Home    About    Download    Register    News    Help

Print Thread
Page 1 of 4 1 2 3 4
#159980 22/09/06 02:21 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
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

Last edited by Sukai; 22/09/06 02:24 AM.
#159981 22/09/06 02:53 AM
Joined: Mar 2004
Posts: 210
F
Fjord artisan
Offline
Fjord artisan
F
Joined: Mar 2004
Posts: 210
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.)

#159982 22/09/06 03:22 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
i guess i could try that smirk

dont know if i can do it tho

#159983 22/09/06 03:34 AM
Joined: Jan 2006
Posts: 108
F
Vogon poet
Offline
Vogon poet
F
Joined: Jan 2006
Posts: 108
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

#159984 22/09/06 04:24 AM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
this is hard smirk

im reading up on mirc's help file ..to see if any variables/comands etc can help me out

#159985 22/09/06 07:25 AM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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.


We don't just write the scripts, we put them to the test! (ScriptBusters)
#159986 22/09/06 01:31 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
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

#159987 22/09/06 01:36 PM
Joined: Oct 2004
Posts: 8,330
Hoopy frood
Offline
Hoopy frood
Joined: Oct 2004
Posts: 8,330
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.


Invision Support
#Invision on irc.irchighway.net
#159988 22/09/06 01:49 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
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

Last edited by Sukai; 22/09/06 02:09 PM.
#159989 22/09/06 03:54 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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


We don't just write the scripts, we put them to the test! (ScriptBusters)
#159990 22/09/06 04:13 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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.

Last edited by Scorpwanna; 22/09/06 04:24 PM.

We don't just write the scripts, we put them to the test! (ScriptBusters)
#159991 22/09/06 04:22 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
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

Last edited by Sukai; 22/09/06 04:26 PM.
#159992 22/09/06 04:25 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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


We don't just write the scripts, we put them to the test! (ScriptBusters)
#159993 22/09/06 04:31 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
i entered several entries of "cool"

it doesnt show them all or append, only shows the first "cool" entry made

#159994 22/09/06 04:31 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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


We don't just write the scripts, we put them to the test! (ScriptBusters)
#159995 22/09/06 04:38 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
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

Last edited by Sukai; 22/09/06 04:39 PM.
#159996 22/09/06 05:03 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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.


We don't just write the scripts, we put them to the test! (ScriptBusters)
#159997 22/09/06 05:12 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
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

#159998 22/09/06 05:26 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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

Last edited by Scorpwanna; 22/09/06 05:46 PM.

We don't just write the scripts, we put them to the test! (ScriptBusters)
#159999 22/09/06 05:43 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
LOL

your too nice laugh

im reading over the /help file in mirc to better understand some of the stuff used in here

Page 1 of 4 1 2 3 4

Link Copied to Clipboard