~ibid-core/ibid/old-trunk-1.6

« back to all changes in this revision

Viewing changes to ibid/plugins/memo.py

  • Committer: Tarmac
  • Author(s): Keegan Carruthers-Smith
  • Date: 2011-03-23 16:11:13 UTC
  • mfrom: (1015.6.8 named-groups-656201)
  • Revision ID: ibid-lp-lander@rivera.za.net-20110323161113-vzgpclmucy8fxyzi
Added named arguments to the match decorator.
Author: Keegan Carruthers-Smith
Merge Request: http://code.launchpad.net/~keegan-csmith/ibid/named-groups-656201/+merge/51159
Approved by: Stefano Rivera, Max Rabkin
Fixes LP: #656201

Show diffs side-by-side

added added

removed removed

Lines of Context:
151
151
            'source': to.source,
152
152
        })
153
153
 
154
 
    @match(r'^(?:delete|forget)\s+(?:my\s+)?'
155
 
            r'(?:(first|last|\d+(?:st|nd|rd|th)?)\s+)?' # 1st way to specify number
156
 
            r'(?:memo|message|msg)\s+'
157
 
            r'(?(1)|#?(\d+)\s+)?' # 2nd way
158
 
            r'(?:for|to)\s+(.+?)(?:\s+on\s+(\S+))?$')
 
154
    @match(r'(?:delete|forget) (?:my )?'
 
155
            r'(?:(?P<num>first|last|\d+(?:st|nd|rd|th)?) )?' # 1st way to specify number
 
156
            r'(?:memo|message|msg) '
 
157
            r'(?(1)|#?{num:digits} )?' # 2nd way
 
158
            r'(?:for|to) (?P<who>.+?)(?: on {source:chunk})?')
159
159
    @authorise(fallthrough=False)
160
 
    def forget(self, event, num1, num2, who, source):
 
160
    def forget(self, event, num, who, source):
161
161
        if not source:
162
162
            source = event.source
163
163
        else:
164
164
            source = source.lower()
165
 
        number = num1 or num2 or 'last'
 
165
        number = num or 'last'
166
166
        number = number.lower()
167
167
        if number == 0:
168
168
            # Don't wrap around to last message, that'd be unexpected