""" RBhelp.py (C)2008 Don A. Hanlen I make no claims, and take no reponsibility, for use or abuse of this code! I require those who DO use it to cite its source! If this code is used for commercial purposes I expect a (negotiable) cut! This module provides help and information functions for rePYbot(c). """ from random import randint from string import find, lower pattiRand = 10 helpDict = { 'alert' :"The old RepBot's alert function is better implemented using\ FIBS' 'show saved' and 'waitfor' commands IMO.", 'ask' :"'tell %s ask ' Get statistics on user.", 'client' :"When I say 'tell %s...' that means use whatever your client\ requires to chat (not kibitz) with another user.", 'cocoa' :"I've been told you have to 'chat with %s' to use this bot.", 'complain':"'tell %s complain ' Register a complaint about user.\ You may complain IF: You have a ~~saved match with user; You have played user\ in the last day; OR user hase registered a vouch/complaint against you.", 'grok' :"To completely understand something, to BE that thing! It's\ from Robert Heinlein's 'Stranger in a Strange Land'.", 'help' :"'tell %s help ' I have help on (alert, ask, client,\ cocoa, complain, grok, help, home, list, name, random, replist, source, time,\ vouch, weight, whyshout, withdraw, ~~)", 'home' :"I need a 24/7 home!", 'list' :"'tell %s list ' Get an ~~approximate list of user's\ ~~saved matches. There are many reasons why this list may be inaccurate!", 'name' :"Since the original RepBot had a 'p' in it, I added a 'y' in\ the and changed case, making rePYbot (because it's written in Python). You\ can probably get away with 'tell repy', and capitalization is NEVER required!", 'purr' :"You make my heart sing!", 'random' :"You'll get random snippets of information about %s's\ saved~games (and other things), at the suggestion of a higher authority.\ Current odds are 1:10.", 'replist' :"'tell %s replist ' ..get a list of vouches/complaints\ for and by user.", 'source' :"Source code and information may be found at\ (http://users.owt.com/dhanlen/rePYbot.html).", 'time' :"To discourage hacks, %s will not accept commands from a user\ within 2 seconds of each other. This time period will increase with repeated\ hammering. One warning is delivered per timeout (the length of which may\ increase DURING the timeout)!", 'vouch' :"'tell %s vouch ' Register a voucher for user.\ You may vouch IF: You have a ~~saved match with user; You have played user\ in the last day; OR user hase registered a vouch/complaint against you.", 'weight' :"The weight of your vouch/complaint is\ int(log(your_experience+1)). I didn't like those inflated ratings from\ previous repbots.", 'whyshout':"The occasional shouts are either to indicate that %s just\ logged in, or on detection of a question about the old repbot in shouts.\ They serve the purpose of reminding people that this is not Patti's bot,\ nor part of FIBS.", 'withdraw':"'tell %s withdraw ' Withdraw a complaint or vouch.", '~~' :"~~'s in %s output mean that ~saved~game~ information is\ ~~imprecise. Equivalence, not equality. (~ kinda looks like an equivalence\ symbol.)", } snippets = [ "*** The saved-game information parsed by %s comes from\ http://www.fibs.com/savedgames/list.html . ***", "*** The asynchronous snapshot of saved games used by %s may be a couple\ of days out of date. ***", "*** Many saved games have been completed that are listed in %s's\ dbase. ***", "*** Unlimited matches show up as saved games in %s's dbase. ***", "*** Matches saved since the last dbase update won't be listed. ***", "*** If you were playing a match at the instant of the last dbase update,\ it will show up as a saved game.", "*** Lots of saved games do NOT indicate that a user is a dropper! ***", "*** Use this information as the raw data that it is, not as a\ pronouncement of judgement. ***", "*** If you have questions or comments about %s contact don, not Patti! ***", "*** Neither Patti nor FIBS has anything to do with %s. ***", "*** Read\ http://www.fibsboard.com/repbot/repbot-objective-functions-t1920.0.html\ and contribute to the discussion! ***", "*** I'm looking for a 24/7 home. Contact don if you know of one. ***", "*** Your ad here could be here! ***", "*** The use of '~' in my output indicates equivalence, not equality. ***", "*** It seems that, based on looking at saved-games lists as represented\ on FIBS.com, daily, games played and completed within the last day are listed\ as saved.", "*** More information about %s, including source code (under development),\ may be found at: http://users.owt.com/dhanlen/rePYbot.html ***" ] class RBhelp: """ a bunch of help messages and ways to get 'em """ def __init__(self, botName): """ set botName is all! """ self.botName = botName def helpD(self, topic): """ return help on topic """ if helpDict.has_key(lower(topic)): return self.addbotName(helpDict[lower(topic)]) return "*** No information found on %s. 'tell %s help' ***" %( topic, self.botName) def snippet(self): """ randomly (odds are 1:pattiRand) return a random snippet these are (mostly) about the nature of saved-games """ if not randint(0, pattiRand): return self.addbotName(snippets[randint(0, len(snippets)-1)]) return '' def addbotName(self, message): """ return message with bot's name added if necessary """ if find(message, '%s') >= 0: return message %self.botName return message