1 # -*- coding: utf-8 -*-
3 # Copyright (c) 2012, François Revol
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
9 # * Redistributions of source code must retain the above copyright notice,
10 # this list of conditions, and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright notice,
12 # this list of conditions, and the following disclaimer in the
13 # documentation and/or other materials provided with the distribution.
14 # * Neither the name of the author of this software nor the name of
15 # contributors to this software may be used to endorse or promote products
16 # derived from this software without specific prior written consent.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 # ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22 # LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 # SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 # INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 # CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 # POSSIBILITY OF SUCH DAMAGE.
31 import supybot
.conf
as conf
32 import supybot
.utils
as utils
33 from supybot
.commands
import *
34 import supybot
.callbacks
as callbacks
35 import supybot
.log
as log
41 class Haiku(callbacks
.Plugin
):
42 def __init__(self
, irc
):
46 fortunes
= open("/home/revol/devel/haiku/trunk/data/system/data/fortunes/Haiku", "r")
52 self
.fortunes
.append(fortune
)
58 self
.__parent
= super(Haiku
, self
)
59 self
.__parent
.__init
__(irc
)
61 def error(self
, irc
, msg
, args
):
64 Returns the code and value for the given <error> value or code.
69 raise callbacks
.ArgumentError
72 if arg
in errors
.errors
:
73 err
= errors
.errors
[arg
]
79 irc
.errorInvalid('argument', arg
, Raise
=True)
80 for e
in errors
.errors
:
81 if errors
.errors
[e
]['value'] == i
:
82 err
= errors
.errors
[e
]
85 irc
.reply("Unknown error '%s'" % (arg
))
89 r
= "%s = %s = 0x%x (%d): %s" % (key
, expr
, int(value
), value
, err
['str'])
92 def haiku(self
, irc
, msg
, args
):
95 Returns a random haiku.
98 if len(self
.fortunes
) > 0:
99 h
= self
.fortunes
[int(random
.random() * len(self
.fortunes
))].split('\n')
102 irc
.reply(l
, prefixNick
= False)
104 irc
.reply("No haiku found")
106 def reportbugs(self
, irc
, msg
, args
):
109 Returns some infos on reporting bugs.
115 t
= "If you think there is a bug in Haiku, please report a bug so we can remember to fix it. cf. http://dev.haiku-os.org/wiki/ReportingBugs"
116 irc
.reply(t
, to
= to
)
118 def patchwanted(self
, irc
, msg
, args
):
121 Returns some infos on submitting patches.
127 t
= "Haiku is Free Software, therefore you can fix it yourself and send a patch, which would likely be very appreciated. cf. http://dev.haiku-os.org/wiki/SubmittingPatches"
128 irc
.reply(t
, to
= to
)
130 def download(self
, irc
, msg
, args
):
133 Returns download links.
139 t
= "Current release: http://www.haiku-os.org/get-haiku - Nightly builds: http://haiku-files.org/haiku/development/"
140 irc
.reply(t
, to
= to
)
142 def dl(self
, irc
, msg
, args
):
145 Returns download links.
147 return self
.download(irc
, msg
, args
)
149 def vi(self
, irc
, msg
, args
):
159 irc
.reply(t
, to
= to
)
161 def emacs(self
, irc
, msg
, args
):
171 irc
.reply(t
, to
= to
)
173 def bored(self
, irc
, msg
, args
):
182 t
= "Why won't you get on some easy tasks then? http://dev.haiku-os.org/wiki/EasyTasks"
183 irc
.reply(t
, to
= to
)
185 def jlg(self
, irc
, msg
, args
):
188 Praise Jean-Louis Gassée.
194 t
= "Jean-Louis Gassée, such a Grand Fromage!"
195 irc
.reply(t
, to
= to
)
197 def basement(self
, irc
, msg
, args
):
209 to
= ' and '.join([', '.join(args
[:-1]), args
[-1]])
211 t
= "sends %s to BGA's basement and chains %s to a post in front of a computer. Get to work!" % (to
, who
)
212 irc
.reply(t
, action
= True)
214 def trout(self
, irc
, msg
, args
):
217 Puts someone back to his place.
223 to
= ' and '.join([', '.join(args
[:-1]), args
[-1]])
224 t
= "slaps %s with a trout." % (to
)
225 irc
.reply(t
, action
= True)
227 def plop(self
, irc
, msg
, args
):
237 irc
.reply(t
, to
= to
)
239 def shibboleet(self
, irc
, msg
, args
):
245 irc
.reply("http://xkcd.com/806/ Tech Support")
249 # vim:set shiftwidth=4 softtabstop=4 expandtab textwidth=79: