Botmail

By RusselB on Jan 06, 2007

Basic botmail uses commands like !send, !read, !del and !list
Some commands accept one or more parameters (ie: You can read multiple messages by specifying the message numbers)
Contact information is located at the beginning of the script

Script now tracks when a message is left.

Script works, but there is an occasional timing problem when reading the messages, where the message actually gets displayed before the information regarding who it's from and when it was left, rather than the other way around.

Additionally, if messages are deleted in an order other than last to first, there will be blank messages displayed, even though the count is correct. I'm not sure how to get around this at the moment, but I will keep working on it.

As always, suggestions and comments are more than welcome.

Changes made on July 11 2010: Network specific access. Use !add network to add the current network and !del network to delete the current network from the list.

Custom window log added July 25 2010.

;Contact information
;Author: RusselB
;Website reference: http://www.hawkee.com/snippet/2248/
;E-mail: r.k.bairstow@gmail.com
;NOTE: Please allow at least 3 days for a response on the website before using the e-mail, and even then only if it's due to an error in the script rather than a modification request.
.ctcp *:version:*:  ctcpreply $nick VERSION   return Botmail script by RusselB. July 25 2010
on *:start:{
  if !$hget(Botmail) { .hmake Botmail 100 }
  if $exists(Botmail.hsh) { .hload Botmail Botmail.hsh }
}
on *:exit:{
  .hsave -o Botmail Botmail.hsh 
}
on *:disconnect:{
  .hsave -o Botmail Botmail.hsh 
}
on *:notify:{
  if $istok(%botmail.networks,$network,32) {
    if $hget(Botmail,$nick) {
      .msg $nick I have $bytes($hget(Botmail,$nick),b) messages for you
      .msg $nick All commands are to be used via pm/query.
      .msg $nick Available commands are: !list, !read <message number(s)>, !del <message number(s)>, and !delall
    }
  }
}
on *:text:*:?:{
  tokenize 32 $strip($replace($1-,$chr(44),$chr(32)))
  if !$window(@Botmail) { .window @Botmail }
  .echo @Botmail $nick ( $+ $address $+ ) used the command $1- on $date at $time
  if ($1- == !add network) {
    set %botmail.networks $addtok(%botmail.networks,$network,32)
    .msg $nick $network has been added to the list of networks.
    .msg $nick Active networks: %botmail.networks
  }
  if $istok(%botmail.networks,$network,32) {
    if ($1- == !del network) {
      set %botmail.networks $remtok(%botmail.networks,$network,1,32)
      .msg $nick $network has been removed from the list of networks.
      .msg $nick Active networks: %botmail.networks
    }
    elseif ($1 == !help) {
      .msg $nick All commands are to be used via pm/query.
      .msg $nick Available commands are: !list, !read <message number(s)>, !del <message number(s)>, and !delall
    }
    elseif ($1 == !send) {
      if !$2 || !$3 {    .notice $nick Usage: !send <nick> <message>  }
      else {
        .hinc -m Botmail $2
        .hadd -m Botmail $+($2,.,$hget(Botmail,$2)) $address($nick,5) $ctime $3-
      }
      .notify $2
    }
    elseif $1 == !list {   .msg $nick You have $hget(Botmail,$nick)) message $+ $iif($hget(Botmail,$nick) != 1,s)    }
    elseif $1 == !delall {
      .hdel -w Botmail $+($nick,*)
      if $notify($nick) {      .notify -r $nick    }
      .msg $nick All of your messages have now been deleted
    }
    else {
      if !$hget(Botmail,$nick) {    .msg $nick You have no messages  }
      elseif !$2  {    .msg $nick No message number(s) specified  }
      else {
        var %msgs = $remove($replace($2-,$chr(44),$chr(32)),$chr(35)), %a = 1, %b = $numtok(%msgs,32)
        while %a <= %b {
          if $gettok(%msgs,%a,32) !isnum {
            .msg $nick Only message numbers are allowed    
            .msg $nick Message $v1 will be ignored
          }
          else {
            if $1 == !read {
              var %msg.num = $gettok(%msgs,%a,32), %msg = $hget(Botmail,$+($nick,.,%msg.num)), %msg.nick = $gettok(%msg,1,32), $&
                %msg.time = $gettok(%msg,2,32), %msg = $gettok(%msg,3-,32)
              .timer 1 %a .msg $nick Message $chr(35) $+ %msg.num From: %msg.nick Sent At: $asctime(%msg.time)
              .timer -m 1 $calc(%a * 1500) .msg $nick %msg
            }
            elseif $1 == !del {
              .hdel Botmail $+($nick,.,$gettok(%msgs,%a,32))
              .hdec Botmail $nick
              .msg $nick Message $gettok(%msgs,%a,32) has been deleted.
              if $hget(Botmail,$nick) == 0 {
                .hdel -w Botmail $+($nick,*)
              }
            }
          }
          inc %a
        }
      }
    }
  }
}
on *:close:@Botmail:{
  .savebuf -a @Botmail $qt($scriptdirBotmail.log)
}

Comments

Sign in to comment.
Cheiron   -  Jul 25, 2010

its cool though , it works and i can live with it all being logged. maybe at a later date just edit it so it only logs who has sent the botmail and not the rest of the commands.
many thanks RusselB :)

 Respond  
RusselB   -  Jul 25, 2010

Ooops.. sorry about the typo.
As to it relaying everything, that is, by definition, what a log is.
Also, and I quote > a log system so i can check who has used the service direct from a custom window, @Botmail , on the bot in format nick (ident@hostmask) used botmail at $time on $date
OK.. I admit I didn't include the address information and I altered the date/time format, but it does show > who has used the service I just included what command/part of the service they actually used.

 Respond  
Cheiron   -  Jul 25, 2010

window opened but

used the command !send Cheiron test on 25/07/2010 at 21:05:02

nick wasnt shown.

i had a look at the edited code RusselB and spotted a minor mistake.

 .echo @Botmail $nicks used the command $1- on $date at $time

it should be $nick

on editing the window now showed

Cheiron used the command !send Cheiron test on 25/07/2010 at 21:06:52
Cheiron used the command !list on 25/07/2010 at 21:06:58
Cheiron used the command !read 1 on 25/07/2010 at 21:07:05
Cheiron used the command !read 2 on 25/07/2010 at 21:07:11
Cheiron used the command !delall on 25/07/2010 at 21:07:16

it is relaying everything to the custom window

 Respond  
RusselB   -  Jul 25, 2010

Logging added

 Respond  
Cheiron   -  Jul 25, 2010

been running the botmail for nearly 2 weeks now with no issues at all, so i want to say a huge ty to you RusselB for such a reliable script and on a busy net too.

just looking forward to the logging system now to complete the script for me :)

 Respond  
Cheiron   -  Jul 14, 2010

hi RusselB

yeah i know that with the pm blocker. i realised that as soon as my bot went funny with my script even though i have the bot added it will message them.
as for the logging, fantastic.. will keep my eyes peeled :)

 Respond  
RusselB   -  Jul 14, 2010

Re: PM Blockers -> There is no way that I know of for determining if a person is using a pm blocker or not, thus the results gotten when someone else is using a pm blocker is not a problem/error with my code.
Re: Usage logging system -> Will see about adding that later.

 Respond  
Cheiron   -  Jul 14, 2010

field tested it for a few days now and have found no problems with it .. except where users have pm blockers. it sends it loopy when the client accepts the pm from the bot as shon below.

Message This will be ignored Only message numbers are allowed Message is will be ignored

dont know if that can be fixed or not.
other than that .. only thing i can see that this script can benifit with is a log system so i can check who has used the service direct from a custom window, @Botmail , on the bot in format nick (ident@hostmask) used botmail at $time on $date

 Respond  
Cheiron   -  Jul 12, 2010

bingo. thats working now
many thanks RusselB :)

 Respond  
RusselB   -  Jul 12, 2010

Added notification message for network addition/removal. Also noted that the global variable where the network names are stored was missing the last s in a couple of spots.

Regarding the nicks not being deleted from the hash table, they should be deleted when using the !delall command. I will quickly add a check so that they are also deleted if the number of outstanding messages is zero.

 Respond  
Cheiron   -  Jul 12, 2010

i cant seem to get the !add network to run RusselB .. i did !add network in the bot pm and tried in channel too.. nothing confirmed and nothing found in my hash table manager either to say it has worked. i have look also in variables and nothing in there. i tried to run it as is and now cannot get anything to work at all :(

also .. just out of interest ....

the nicks do not get deleted from the hash table after they have got their message and have deleted them. is that normal ?

 Respond  
RusselB   -  Jul 11, 2010

Changes made

 Respond  
Cheiron   -  Jul 11, 2010

only other edit sorry and i apologise for the double post is how to make it network specific as i got bot sat on 3 nets and only want it to trigger on 1 net

 Respond  
Cheiron   -  Jul 11, 2010

nice script RusselB and goes ok. one edit i would like to see though to try and counter the idiots using others nicks to stir trouble is for it to show the hostmask of the user sending it
atm it only shows

!read 1 Message #1 From: Cheiron Sent At: Sun Jul 11 19:49:30 2010 testing

what would be benficial is

!read 1 Message #1 From: Cheiron (ident@hostmask) Sent At: Sun Jul 11 19:49:30 2010 testing

could you do an update for that please for me :)

 Respond  
AHBARAR   -  Jun 13, 2007

gr8 my freind im always keeping my eye on ur works hehe oh i never post my works wonder why >:s but im sure i love ur work >:D

 Respond  
RusselB   -  Jun 12, 2007

Glad I was able to get the problems resolved. Please keep an eye for updates, as I will be posting them as I\'m able to get the other problems resolved.

 Respond  
AHBARAR   -  Jun 12, 2007

It Works So Perfect Thx So Much RusseIB For Ur Time U Deserve 10/10 without any objection >:D

 Respond  
RusselB   -  Jun 09, 2007

I think I got all the problems, with the exceptions of those noted in the introduction, solved.

 Respond  
RusselB   -  Jun 08, 2007

Problems noted, Ahbarar. I should be able to find the exact causes of those errors and fix them up in time for an update in 48 - 60 hours

 Respond  
AHBARAR   -  Jun 03, 2007

if i say !del nick it says

  • /hdel: insufficient parameters (line 64, msg.txt)
    and if i say !delall it says
  • /hdel: insufficient parameters (line 54, msg.txt)
 Respond  
AHBARAR   -  Jun 03, 2007

i like the script but i found tht if u typed !read #1 it give u this msg Message ##1 From:
and on bot u can see

  • /msg: insufficient parameters
    but if u typed !read 1 or 2 it work
    the problem is deleting cas it giving this bug
  • /hdel: insufficient parameters (line 64, msg.txt)
    and its not deleting it >:|
 Respond  
RusselB   -  Apr 22, 2007

Mecatrix & Scar-Face: I apologize for that error. Somehow I managed to miss a closing parantheses on each of lines 47 & 48.
This has been corrected.

 Respond  
Scar-Face   -  Apr 15, 2007

I got the same type error as mecatrix did. :-/

 Respond  
mecatrix   -  Apr 08, 2007
  • Invalid format: $gettok (line 47, script5.txt)
  • Invalid format: $gettok (line 47, script5.txt)
  • Invalid format: $gettok (line 47, script5.txt)
  • Invalid format: $gettok (line 47, script5.txt)

[03:49] <PaNDa[ro]> I have messages for you
[03:49] <PaNDa[ro]> Use: /msg PaNDa[ro] !list to list them, /msg PaNDa[ro] !read <message number(s)> to read the message(s), /msg PaNDa[ro] !del <message number(s)> to delete the message(s), or /msg PaNDa[ro] !delall to delete all messages
[03:49] <PaNDa\Tido> !list
[03:49] <PaNDa[ro]> Message #1 from PaNDa\Tido
[03:49] <PaNDa\Tido> !read 1
[03:50] <PaNDa\Tido> !read #1
[03:50] <PaNDa\Tido> !read #1 from PaNDa\Tido
[03:50] <PaNDa\Tido> !read 1 from PaNDa\Tido

i got that :D any repair?

 Respond  
RusselB   -  Jan 20, 2007

RussellReal: Nice catch on the : in that elseif...I\'m not sure how that got in there, but I have removed it. Regarding RAM, if someone is running that close on the amount of RAM in their system, then they should get more. I like using hash tables for things like this, as ini files (or any type of file that requires disk access) is a lot slower than a hash table.

If you want to do a re-write of my script so that it uses ini files, please be my guest. I only request that you include a line noting that your script is based on mine.

 Respond  
RussellReal   -  Jan 13, 2007

\"elseif $1 == !del:{\" suspicious :o and more on that note pretty sure won\'t trigger, I know if statements trigger without () but process faster with them so there is less prediction needed for the client to process, and I would have to press the fact that, hash shouldn\'t be used really for long term storing of data, it could, butt it shouldn\'t because it uses RAM which you prolly have alot of but some people JUST BARELY have enough RAM to keep their operating system good, and Therefore I use them only for sockets and such where its opened and closed within seconds, and, as a alternative to hash tables, I really like ini, and I kinda find them to work better, and they are way more organised, I say that because hash never stays in order, the item name may stay the same but when you loop through a table it will NEVER stay the same order UNLESS its a smaller scale table, and even still you can\'t be too certain, but ini is better in that department. $ini == $readini\'s lil counterpart and together you can incorperate awesome amounts of data into scripts which might require that much. hope Any of my advice helps :s

 Respond  
SyntaxIRC   -  Jan 07, 2007

Damnit, Noutrious, sorry. :P

 Respond  
SyntaxIRC   -  Jan 07, 2007

I\'d have to agree with Nitrous, but add a few more e\'s at the end.

 Respond  
no_body21   -  Jan 07, 2007

CooL! Nice Job RusselB

 Respond  
Lindrian   -  Jan 07, 2007

Not bad at all!

 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.