Skip to content

Commit d1774b5

Browse files
committed
Merge branch 'issue128' into fl
2 parents e726503 + 2344493 commit d1774b5

File tree

3 files changed

+27
-10
lines changed

3 files changed

+27
-10
lines changed

nabsurprised/locale/fr_FR/LC_MESSAGES/django.po

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ msgid ""
88
msgstr ""
99
"Project-Id-Version: PACKAGE VERSION\n"
1010
"Report-Msgid-Bugs-To: \n"
11-
"POT-Creation-Date: 2020-02-12 14:21+0100\n"
11+
"POT-Creation-Date: 2021-07-17 15:01+0200\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
1414
"Language-Team: LANGUAGE <[email protected]>\n"
@@ -84,32 +84,37 @@ msgstr "Fréquence des humeurs"
8484

8585
#: templates/nabsurprised/settings.html:13
8686
msgctxt "Surprise frequency"
87+
msgid "Rarely"
88+
msgstr "Rarement"
89+
90+
#: templates/nabsurprised/settings.html:14
91+
msgctxt "Surprise frequency"
8792
msgid "Sometimes"
8893
msgstr "De temps en temps"
8994

90-
#: templates/nabsurprised/settings.html:14
95+
#: templates/nabsurprised/settings.html:15
9196
msgctxt "Surprise frequency"
9297
msgid "Often"
9398
msgstr "Souvent"
9499

95-
#: templates/nabsurprised/settings.html:15
100+
#: templates/nabsurprised/settings.html:16
96101
msgctxt "Surprise frequency"
97102
msgid "Very often"
98103
msgstr "Très souvent"
99104

100-
#: templates/nabsurprised/settings.html:16
105+
#: templates/nabsurprised/settings.html:17
101106
msgctxt "Surprise frequency"
102-
msgid "Disabled"
107+
msgid "Never"
103108
msgstr "Jamais"
104109

105-
#: templates/nabsurprised/settings.html:22
110+
#: templates/nabsurprised/settings.html:23
106111
msgid "Surprise me now!"
107112
msgstr "Chatouille"
108113

109-
#: templates/nabsurprised/settings.html:29
114+
#: templates/nabsurprised/settings.html:30
110115
msgid "Save"
111116
msgstr "Enregistrer"
112117

113-
#: templates/nabsurprised/settings.html:30
118+
#: templates/nabsurprised/settings.html:31
114119
msgid "Reset"
115120
msgstr "Annuler"

nabsurprised/nabsurprised.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,14 @@
88

99

1010
class NabSurprised(NabRandomService):
11+
RARELY, SOMETIMES, OFTEN, VERY_OFTEN = 30, 50, 125, 250
12+
FREQUENCY_SECONDS = {
13+
RARELY: 10800,
14+
SOMETIMES: 7200,
15+
OFTEN: 3600,
16+
VERY_OFTEN: 1200,
17+
}
18+
1119
NLU_INTENTS = [
1220
"nabsurprised/surprise",
1321
"nabsurprised/carrot",
@@ -61,7 +69,10 @@ async def _do_perform(self, expiration, lang, type):
6169
await self.writer.drain()
6270

6371
def compute_random_delta(self, frequency):
64-
return (256 - frequency) * 60 * (random.uniform(0, 255) + 64) / 128
72+
key = frequency
73+
if key not in NabSurprised.FREQUENCY_SECONDS:
74+
key = NabSurprised.RARELY
75+
return random.uniform(0, NabSurprised.FREQUENCY_SECONDS[key])
6576

6677
async def process_nabd_packet(self, packet):
6778
if packet["type"] == "asr_event":

nabsurprised/templates/nabsurprised/settings.html

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ <h5 class="card-title">{% trans "Surprise" %}</h5>
1010
<label for="surpriseSelect" class="col-6 col-form-label">{% trans "Surprise Frequency" %}</label>
1111
<div class="col-6">
1212
<select name="surprise_frequency" id="surpriseSelect">
13+
<option value="30"{% if config.surprise_frequency == 30 %} selected{% endif %}>{% trans "Rarely" context "Surprise frequency" %}</option>
1314
<option value="50"{% if config.surprise_frequency == 50 %} selected{% endif %}>{% trans "Sometimes" context "Surprise frequency" %}</option>
1415
<option value="125"{% if config.surprise_frequency == 125 %} selected{% endif %}>{% trans "Often" context "Surprise frequency" %}</option>
1516
<option value="250"{% if config.surprise_frequency == 250 %} selected{% endif %}>{% trans "Very often" context "Surprise frequency" %}</option>
16-
<option value="0"{% if config.surprise_frequency == 0 %} selected{% endif %}>{% trans "Disabled" context "Surprise frequency" %}</option>
17+
<option value="0"{% if config.surprise_frequency == 0 %} selected{% endif %}>{% trans "Never" context "Surprise frequency" %}</option>
1718
</select>
1819
</div>
1920
</div>

0 commit comments

Comments
 (0)