mIRC Home    About    Download    Register    News    Help

Print Thread
Page 2 of 4 1 2 3 4
#160000 22/09/06 05:47 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
shocked that seems to work pretty well

#160001 22/09/06 05:48 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
I was once where you are, and never recieved the help I could of then. So I feel obligated to help you out smile.


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

#160003 22/09/06 06:00 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
Sure I'll give it a shot in my next post. But right now i'm making the !delete function smile.


We don't just write the scripts, we put them to the test! (ScriptBusters)
#160004 22/09/06 06:06 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- =>
    %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)
      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,=>,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 }
      }
    }
  }
  if ($1 == !delete) {
    var %text = $2- =>
    %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


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

Last edited by Scorpwanna; 22/09/06 07:01 PM.

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

REALLY appreciate it

#160007 22/09/06 07:01 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
You're welcome. smile


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

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


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

#160011 22/09/06 08:56 PM
Joined: Sep 2003
Posts: 261
S
Fjord artisan
Offline
Fjord artisan
S
Joined: Sep 2003
Posts: 261
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.


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

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


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

but is there anyway to make it show only the keyword? in the format i showed in the previous post

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


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


We don't just write the scripts, we put them to the test! (ScriptBusters)
#160017 22/09/06 09:46 PM
Joined: Sep 2006
Posts: 31
S
Sukai Offline OP
Ameglian cow
OP Offline
Ameglian cow
S
Joined: Sep 2006
Posts: 31
haha looks great so far, awesome

i think i just ran out of ideas o_o;;

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


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

Last edited by Sukai; 22/09/06 10:06 PM.
Page 2 of 4 1 2 3 4

Link Copied to Clipboard