1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
|
# -*- Encoding: UTF-8 -*-
###
# Copyright (c) 2008-2009, Elián Hanisch
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
###
import supybot.conf as conf
import supybot.registry as registry
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
# a bool that specifies whether the user identified himself as an advanced
# user or not. You should effect your configuration by manipulating the
# registry as appropriate.
from supybot.questions import expect, anything, something, yn
conf.registerPlugin('Factos', True)
class ValidLanguages(registry.OnlySomeStrings):
validStrings = ('en', 'es')
class SpaceSeparatedListOfLanguages(registry.SpaceSeparatedListOf):
Value = ValidLanguages
class UnicodeString(registry.String):
def setValue(self, s):
super(UnicodeString, self).setValue(s.decode('utf-8'))
def __str__(self):
s = self.value.encode('utf-8')
if self._needsQuoting(s):
s = repr(s)
return s
Factos = conf.registerPlugin('Factos')
# edit limits
conf.registerChannelValue(Factos, 'allow',
registry.Boolean(True, """If True any user can edit the database."""))
conf.registerChannelValue(Factos.allow, 'query',
registry.Boolean(True, """If True any user can edit the database in private if present in a
channel with allow=True."""))
# behaviour
conf.registerChannelValue(Factos, 'quiet',
registry.Boolean(False, """Setting this to True will make the bot less verbose, it won't reply if a fact doesn't exist.
Default False."""))
#conf.registerChannelValue(Factos, 'forceLocal', TODO
# registry.Boolean(False, """When this is set to True, Facts created will be always local and
# won't be inserted in the global table."""))
#conf.registerChannelValue(Factos, 'forceModes', TODO
# registry.Boolean(False, """ """))
# notices and alerts
conf.registerGlobalValue(Factos, 'noticeInChannels',
registry.SpaceSeparatedListOfStrings('', """Determines in which channels to notify about fact
changes, empty string disables it. Default ''"""))
conf.registerChannelValue(Factos, 'alertInChannels',
registry.SpaceSeparatedListOfStrings('', """Determines which channels to alert when a fact
with the 'alert' mode is called, empty string disables it. Default ''"""))
conf.registerChannelValue(Factos.alertInChannels, 'message',
UnicodeString('$nick llamó ${fact_name} en $channel (${*})', """Determines the message used when alerting
about a fact."""))
# repeat protection
conf.registerChannelValue(Factos, 'repeatProtection',
registry.Boolean(True, """This setting will enable protection against fact repeating. Default True."""))
conf.registerGlobalValue(Factos.repeatProtection, 'timeout',
registry.Integer(120, """Time in seconds it must pass before reasking for a fact. Default 300."""))
conf.registerGlobalValue(Factos.repeatProtection, 'msglimit',
registry.Integer(15, """Number of messages must occur in a channel before reasking for a fact.
Mainly for busy channels where long timeouts would mean too much scrolling. Default 20."""))
conf.registerChannelValue(Factos.repeatProtection, 'collision',
registry.Boolean(True, """This setting will enable ignoring facts called almost at the same
time. This is when two or more users see somebody's question and ask the same fact, they
'collide'. Default True."""))
# l10n
conf.registerGroup(Factos, 'l10n')
conf.registerChannelValue(Factos.l10n, 'language',
ValidLanguages('es', """Default language used by the plugin globally or in a channel."""))
conf.registerGlobalValue(Factos.l10n, 'enabledLanguages',
SpaceSeparatedListOfLanguages(['es', 'en'], """List of language which regexp's will be compiled."""))
# databases
conf.registerGroup(Factos, 'sqlite')
conf.registerGlobalValue(Factos.sqlite, 'database',
registry.String('Factos',
"""Name for sqlite database. It will be saved as 'data/name.sqlite.db' in bot's path."""))
conf.registerChannelValue(Factos.sqlite, 'default',
registry.String('default',
""" """))
conf.registerChannelValue(Factos.sqlite, 'fallback',
registry.String('',
""" """))
# vim:set shiftwidth=4 tabstop=4 softtabstop=4 expandtab textwidth=100:
|