Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- features['braai'] = {
- 'description': u'Braais for people',
- 'categories': ('fun', 'monitor',),
- }
- class Braai(Processor):
- usage = u'braai (on|please)'
- feature = ('braai',)
- placesOnGrid = {}
- time = IntOption('braai_time', u'Brewing time in seconds', 900)
- spaces = IntOption('grid_spaces', u'Maximum number of cups', 16)
- def braai_announce(self, event):
- event.addresponse(u"Braai's ready for %s!",
- human_join(self.pots[(event.source, event.channel)]))
- del self.placesOnGrid[(event.source, event.channel)]
- @match(r'^braai\s+on$')
- def braai_on(self, event):
- if (event.source, event.channel) in self.placesOnGrid:
- if len(self.placesOnGrid[(event.source, event.channel)]) >= self.spaces:
- event.addresponse(u"There's already a braai on, and it's all reserved")
- elif event.sender['nick'] in self.pots[(event.source, event.channel)]:
- event.addresponse(u"You already have a braai on the go")
- else:
- event.addresponse(u"There's already a braai on. If you ask nicely, maybe you can have a bite")
- return
- self.placesOnGrid[(event.source, event.channel)] = [event.sender['nick']]
- ibid.dispatcher.call_later(self.time, self.braai_announce, event)
- event.addresponse(choice((
- u'puts the braai on',
- u'gets a beer',
- )), action=True)
- @match('^braai\s+(?:please|pls)$')
- def braai_accept(self, event):
- if (event.source, event.channel) not in self.pots:
- event.addresponse(u"There isn't a braai on")
- elif len(self.placesOnGrid[(event.source, event.channel)]) >= self.spaces:
- event.addresponse(u"Sorry, out of meat")
- elif event.sender['nick'] in self.placesOnGrid[(event.source, event.channel)]:
- event.addresponse(u"Now now, we don't want anyone eating too much")
- else:
- self.placesOnGrid[(event.source, event.channel)].append(event.sender['nick'])
- event.addresponse(True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement