Make your bot Talk

By DjSxX on Dec 12, 2013

Make your bot talk, its a quote system, it records any text in any channel seperated in txt files for a channel if the bot is highlighted
Change YOURBOT into the nick of the bot to make it respond to its name
The language is in dutch but thats easy adjustable ;)
Type !quote info to see howmany lines it has

Can Anyone help me to find out that the bot doesnt record lines dat already excists in the textfile?
Code is edited on 16.12.2013

on *:TEXT:*:#: {
  if ($1 == !quote) && ($2 == info) {
    if (!%waitthreeagain) {
      msg $chan Totaal aantal Quotes: $+(,$lines(quotes. $+ $chan $+ .txt),)   
      msg $chan Om flooding te voorkomen: 1 quote om de 3 seconden.
      set -u3 %waitthreeagain 1
    }
    else { halt }
  }
  elseif ($1 == $me $+ :) || ($1 == $me) {
    if (!%waitthree) {
      msg $chan  $+ $nick $+ : $read(quotes. $+ $chan $+ .txt, n)
      set -u3 %waitthree 1
      if ($2 == $null) { halt }
      else { write quotes. $+ $chan $+ .txt $2- }
    }
    else { halt }
  }
  elseif ($1 == $me) && ($len($2-) >= 1) {
    if ($2- !isin $read(quotes. $+ $chan $+ .txt, nw, $2- $+ , $calc($readn + 1))) { write quotes. $+ $chan $+ .txt $2- }
    else { halt }
  }
}

Comments

Sign in to comment.
baloe12nl   -  Dec 24, 2013

J youse this code for my chatterbot.

On *:load: {
  /echo 5 -ag Loaded chatterbot script $+(v,1.0) $+ ! By Baloe12nl.
  if ( !$readini( scripts/kletsen.ini, Hallo, antw1 ) ) {
    /writeini scripts/kletsen.ini Hallo antw1 Hai to you to
  }
  if ( %timerkls == $null ) { /set %timerkls 0 | /echo 5 -ag timerkls is loaded and set to 0. }
  if ( %antkls == $null ) { /set %antkls 1 | /echo 5 -ag antls is loaded and set to 1. }
  if ( %antkls.rand == $null ) { /set %antkls.rand 1 | /echo 5 -ag antkls.rand is loaded and set to 1. }
  /echo 5 -ag to use, type: !talk < on / off / disable >
}

on *:TEXT:*talk*:*: {
  if ($1 == !talk) {
    if ($2 == on) { /enable #talks | /disable #Ctalks | /msg $chan 5De Talk Mode Is on, | set %st.talks on | set %last.used.command talks on | set %last.persons1 $nick | halt }
    if ($2 == off) { /disable #talks | /enable #Ctalks | /msg $chan 5De Talk Mode Is off. | unset %st.talks | set %last.used.command talks off | set %last.persons1 $nick | halt }
    if ($2 == disable) { /disable #talks | /disable #Ctalks | /msg $chan 5De Talk Mode Is off. | /msg $chan 5De teatch Mode Is off. | unset %st.talks | set %last.used.command talks off | set %last.persons1 $nick | halt }
    if ($2 == help) { /notice $nick 5< 10!talk on 5> zet de chatterbot op speake mode | /notice $nick 5< 10!talk off 5> Zet de speake mode of en de learn mode aan. | /notice $nick 5< 10!talk disable 5> Zet de learn en speake mode beide off. | /notice $nick 5< 10!talk help 5> Geeft hulp bij de chatterbot comando's. }
    else { /notice $nick 5Incorrect command usage: !talk <on/off/disable/help> | halt }
  }
  else { /halt }
}

; Here the read part and awnser on the chat
; Hier het gedeelte dat leest en antwoord op de chat

#talks off

on *:text:*:#: {
  /set %antkls.rand $rand(1, [ %nr ] )
  if ( $readini(scripts/kletsen.ini, $1 $+ $2 $+ $3 $+ $4, antw $+ 1 ) == $null ) { /halt }
  :1
  if ( $readini(scripts/kletsen.ini, $1 $+ $2 $+ $3 $+ $4, antw $+ %antkls.rand ) == $null ) { /dec %antkls.rand 1 | goto 1 }
  else { /msg # $readini(scripts/kletsen.ini, $1 $+ $2 $+ $3 $+ $4, antw $+ %antkls.rand ) }
}

#talks end

; Here the write part to ini
; hier gedeelte dat het moet schrijven naar ini

#Ctalks on

on *:text:*:#: {
  if ( %timerkls <= 0) { /set %nick $nick | /set %nick1 $1 $+ $2 $+ $3 $+ $4 | /set %timerkls 360 | /dec -c %timerkls 1 | /halt }
  if ( %timerkls >= 1 ) { 
    if ( $nick == %nick ) /halt
    if ( $nick == chatbot ) /halt ;Hier de naam van je chatbot op <chatbot> ; Here the name of your Bot on < chatbot >
    else {
      /set %antkls 1
      /set %timerkls 0
      if ( $readini( scripts/kletsen.ini, %nick1 $+ , antw $+ %antkls ) != $null ) { 
        :2
        if ( $1- isin $readini( scripts/kletsen.ini, %nick1 $+ , antw $+ %antkls ) ) {
          /set %timerkls 0 
          /unset %nick
          /halt
        }
        if ( %antkls > %nr ) /set %nr %antkls
        if ( $readini( scripts/kletsen.ini, %nick1 $+ , antw $+ %antkls ) != $null ) { 
          /inc %antkls 1
          goto 2
        }
        else { 
          /writeini -n scripts/kletsen.ini %nick1 antw $+ %antkls $1- 
          /set %timerkls 0 
          /unset %nick
          ;          /save scripts/kletsen.ini
          /load -rs scripts/kletsen.ini
          /halt
        }
      }
      else { 
        /writeini -n scripts/kletsen.ini %nick1 antw $+ %antkls $1- 
        /set %timerkls 0 
        /unset %nick
        ;       /save scripts/kletsen.ini
        /load -rs scripts/kletsen.ini
        /halt
      }
    }
  }
}

#Ctalks end
 Respond  
Vegito   -  Dec 16, 2013
on *:TEXT:*:#: {
  if ($1-2 = quote info) {
    if (!%waitthreeagain) {
      msg # Totaal aantal Quotes: $+(,$lines($+(quotes.,#,.txt)),)   
      set -u3 %waitthreeagain 1
    }
    else msg # Om flooding te voorkomen: 1 quote om de 3 seconden.
  }
  if ($istok($+($me,:) $me,$1,32)) {
    if (!%waitthree) {    
      set -u3 %waitthree 1
      if (!$2) msg # $+(,$nick,:) $read($+(quotes.,#,.txt),n)
      elseif ($2- !isin $read($+(quotes.,#,.txt), nw, $2-, $readn)) write $+(quotes.,#,.txt) $2- 
    }
    else msg # Om flooding te voorkomen: 1 quote om de 3 seconden.
  }
}

Zo is het veel beter.

DjSxX  -  Dec 21, 2013

thnx @Vegito heb er weer wat bij geleerd :D
Ik ben er nog redelijk n00b in, Heb allen de if regel nog achter de elsif gezet zodat ie ook reageert als je wel een $2 typt ;)

on :TEXT::#: {
if ($1-2 = quote info) {
if (!%waitthreeagain) {
msg # Totaal aantal Quotes: $+(,$lines($+(quotes/quotes.,#,.txt)),)
set -u3 %waitthreeagain 1
}
else msg # Om flooding te voorkomen: 1 quote om de 3 seconden.
}
if ($istok($+($me,:) $me,$1,32)) {
if (!%waitthree) {
set -u3 %waitthree 1
if (!$2) msg # $+(,$nick,:) $read($+(quotes/quotes.,#,.txt),n)
elseif ($2- !isin $read($+(quotes/quotes.,#,.txt), nw, $2-, $readn)) write $+(quotes/quotes.,#,.txt) $2- | msg # $+(,$nick,:) $read($+(quotes/quotes.,#,.txt),n)
}
else msg # Om flooding te voorkomen: 1 quote om de 3 seconden.
}
}

Maar het werkt wel :D

Vegito  -  Dec 22, 2013

Hoe jij het bij elseif hebt gedaan zal niet werken omdat je { } mist.

Maar je zou het ook veel makkelijker kunnen doen.

on *:TEXT:*:#: {
  if ($1-2 = quote info) {
    if (!%waitthreeagain) {
      msg # Totaal aantal Quotes: $+(,$lines($+(quotes.,#,.txt)),)   
      set -u3 %waitthreeagain 1
    }
    else msg # Om flooding te voorkomen: 1 quote om de 3 seconden.
  }
  if ($istok($+($me,:) $me,$1,32)) {
    if (!%waitthree) {    
      set -u3 %waitthree 1
      msg # $+(,$nick,:) $read($+(quotes.,#,.txt),n)
      if ($2- !isin $read($+(quotes.,#,.txt), nw, $2-, $readn)) write $+(quotes.,#,.txt) $2- 
    }
    else msg # Om flooding te voorkomen: 1 quote om de 3 seconden.
  }
}
Sign in to comment

Yawhatnever   -  Dec 14, 2013

http://en.wikichip.org/wiki/Text_Files_-_mIRC#n_Switch

ALWAYS USE THE n SWITCH for $read() and $readini()!!!!!!!!!!!!!!!!

ProIcons  -  Dec 14, 2013

Please Edit your Comment, and stop Spamming. Be polite to our fellow hawkeers

Yawhatnever  -  Dec 14, 2013

I am not being impolite, nor is it truly spam. The 'n' switch is one of the most important concepts one must learn in mSL, along with using $safe() on user-generated text in timers or /scon. Not only is @DjSxX leaving this gaping security hole for themselves, but they've posted the code publicly with the expectation that others may find it useful. If the code does not get edited I would go as far as to say that the code should be removed from public view.

Sign in to comment

Vegito   -  Dec 13, 2013

This is very badly written.

 Respond  
ProIcons   -  Dec 12, 2013

1st of all, this is not a section to asking questions. You can either go to forums, or on stackoverflow.
2nd, if you want an answer to this you must build/syntax your sentences in a way to give people to understand what exactly you want.

 Respond  
ovelayer   -  Dec 12, 2013

could also change YOURBOT to $me
=)

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.