|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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.comonce 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.
|
|
|
|
Joined: Mar 2004
Posts: 210
Fjord artisan
|
Fjord artisan
Joined: Mar 2004
Posts: 210 |
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.)
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2006
Posts: 31 |
i guess i could try that ![smirk smirk](/images/graemlins/mirc/smirk.gif) dont know if i can do it tho
|
|
|
|
Joined: Jan 2006
Posts: 108
Vogon poet
|
Vogon poet
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
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2006
Posts: 31 |
this is hard ![smirk smirk](/images/graemlins/mirc/smirk.gif) im reading up on mirc's help file ..to see if any variables/comands etc can help me out
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
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 smile](/images/graemlins/mirc/smile.gif) 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"
on *:text:*:#: {
if ($findtok($1-,is,1,32)) {
var %text = $1-
%text = $reptok(%text,is,=>,1,32)
write learnt.txt %text
;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".
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".
on *:text:*:#: {
var %text = $read(learnt.txt, w, $1- $+ *)
;if "this entry*" is found at the beginning of a line,
if (%text) {
var %split=> = $calc($findtok(%text,=>,1,32) +1)
msg $chan hmm, $gettok(%text,%split=> $+ -,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)
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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
|
|
|
|
Joined: Oct 2004
Posts: 8,330
Hoopy frood
|
Hoopy frood
Joined: Oct 2004
Posts: 8,330 |
The fastest method would probably be hash tables:
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
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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.
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Heh, Riamus2 you are obsessed with hash tables ![smile smile](/images/graemlins/mirc/smile.gif) . There's only 1 drawback to the hash table item definition thing. the item can only be 1 word. ![frown frown](/images/graemlins/mirc/frown.gif) Sukai When I gave you the examples I separated them, all in all they should be under the same on text event:
on *:text:*:#: {
var %text = $read(learnt.txt, w, $1- $+ *)
;if "this entry*" is found at the beginning of a line,
if (%text) {
var %split=> = $calc($findtok(%text,=>,1,32) +1)
msg $chan hmm, $gettok(%text,%split=> $+ -,32)
}
if ($findtok($1-,is,1,32)) {
var %text = $1-
%text = $reptok(%text,is,=>,1,32)
write learnt.txt %text
;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".
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)
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
Joined: Sep 2003
Posts: 261 |
on *:text:*:#: {
if ($1 == ?) {
var %text = $2- =>
%text = $read(learnt.txt, w, %text $+ *)
;if "this entry*" is found at the beginning of a line,
if (%text) {
var %split=> = $calc($findtok(%text,=>,1,32) +1)
msg $chan hmm, $gettok(%text,%split=> $+ -,32)
}
}
if ($1 == !learn) {
if ($findtok($2-,is,1,32)) {
var %text = $2-
%text = $reptok(%text,is,=>,1,32)
write learnt.txt %text
;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".
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 smile](/images/graemlins/mirc/smile.gif) .
Last edited by Scorpwanna; 22/09/06 04:24 PM.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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.
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
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 smile](/images/graemlins/mirc/smile.gif)
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Hrm, you've just inspired me to add something like this to a socketbot i have. ![smile smile](/images/graemlins/mirc/smile.gif) 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)
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
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.
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
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 smile](/images/graemlins/mirc/smile.gif) . Not gunna leave you in the woods by yourself.
We don't just write the scripts, we put them to the test! (ScriptBusters)
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2006
Posts: 31 |
thank you ![laugh laugh](/images/graemlins/mirc/laugh.gif) 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
|
|
|
|
Joined: Sep 2003
Posts: 261
Fjord artisan
|
Fjord artisan
Joined: Sep 2003
Posts: 261 |
Sounds like great fun, I'll do it! heh Edited: Try this out.
on *:text:*:#: {
if ($1 == ?) {
var %text = $2- =>
%text = $read(learnt.txt, w, %text $+ *)
;if "this entry*" is found at the beginning of a line,
if (%text) {
var %term = $reptok(%text,=>,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,=>,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,=>,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,=>,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 => 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)
|
|
|
|
Joined: Sep 2006
Posts: 31
Ameglian cow
|
OP
Ameglian cow
Joined: Sep 2006
Posts: 31 |
LOL your too nice ![laugh laugh](/images/graemlins/mirc/laugh.gif) im reading over the /help file in mirc to better understand some of the stuff used in here
|
|
|
|
|