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)
}
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.
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
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
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.
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 ?
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 :)
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
[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?
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.
\"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