Esempio n. 1
0
 def say(self, message):
     message = self.emote_handler.transform(
         self.format_handler.transform(inoculate(message)))
     self.message("<font color=blue>%s:</font> %s" %
         (inoculate(self.name), message))
     self.broadcast("<font color=red>%s:</font> %s" %
         (inoculate(self.name), message))
Esempio n. 2
0
    def process(self, http_request):

        service = self.service

        # get the desired name from a cookie
        name = http_request.getCookie(self.name_cookie_key)
        if name is not None:
            name = self.name = next_name(self.chatters, name)
        # or get a default name
        else:
            name = next_name(self.chatters)
        self.name = name
        self.chatters[name] = self

        self.message(
            '<p>You are <font color="blue">%s</font>.</p>' % (
                inoculate(self.name)
            )
        )
        self.broadcast(
            '<p><font color="red">%s</font> enters.</p>' % (
                inoculate(self.name)
            )
        )

        self.goto(self.Chat(self))
Esempio n. 3
0
    def social(self, object = None, modifier = None):

        subject = inoculate(self.name)

        # if the user specified a modifier, it's going to be
        #  the second argument instead of the last, so switch
        #  the variables around (this makes it possible to use
        #  the default argument for the explicit modifier case).
        if modifier is not None:
            object, modifier = modifier, object
        # otherwise, use the implicit modifier
        else:
            modifier = implicit_modifier

        # conjugate the predicate
        if object is None:
            predicate = verb
            predicates = verbs
        else:   
            object = inoculate(object)
            if modifier is None:
                predicate = '%s %s' % (verb, object)
                predicates = '%s %s' % (verbs, object)
            else:
                modifier = inoculate(modifier)
                predicate = '%s %s %s' % (verb, modifier, object)
                predicates = '%s %s %s' % (verbs, modifier, object)

        self.message(template % ('You', predicate))
        self.broadcast(template % (subject, predicates))
Esempio n. 4
0
    def emote(self, message):

        # treat the message
        message = message.strip()
        # implicit punctuation
        if not (
            message.endswith('.') or
            message.endswith('?') or
            message.endswith('!')
        ):
            message = '%s.' % message

        message = self.emote_handler.transform(
            self.format_handler.transform(inoculate(message)))

        self.message("<font color=blue>%s</font> %s" %
            (inoculate(self.name), message))
        self.broadcast("<font color=red>%s</font> %s" %
            (inoculate(self.name), message))
Esempio n. 5
0
import re
from cixar.python.wrap import wrap
from cixar.ish.sh.inoculate import inoculate

EMOTE_URL = ".chat/art/tango"

emote_table = {
  "face-surprise":    ":-O :O 8-O",
  "face-wink":        ";) ;-)",
  "face-smile-big":   ":D :-D =D =-D",
  "face-smile":       ":) :-) =) =-)",
  "face-sad":         ":( :-( =( =-(",
  "face-plain":       ":| :-|",
  "face-glasses":     "8) 8-)",
  "face-devil":       inoculate(">:-D >:D >:-) >:)"),
  "face-crying":      ":'-( :'(",
  "face-angel":       "0:-) 0:)",
}

format_table = {
  "(^|\s)&lt;(https?://\S+) ([^>]+)&gt;(\s|$|.)": '\\1<a target="_blank" href="\\2">\\3</a>\\4',
  "(^|\s)([a-zA-Z1-10]+://\S+)(\s|$|\.)": '\\1<a target="_blank" href="\\2">\\2</a>\\3',
  "(^|\s)\*(\S[^*]+)\*(\s|$|\.)": "\\1<b>\\2</b>\\3",
  "(^|\s)_(\S[^_]+)_(\s|$|\.)": "\\1<u>\\2</u>\\3",
  "(^|\s)/(\S[^/]+)/(\s|$|\.)": "\\1<i>\\2</i>\\3",
  "(^|\s)'(\S[^']+)'(\s|$|\.)": "\\1<tt>\\2</tt>\\3",
}

class EmoteHandler(dict):
  def __init__(self, table):