@@ +Mail and BB system using MySQL @@ for PennMUSH 1.8.1p1 and higher @@ @@ August 16 2005 @@ Written by Talvo@ElendorMUSH / Mike@M*U*S*H @@ @@ COPYRIGHT AND SUPPORT: @@ This code is free for anyone to use. However: @@ 1) if it breaks (itself or other stuff), don't blame me. @@ 2) don't take credit for my code. @@ @@ For any support stuff, please feel free to email me. My current address is @@ talvo@talvo.com . I'll do my best to fix any bugs you might find as quickly as possible, @@ and if you have problems installing or setting up the system, I'll try and help with those, too, @@ but may not always have the time to do so. If you find a bug and fix it (or add a new feature @@ or anything), please feel free to send me it, and I'll include it in the file (you will be @@ fully credited for the code). Feature requests (without code) are also welcomed, though again may @@ not make it in, either due to lack of time or because it's not compatible with the way the system @@ works. @@ @@ And now that's out the way, a short description of the code: This is a +Mail and Bulletin Board @@ system for PennMUSH 1.8.1. It stores the messages off the MUSH, in a MySQL database. @@ It will also very shortly have an accompanying POP3 server and (hopefully) NNTP server, which @@ means you can download your mail from the MUSH into Outlook Express/Thunderbird, etc, or @@ even set up a web-based system like SquirrelMail to check it. (The POP3 server is mostly done, @@ and the NNTP is a current work-in-progress.) They're (being) written in the Tcl scripting language, @@ and will hopefully run on all platforms when finished. @@ @@ Commands are not currently made "global" (via @command/add and @hook) because it's not possible, @@ b/c of the way those commands work. @@ @@ 4 MySQL tables are used (named inbox, bbinbox, undo and mail), and are created by the code. @@ Tested on MySQL version 4.0.24 @@ @@ The latest version of this code (and help-files) are available from www.talvo.com @@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ @@ INSTALLATION INSTRUCTIONS: @@ I would recommend a function_invocation_limit of at least 3500 ideally (higher is no problem). @@ Setting this should be no problem - Keran's weather system (which has been around several @@ years) asks for 12,500, and M*U*S*H's is set to 25,000. Uncomment out this line to set @@ your function_invocation_limit to 3500 if it's currently set lower: @@ @@ @switch [config(function_invocation_limit)]=<3500,@config/set function_invocation_limit=3500 @@ @@ It's suggested you create a Wizard character specifically for uploading this code. Even if @@ you don't make a special char for it though (beware it overwriting attrs on yourself if you dont!) @@ it still needs to be run by a Wizard. @@ @@ There are various +MAIL options. These can all be set in-game, at any time, via the command @@ +mail/config. You can find them below and change them if you wish, though. @@ @@ If you're upgrading, comment out the lines below which create the objects you already have. @@ @@ You will need to set safer_ufun to "no" in your mush.cnf file in order to use this code. @@ (If you don't want to do that for some reason, you can probably get away with doing something @@ like @SET %VB/*=PUBLIC at the end, instead.) @@ @@ You may also want to alter the way these functions work, to tie into your own ALT system @@ (alternate character). They allow players to read their alts mail, via the '@alt' syntax. @@ @@ FUN.ISALT - is %0 (objid) an alt of %1? @@ This function must do the following things: @@ Return -1 if there is no such player as %1. @@ Return 1 if %1 is the empty string, the same player as %0, or an ALT of %0. @@ Return 0 otherwise. @@ When not returning -1, the register passed as %2 must be set to the objid of the player matched @@ (which is just %0, when %1 is the empty string, or objid(pmatch(%1)) otherwise). This is done via: @@ [ufun(fun.setquiet,%2,objid)] which supresses error messages from the setq(), when %2 is not passed. @@ The default is to be used when there is no ALT system in place, and only accounts for %1 being @@ the same person as %0 or the empty string. &FUN.ISALT me=if(strlen(%1),switch(pmatch(%1),#-*,-1,switch(ufun(fun.setquiet,%2,objid(#$))[objid(#$)],%0,1,0)),ufun(fun.setquiet,%2,%0)1) @@ FUN.ALTS - return all of %0's alts, including %0 himself. The default simply returns %0. &FUN.ALTS me=%0 @@ This @lock controls who can read all sent mail via +READ/SENT, +skim non-alts, etc. @@ Suggested: wiz/roy, perhaps see_all too. @@ @lock/user:see_all me=FLAG^WIZARD|FLAG^ROYALTY @lock/user:see_all me=FLAG^WIZARD|FLAG^ROYALTY|POWER^SEE_ALL @@ Do you want to set yourself QUIET during the installation? 1 to hide the spam, 0 to see it. &quiet`during me=0 @@ STUFF FOR GOD (#1) TO DO: @@ Create a 'mailban' flag, which is set on players (via +mail/ban) to stop them sending mail. @@ @flag/add MAILBAN=,player,wizard mdark,wizard @@ Add attributes used by the mail system: @@ @attr/add/retroactive mailsignature=no_command prefixmatch @@ @attr/add/retroactive mailfailure=no_command prefixmatch @@ When you're happy with how those values are set, simply upload the code using TF's /quote @@ command, or copy and paste it all in. @@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ @@ CODE BEGINS @@ @set me=quiet`before:[hasflag(%!,quiet)] @set me=[if(v(quiet`during),QUIET,!QUIET)] @@ Create the objects. @SET ME=VA:[create(+MAIL Commands)] @SET ME=VB:[create(+MAIL Functions)] @SET ME=VC:[create(+MAIL Messages)] @SET ME=VD:[create(+MAIL Database)] @@ @SET ME=VZ:[pcreate(MailBot,BotMail)][@@(This is for the POP3 server, which isn't in use yet)] @@ The Wiz flag can't be avoided; we need it for objeval() @set %vb=WIZARD @power %va=SQL_OK CAN_NSPEMIT NO_PAY PEMIT_ALL SEE_ALL @power %vb=NO_PAY @dolist %va %vb %vc %vd=@lock/examine ##==%va|=%vb|=%vc ; @set ##=VISUAL @@ @set %vz=WIZARD[@@(This is for the POP3 server, which isn't in use yet)] @@ @lock/interact %vz=$me[@@(This is for the POP3 server, which isn't in use yet)] @dol lattr(me/V?)=@cpattr me/##=%va,%vb,%vc,%vd ; @@ ,%vz @mvattr me/fun.alts=%vb @mvattr me/fun.isalt=%vb @lock/user:see_all %vb=[lock(me/see_all)] @lock/user:see_all me @@ Much, much easier. There will be a function for sending mail from objects (wiz-only, mind you) @lock/use %va=TYPE^PLAYER &INFO %vb=Info about the system, author, etc, are under here. Ex %!/info** for more. &INFO`AUTHOR %vb=Talvo@ElendorMUSH &INFO`CREDITS %vb=Code by Talvo@ElendorMUSH. Based on ElendorMUSH's +mail system, which was written by Lukthil@ElendorMUSH. Help and inspiration from Fraibert@ElendorMUSH and Benigo@ElendorMUSH. Cheetah@M*U*S*H wrote the new regexp used in FUN.PARSEARGS, and I will love him forever for it ;) Walker@M*U*S*H helped a hell of a lot with the regexp'ing in +edit/regexp\[all\]\[i\], and greatly improved its power. &INFO`DESC %vb=An integrated +MAIL and Bulletin Board system for PennMUSH 1.8.1 and higher. &INFO`EMAIL %vb=talvo@talvo.com &INFO`FROM %vb=http://www.talvo.com/ &INFO`NAME %vb=Talvo's +Mail and BB System &INFO`VERSION %vb=1.1 @set %vb/info**=visual @@ Create the MySQL tables. @SQL CREATE TABLE `inbox` ( `id` int(11) NOT NULL default '0', `who` char(20) NOT NULL default '', `status` char(1) NOT NULL default '', `pop3` smallint(6) NOT NULL default '0', PRIMARY KEY (`id`,`who`)) TYPE=MyISAM @SQL CREATE TABLE `mail` ( `id` int(11) NOT NULL auto_increment, `who` varchar(20) NOT NULL default '', `date` bigint(20) NOT NULL default '0', `subject` text NOT NULL, `recip` text NOT NULL, `body` longtext NOT NULL, `sent` tinyint(4) NOT NULL default '0', `sig` text NOT NULL, `forwards` text NOT NULL, PRIMARY KEY (`id`)) TYPE=MyISAM @SQL CREATE TABLE `undo` ( `who` varchar(20) NOT NULL default '', `data` longtext NOT NULL, PRIMARY KEY (`who`)) TYPE=MyISAM @SQL CREATE TABLE `bbinbox` ( `id` int(11) NOT NULL default '0', `bbcode` int(11) NOT NULL default '0', `readers` longtext NOT NULL ,PRIMARY KEY (`id`,`bbcode`)) TYPE=MyISAM @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ MUSH commands... @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ Commands: Done @@ @@ +mail [@] [] . . . . . . . . . . . . . . . . X-H @@ +mail [@] = . . . . . . . . . . . X-H @@ +reply [@] [] . . . . . . . . . . . . X-H @@ +forward [@] [] = . . . . . . . X-H @@ +include [@] [] . . . . . . . . . . . X-H @@ +includes . . . . . . . . . . . . . . . . . . . . . . X-H @@ +include/remove [] . . . . . . . . . . . . . . . X-H @@ +subject . . . . . . . . . . . . . . . . . . . . X-H @@ +address . . . . . . . . . . . . . . . . . . . X-H @@ +cc . . . . . . . . . . . . . . . . . . . . . . X-H @@ +cc/remove . . . . . . . . . . . . . . . . . . X-H @@ - . . . . . . . . . . . . . . . . . . . . . . . . X-H @@ +write[/nospace][/noeval] . . . . . . . . . . . X-H @@ +undo . . . . . . . . . . . . . . . . . . . . . . . . X-H @@ -- . . . . . . . . . . . . . . . . . . . . . . . . . . X-H @@ +send[/nosig][/loud] . . . . . . . . . . . . . . . . . X-H @@ +proof[/examine] . . . . . . . . . . . . . . . . . . . X-H @@ +read[/examine] [@] [] [] . . . . . . X-H @@ +read/sent[/examine] [@] . . . . . . . . . . X-H @@ +read/mark [@] [ [] . . . . . . . . . X-H @@ +skim [@] [] [] . . . . . . . . . . . X-H @@ +delete[/force] . . . . . . . . . . . . . . . X-H @@ +deleted . . . . . . . . . . . . . . . . . . . . . . . X-H @@ +undelete . . . . . . . . . . . . . . . . . . X-H @@ +unread . . . . . . . . . . . . . . . . . . . X-H @@ +clear . . . . . . . . . . . . . . . . . . . . . . . . X-H @@ +edit / . . . . . . . . . . . . . . . . . . X-H @@ +edit/delim . . . . . . . . X-H @@ +edit/regexp[all][i] . . . . X-H @@ +toss . . . . . . . . . . . . . . . . . . . . . . . . X-H @@ +erase[/all] . . . . . . . . . . . . . . . . . . . . . X-H @@ +outbox[/id] [@] . . . . . . . . . . . . . . . . X-H @@ +unmail . . . . . . . . . . . . . . . . . . . . . X-H @@ +mail/ban . . . . . . . . . . . . . . . . . . X-H @@ +mail/unban . . . . . . . . . . . . . . . . . X-H @@ +mail/banned . . . . . . . . . . . . . . . . . . . . . X-H @@ +mail/config [