Re: Lyntin Question
Brazen <odbrazen-/[email protected]> Fri, 7 Aug 2009 09:32:32 -0700 (PDT)
| Newsgroups | gmane.comp.games.mud.client.lyntin |
|---|---|
| Message-ID | <[email protected]> |
Keys to dictionaries must be hashable. In general this means you can only = use unmutable types like string or tuple and cannot use mutable types like = list. Your has_key(sess) is checking the dictionary for a list key, which = raises the error. Also in that same spot you are creating a variable named sess that is a lis= t of one item, the string 'session'. What you actually want to do there is= access the args dictionary to get the value of the key 'session' sess =3D args['session'] -Brazen --- On Thu, 8/6/09, Mac Daddy <[email protected]> wrote: > From: Mac Daddy <[email protected]> > Subject: [lyntin-devl] Lyntin Question > To: [email protected] > Date: Thursday, August 6, 2009, 5:58 AM > Like most new programmers, I am > having difficulty with "hooking." > = > I concede, I am new to Python/Programming, and will likely > reveal that = > in my code. =3D) {so embarrassing} > = > Here is what the code looks like: > = > When I run the code, I get an slew of errors (lyntin > quits), but primarily: > = > TypeError: unhashable type: 'list'=A0 I don't have a > list (at least, I = > don't think I do), in my module, so somewhere the engine is > sending me = > one -- perhaps the spamargs is a list? > = > Anyway, thanks in advance!! > = > = > # Yet another "bot" attempt. it essentially > # just smiles if a player is encountered.=A0 I know, I > know, I can just make > # an "action" for this, but then I wouldn't learn anything > =3D) > # more importantly, I am just trying to learn how to > process the incoming > # text for more advanced usage. > = > import re > from lyntin import exported > from lyntin.modules import modutils > = > commands_dict =3D {} > = > # So far, just putting stuff that I deem minimally > required. > # Here is my dictionary of Variables (only one for now). > = > BotTriggers =3D {"**PLAYER**": "player_check"} > = > # In 3k, I have the created the above tag to show (via > aset) for ALL players > # in their pretitle. > = > def botfilter(args): > =A0 =A0=A0=A0# This takes in mud text, and > filters it, I hope. > =A0 =A0=A0=A0ses =3D ["session"] > =A0 =A0=A0=A0text =3D ["dataadj"] > =A0 =A0=A0=A0# I am not 100% what those mean, > other than what I can infer. > =A0 =A0=A0=A0# Clearly the session, but not > sure the depths of what "dataadj" > =A0 =A0=A0=A0# means. > =A0 =A0=A0=A0# I used a format similar to the > highlight module. > =A0 =A0=A0=A0# I think it runs the text against > the dict list? > =A0 =A0=A0=A0if BotTriggers.has_key(ses): > =A0 =A0 =A0 =A0=A0=A0return > BotTriggers[ses].expand(text) > =A0 =A0=A0=A0return text > = > def expand(text): > =A0 =A0=A0=A0# Again, used the highlight module > as a guide, for matching > =A0 =A0=A0=A0# the text. On a match, I just > want a TRUTH value to be returned. > =A0 =A0=A0=A0# not sure if "m" is the truth > value? > =A0 =A0=A0=A0if text: > =A0 =A0 =A0 =A0=A0=A0trigger =3D > BotTriggers.keys() > =A0 =A0 =A0 =A0=A0=A0trigger.sort() > =A0 =A0 =A0 =A0=A0=A0for m in trigger: > =A0 =A0 =A0 =A0 =A0 > =A0=A0=A0BotTriggers[m].finditer(text) > =A0 =A0=A0=A0return m > = > def aufgehts(ses, args, input): > =A0 =A0=A0=A0# This is the primary command > function. > =A0 =A0=A0=A0if BotTriggers: > =A0 =A0 =A0 > =A0=A0=A0exported.lyntin_command("smile") > =A0 =A0 =A0 > =A0=A0=A0exported.write_message("Active!!") > = > commands_dict["aufgehts"] =3D (aufgehts) > = > def load(): > =A0 > =A0=A0=A0modutils.load_commands(commands_dict) > =A0 > =A0=A0=A0exported.hook_register("mud_filter_hook", > botfilter, 99) > = > def unload(): > =A0 > =A0=A0=A0modultils.unload_commands(commands_dict) > =A0 > =A0=A0=A0exported.hook_unregister("mud_filter_hook", > botfilter) > = > -------------------------------------------------------------------------= ----- > Let Crystal Reports handle the reporting - Free Crystal > Reports 2008 30-Day = > trial. Simplify your report design, integration and > deployment - and focus on = > what you do best, core application coding. Discover what's > new with = > Crystal Reports now.=A0 http://p.sf.net/sfu/bobj-july > _______________________________________________ > Lyntin-devl mailing list > [email protected] > https://lists.sourceforge.net/lists/listinfo/lyntin-devl > = = ---------------------------------------------------------------------------= --- Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day = trial. Simplify your report design, integration and deployment - and focus = on = what you do best, core application coding. Discover what's new with = Crystal Reports now. http://p.sf.net/sfu/bobj-july