Total Complexity | 3 |
Total Lines | 13 |
Duplicated Lines | 0 % |
1 | import re |
||
6 | class LastCommand(BotCommand): |
||
7 | command = '/last' |
||
8 | |||
9 | def default(self, message): |
||
10 | match = re.match('(/last)( (?P<howmany>\d+))?', message.text) |
||
11 | howmany = int(match.groupdict(5)['howmany']) |
||
12 | tab = self._db.get_or_create_tab(message.chat.id)[0] |
||
13 | last_entries = u'\n'.join([ |
||
14 | u'*{:7.2f}* {} for {}'.format(entry.amount, entry.date.humanize(), entry.reason) |
||
15 | for entry in tab.entries[:howmany]]) |
||
16 | if not last_entries: |
||
17 | last_entries = 'No entries!' |
||
18 | self.bot.say(message, last_entries, markdown=True) |
||
19 |