Merge lp:~stefanor/ibid/coffee-374028 into lp:~ibid-core/ibid/old-trunk-pack-0.92

Proposed by Stefano Rivera
Status: Superseded
Proposed branch: lp:~stefanor/ibid/coffee-374028
Merge into: lp:~ibid-core/ibid/old-trunk-pack-0.92
Diff against target: None lines
To merge this branch: bzr merge lp:~stefanor/ibid/coffee-374028
Reviewer Review Type Date Requested Status
Michael Gorven Approve
Review via email: mp+6917@code.launchpad.net

This proposal supersedes a proposal from 2009-05-30.

This proposal has been superseded by a proposal from 2009-05-31.

To post a comment you must log in.
Revision history for this message
Stefano Rivera (stefanor) wrote : Posted in a previous version of this proposal

Removed russell's coffee hack

Revision history for this message
Stefano Rivera (stefanor) wrote :

Removed russell's coffee hack.

Excuse first merge request - had a bad commit

Revision history for this message
Michael Gorven (mgorven) wrote :

 review approve

review: Approve
lp:~stefanor/ibid/coffee-374028 updated
647. By Stefano Rivera

Proper Ibid-style call_later infrastructure for coffee, et al.

648. By Stefano Rivera

Unicodeism

649. By Stefano Rivera

Return the IDelayedCall instance, so the delayed call can be cancelled

650. By Stefano Rivera

Logging typo + comment

651. By Stefano Rivera

A wider set of coffee starting responses

652. By Stefano Rivera

More "pot on" responses

Unmerged revisions

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'ibid/plugins/misc.py'
2--- ibid/plugins/misc.py 2009-05-01 12:17:57 +0000
3+++ ibid/plugins/misc.py 2009-05-30 22:34:59 +0000
4@@ -1,43 +1,61 @@
5 from time import sleep
6-
7+import logging
8+
9+from twisted.internet import reactor
10+
11+import ibid
12 from ibid.plugins import Processor, match
13 from ibid.config import IntOption
14 from ibid.utils import ibid_version
15
16 help = {}
17+log = logging.getLogger('plugins.misc')
18
19 help['coffee'] = u"Times coffee brewing and reserves cups for people"
20 class Coffee(Processor):
21 u"""coffee (on|please)"""
22 feature = 'coffee'
23
24- pot = None
25+ pots = {}
26
27 time = IntOption('coffee_time', u'Brewing time in seconds', 240)
28 cups = IntOption('coffee_cups', u'Maximum number of cups', 4)
29
30+ def coffee_announce(self, source, channel):
31+ try:
32+ ibid.dispatcher.send({
33+ 'reply': u"Coffee's ready for %s!" % u', '.join(self.pots[(source, channel)]),
34+ 'source': source,
35+ 'target': channel,
36+ })
37+ del self.pots[(source, channel)]
38+ except:
39+ log.exception('Coffee callback')
40+
41 @match(r'^coffee\s+on$')
42 def coffee_on(self, event):
43- # Hi ... race condition.
44- if self.pot:
45+ if (event.source, event.channel) in self.pots:
46 event.addresponse(u"There's already a pot on")
47 return
48
49- self.pot = [event.sender['nick']]
50- sleep(self.time)
51- event.addresponse(u"Coffee's ready for %s!", u', '.join(self.pot))
52- self.pot = None
53+ self.pots[(event.source, event.channel)] = [event.sender['nick']]
54+ reactor.callLater(float(self.time), self.coffee_announce, event.source, event.channel)
55+
56+ event.addresponse({'action': True, 'reply': u'flips the salt-timer'})
57
58 @match('^coffee\s+(?:please|pls)$')
59 def coffee_accept(self, event):
60- if not self.pot:
61+ if (event.source, event.channel) not in self.pots:
62 event.addresponse(u"There isn't a pot on")
63
64- elif len(self.pot) >= self.cups:
65+ elif len(self.pots[(event.source, event.channel)]) >= self.cups:
66 event.addresponse(u"Sorry, there aren't any more cups left")
67
68+ elif event.sender['nick'] in self.pots[(event.source, event.channel)]:
69+ event.addresponse(u"Now now, we don't want anyone getting caffine overdoses")
70+
71 else:
72- self.pot.append(event.sender['nick'])
73+ self.pots[(event.source, event.channel)].append(event.sender['nick'])
74 event.addresponse(True)
75
76 help['version'] = u"Show the Ibid version currently running"
77
78=== modified file 'scripts/ibid-plugin'
79--- scripts/ibid-plugin 2009-05-05 07:58:29 +0000
80+++ scripts/ibid-plugin 2009-05-30 22:07:09 +0000
81@@ -52,6 +52,7 @@
82 class TestSource(dict):
83 type = 'test'
84 permissions = []
85+ supports = []
86
87 ibid.sources[u'test_source'] = TestSource()
88

Subscribers

People subscribed via source and target branches