@@ +Mail and BB system using MySQL @@ for PennMUSH 1.8.1p9 and higher @@ @@ ** NOW REQUIRES 1.8.1p9 OR 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 @@ mike@keyboardzombie.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 also has an accompanying POP3 server, which means you can download your mail from the MUSH into @@ a mail client like Outlook Express/Thunderbird, etc, or even set up web-based systems like @@ SquirrelMail to check it. SMTP (for sending mail) and NNTP (for downloading BB posts) may be @@ added at some point in the future; if you'd be interested in having them, let me know. @@ @@ All the commands will be made "global", via @command/add and @hook, with the exception of @@ '-' (short for +write) and '--' (short for +send), b/c it's not possible with softcode. @@ @@ 4 MySQL tables are used (named inbox, bbinbox, undo and mail), and are created by the code. @@ You can give the tables a prefix - the default is 'mm_' - by setting the appropriate config @@ version. See below for that. Tested on MySQL version 4.0.24 @@ @@ The latest version of this code (and help-files) are available from www.keyboardzombie.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. He must also be set NO_PAY, or things will fail. @@ @@ 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 (probably best, as @@ a few are used during the setup, particularly the db_prefix option). @@ @@ 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.) @@ @@ (Keep reading 'til it says not to; there's some code among these comments because you @@ need to do special things with it before/after the installation.:) @@ @@ You may also want to alter the way FUN.ALTS works, to tie into your own ALT system @@ (alternate character). It allows players to read their alts mail, via the '@' syntax. @@ PLEASE NOTE that even if you don't have an alt system, you should still set the default @@ value. Do -not- delete this totally! @@ @@ The default assumes players alts are stored on them in an attr named ALTS, which contains objids, not dbrefs. @@ FUN.ALTS - return all of %0's alts, including %0 himself (objids, not dbrefs). The default simply returns %0. &FUN.ALTS me=setunion(get(%0/ALTS),%0) @@ This @lock controls who can read all sent mail via +READ/SENT, +skim non-alts, etc. @@ Suggested: wiz/roy, perhaps see_all too. @@ If you're worried about security/privacy, lock this to #false instead, so only @@ a player (and his/her alts) can read his mail, and staff can't. @@ @lock/user:see_all me=#false @@ @lock/user:see_all me=FLAG^WIZARD|FLAG^ROYALTY @lock/user:see_all me=FLAG^WIZARD|FLAG^ROYALTY|POWER^SEE_ALL @@ Who can use the sendmail() function (%vb/fun.sendmail)? Note that anyone using this function @@ can send mail as /any player/ on the game - it's intended for staff-owned automated/coded systems, @@ not for players. @@ @lock/user:sendmail me=FLAG^WIZARD&(TYPE^THING|TYPE^EXIT|TYPE^ROOM) @lock/user:sendmail me=FLAG^WIZARD @@ 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 (to be run just after you upload this code): @@ 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 (you'll need to put these into an @startup on @@ #1, or another low-dbref object, so that they run straight away when the MUSH restarts): @@ @attr/access/retroactive mailsignature=no_command prefixmatch @@ @attr/access/retroactive mailfailure=no_command prefixmatch @@ @attr/access/retroactive bbignore=no_command mortal_dark wizard @@ Set up the global SENDMAIL() function. (This also needs adding into an @startup, like @@ the @attrs above do. You may wish to manually put the dbref for %vb in place of '[get(*MailBot/VB)]') @@ @function/preserve sendmail=[get(*MailBot/VB)],FUN.SENDMAIL,4,5 @@ For the POP3/NNTP servers.. You may also wish to change the MailBot character's @@ password (the default is BotMail), but make sure you record the new one for the servers. @@ @newpassword *MailBot=YourNewPasswordHere! @@ Make all the commands global (only God can @command/add). @@ This should be in God's @startup somewhere. It /does not work/ pasted straight in from your client. @@ @assert cand(numversion(),gte(numversion(),1008001006)); @dolist bbcreate bbdelete bbinfo bblist bbscan bbignore bbcatchup bbleave address cc reply include includes subject write undo send proof draft edit unread read skim undelete delete deleted expunge clear toss erase outbox unmail={@command/add +## ; @hook/override +##=[get(*MailBot/VA)],cmd.##} ; @dolist bbadmin bbauthor bbdesc bblock bbheader bbtimeout forward mail mgroup={@command/add/eqsplit +## ; @hook/override +##=[get(*MailBot/VA)],cmd.##} @@ If you're trying to install this on a pre-1.8.1p9 game, you brought this flashing ANSI on yourself. :P think if(cand(numversion(),gte(numversion(),1008001009)),Beginning installation...,ansi(hgfu,THIS SYSTEM REQUIRES AT LEAST PENNMUSH 1.8.1p9 IN ORDER TO WORK CORRECTLY. YOU APPEAR TO BE USING AN EARLIER VERSION. IT'S HIGHLY RECOMMENDED THAT YOU UPGRADE YOUR COPY OF PENNMUSH BEFORE YOU INSTALL OR USE THIS CODE.)) @@ 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 (and then run the 'Stuff for God' code afterwards). You @@ can stop reading, now, unless you want to manually change the config options below, or you're @@ upgrading and need to comment out the object-creation lines below :) @@ @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ @@ CODE BEGINS @@ @set me=quiet`before:[hasflag(%!,quiet)] @set me=[if(v(quiet`during),QUIET,!QUIET)] @@ Create the objects. Comment these lines out if you're upgrading. @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)] @@ If you're upgrading, you'll want to wipe the old objects and start fresh (don't wipe %vd!): @@ @dolist %VA %VB %VC %VZ=@wipe ## @@ 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 @lock/interact %vz=$me @set %vz=!ANSI !COLOR QUIET NO_WARN @power %vz=NO_PAY HIDE IDLE QUEUE CAN_NSPEMIT @set %va=LOUD @set %vb=LOUD @dolist setdiff(lattr(me/V?),VP)=@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 @lock/user:sendmail %vb=[lock(me/sendmail)] @lock/user:sendmail me @@ Much, much easier. There will be a function for sending mail from objects (wiz-only, mind you) @lock/use %va=TYPE^PLAYER @desc %va=ufun(%vb/describe) @desc %vb=[repeat(=,78)]%r[iter(lattr(me/info`*),rest(%i0,`) - [u(%i0)],,%r)]%r[repeat(-,78)]%rFor more info, see HELP MAIL VERSION and HELP MAIL CREDITS%r[repeat(=,78)] &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. See HELP MAIL CHANGES for full change-list with credits. &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=2.3 @set %vb/info**=visual @@ Here for safe keeping: @@ (?\:/n(?\:o(?\:e(?\:v(?\:al?)?)?)?)?)? @@ @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @@ 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 @@ +draft . . . . . . . . . . . . . . . . . . . . . . . . X-H @@ +read[/examine] [@] [] [] . . . . . . X-H @@ +read/sent[/examine] [@] . . . . . . . . . . X-H @@ +read/mark [@] [ [] . . . . . . . . . X-H @@ +bbread / . . . . . . . . . . . . . . . . . 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 [