Added config options for !wiki

This commit is contained in:
gpkvt 2022-10-23 16:19:38 +02:00
parent 591909a94c
commit 83811df8c1
4 changed files with 43 additions and 5 deletions

View File

@ -2,12 +2,18 @@
All notable changes to this project will be documented in this file. If there is a `Changed` section please read carefully, as this often means that you will need to adapt your `config.yml`.
## [1.7.4]
## [1.8.0]
### Changed 1.7.4
### Added 1.8.0
* Option to disable TTS audio output for !wiki function
* Option to configure the number of sentences fetched by !wiki function
### Changed 1.8.0
* "oauth_token doesn't need to start with "oauth:" anymore
* Improved oauth-token detection
* Improved README.md
## [1.7.3] - 2022-10-20

View File

@ -55,6 +55,17 @@ bot:
message_length: 200
language: de
features:
quote: True
pick: True
vote: True
wiki: True
wikitts: True
wikisentences: 3
random: True
version: True
ping: True
messages:
toff: "TTS is now inactive."
ton: "TTS is now active."
@ -116,6 +127,17 @@ Please note that the `oauth_token` is valid for approximately 60 days. If it bec
* `message_length`: Maximum allowed message length for TTS
* `language`: Language for `!wiki` command
##### features
* `quote`: Enable/Disable `!quote` function
* `pick`: Enable/Disable `!pick` function
* `wiki`: Enable/Disable `!wiki` function
* `wikitts`: Enable/Disable audio output for `!wiki` function
* `wikisentences`: Number of sentences fetched by `!wiki` function
* `random`: Enable/Disable `!random` function
* `version`: Enable/Disable `!version` function
* `ping`: Enable/Disable `!ping` function
##### messages
* `toff`: The bots reply when `!toff` is used.
@ -199,6 +221,7 @@ features:
pick: False
vote: False
wiki: False
wikitts: False
random: False
version: True
ping: True

View File

@ -21,6 +21,8 @@ features:
pick: True
vote: True
wiki: True
wikitts: True
wikisentences: 3
random: True
version: True
ping: True

13
tts.py
View File

@ -668,7 +668,7 @@ class IRC:
user = tags['user']
wikipedia.set_lang(CONF['WIKI_LANG'])
msg = msg.replace('!wiki', '').strip()
wikiresult = wikipedia.summary(msg, sentences=3)
wikiresult = wikipedia.summary(msg, sentences=CONF['FEATURE']['WIKISENTENCES'])
self.sendmsg(
CONF['IRC_CHANNEL'],
@ -693,7 +693,8 @@ class IRC:
"queuetime": datetime.datetime.now(),
"timestamp": str(time.time_ns())
}
msg_queue[raw_msg['timestamp']] = [raw_msg['user'], raw_msg['msg']]
if CONF['FEATURE']['WIKITTS']:
msg_queue[raw_msg['timestamp']] = [raw_msg['user'], raw_msg['msg']]
except wikipedia.exceptions.DisambiguationError:
user = f"@{user}"
@ -1492,6 +1493,12 @@ def load_config():
CONF['FEATURE']['WIKI'] = cfg.get('features', {}).get(
'wiki', True
)
CONF['FEATURE']['WIKITTS'] = cfg.get('features', {}).get(
'wikitts', True
)
CONF['FEATURE']['WIKISENTENCES'] = cfg.get('features', {}).get(
'wikisentences', 3
)
CONF['FEATURE']['PICK'] = cfg.get('features', {}).get(
'pick', True
)
@ -1619,7 +1626,7 @@ if __name__ == "__main__":
sys.tracebacklimit = 3
VERSION = "1.7.4"
VERSION = "1.8.0"
CONF = {}
tts_done = []
MSG_QUEUE_RAW = []