;ς = ΔDc@sΠdkiZdkiZdkiZdkiZdkTdk i Z dk i Z dk iZed„eiiƒZeiZde ifd„ƒYZeiiiidƒZdeifd„ƒYZeZdS(N(s*cCs |iƒ S(N(sssisalnum(ss((s./WordStats/plugin.pys'ss WordStatsDBcBs†tZd„Zd„Zd„Zd„Zd„Zd„Zd„Zd„Z d „Z d „Z d „Z d „Z d „Zd„ZRS(NcOs)tiƒ|_tii|||ŽdS(N( sircutilssIrcDictsselfs channelWordsspluginss ChannelUserDBs__init__sargsskwargs(sselfsargsskwargs((s./WordStats/plugin.pys__init__,scCs"|iotii|ƒndS(N(sselfs channelWordsspluginss ChannelUserDBsclose(sself((s./WordStats/plugin.pysclose0s cCsBg}x1|iƒD]#\}}|id||fƒqW|SdS(Ns%s:%s(sLsvs iteritemsswordscountsappend(sselfsvscountswordsL((s./WordStats/plugin.pys serialize4s  cCsŸtƒ}x‹|D]ƒ}|idƒ\}}t|ƒ}|||<||i jotƒ|i |`s(sappends_[1]sselfs iteritemsschansidsdsircutilss nickEqualschannelswordsLsutilsssortBysnsreverse( sselfschannelswordsnsdschansLs_[1]sid((s./WordStats/plugin.pys getTopUsers]s g  cCsa|i||dƒ}d}x9|D]1\}}|d7}||jo||fSq"q"Wt ‚dS(Nii( sselfs getTopUsersschannelswordsLsnssomeIdscountsidsKeyError(sselfschannelsidswordscountsLsnssomeId((s./WordStats/plugin.pysgetRankAndNumberes   cCs‹||ijoh|i|] Keeps stats on in . is only necessary if the message isn't sent in the channel itself. s/ must not contain non-alphanumeric chars.N( swordsstripsnonAlphaNumericsircserrorsselfsdbsaddWordschannels replySuccess(sselfsircsmsgsargsschannelsword((s./WordStats/plugin.pysadd½s  s channeldbssomethingWithoutSpacescCss|ii|ƒ}|oI||jo!|ii||ƒ|iƒqo|i t d|ƒƒn|i dƒdS(s—[] Removes from the list of words being tracked. If is not specified, uses current channel. s2%q doesn't look like a word I am keeping stats on.s*I am not currently keeping any word stats.N( sselfsdbsgetWordsschannelswordsswordsdelWordsircs replySuccessserrorsformat(sselfsircsmsgsargsschannelswordswords((s./WordStats/plugin.pysremoveΛs cCs| o| oN|ii|ƒ}|o td|ƒ}|i |ƒq|i dƒdSn₯|o|o’y|ii ||i |ƒ}Wn-tj o!|itd|ƒƒdSnX|o/td|i||dfƒ}|i |ƒq|itd||ƒƒnυ|ti|ii|ƒƒjo|ii||ƒ}|djo|i td |ƒƒdSn|id |ƒ}y7tii|iƒ} |ii|| |ƒ\}}Wn+ttfj ot } t }t }nXtd |ƒ}g} xž|ii#|||ƒD]„\}}|| jo t }ny2tii%|ƒi} | i'td | |ƒƒWqtj o | i'td d |ƒƒqXqWtdt(| ƒ|f|td|ƒfƒ} |ii*|ƒ} |t j o.td|| |f|td|ƒfƒ}nd}td| | |ƒ} |i | ƒnΐ|o|itd|ƒƒnŸyogi'}|ii,||i ƒD]"\}}|td||ƒƒq‡~} | i/ƒ|i td| ƒƒWn,tj o |itd|iƒƒnXdS(s.[] [] [] With no arguments, returns the list of words that are being monitored for stats. With alone, returns all the stats for that user. With alone, returns the top users for that word. With and , returns that user's stat for that word. is only needed if not said in the channel. (Note: if only one of or is given, is assumed first and only if no stats are available for that word, do we assume it's .) s$I am currently keeping stats for %L.s*I am not currently keeping any word stats.NsI'm not keeping stats on %s.s%s has said %q %n.stimes%s has never said %q.is?I'm keeping stats on %s, but I haven't seen it in this channel.srankingDisplays%qers%s: %isunregistered users#Top %n (out of a total of %n seen):s%qs& You are ranked %i out of %n with %n.ss%s %L.%ssJ%q doesn't look like a word I'm keeping stats on or a user in my database.s%q: %is%LsI have no wordstats for %s.(0suserswordsselfsdbsgetWordsschannelswordssformatsssircsreplys getWordCountsidscountsKeyErrorserrorsnamesWordDictsfromkeyssgetTotalWordCountstotals registryValuesnsircdbsuserss getUserIdsmsgsprefixsgetRankAndNumbersranksnumbers ValueErrorsNoneserssLs getTopUserssuseridsgetUsersusernamesappendslensrets getNumUserss_[1]sgetUserWordCountsswscssort(sselfsircsmsgsargsschannelsuserswordsrankstotalsidsretsusernamesuserssLsnumberswordsscountscserssuseridsns_[1]sssw((s./WordStats/plugin.pys wordstatsέs|   "   "    "' ( K s otherUserslowered(s__name__s __module__sTruesnoIgnores__init__sdies callCommands doPrivmsgsaddswrapsremoves wordstatssoptionals additional(((s./WordStats/plugin.pys WordStatss      L(s supybot.confsconfs supybot.ircdbsircdbs supybot.utilssutilss supybot.worldsworldssupybot.commandsssupybot.pluginsspluginsssupybot.ircutilssircutilsssupybot.callbackss callbackssfiltersstrscharssnonAlphaNumericsInsensitivePreservingDictsWordDicts ChannelUserDBs WordStatsDBssupybots directoriessdatasdirizesfilenamesPlugins WordStatssClass( sircdbs WordStatssutilssnonAlphaNumericsfilenames callbackssconfspluginssWordDictsworlds WordStatsDBsClasssircutils((s./WordStats/plugin.pys?s        p‘