Read out vote result

This commit is contained in:
gpkvt 2022-08-13 08:00:41 +02:00
parent fcbf726e50
commit a4b0cd0cb8
3 changed files with 43 additions and 8 deletions

View file

@ -65,6 +65,7 @@ messages:
votestart: "Quickvote started. Send #yourchoice to participate." votestart: "Quickvote started. Send #yourchoice to participate."
voteend: "Quickvote ended. The results are:" voteend: "Quickvote ended. The results are:"
votenobody: "Nobody casted a vote. :(" votenobody: "Nobody casted a vote. :("
voteresult: "Voting has ended. The result is:"
votes: "Votes" votes: "Votes"
log: log:
@ -117,6 +118,7 @@ Please note that the `oauth_token` is valid for approximately 60 days. If it bec
* `votestart`: Message when a quickvote is started. * `votestart`: Message when a quickvote is started.
* `voteend`: Message if a quickvote ends. * `voteend`: Message if a quickvote ends.
* `votenobody`: Message if quickvote ends, but nobody has voted. * `votenobody`: Message if quickvote ends, but nobody has voted.
* `voteresult`: Prefix for the result (will be read out)
* `votes`: Suffix to vote count. * `votes`: Suffix to vote count.
##### log ##### log

View file

@ -29,6 +29,7 @@ messages: # Things the bot can send as chat message
votestart: "Quickvote started. Send #yourchoice to participate." votestart: "Quickvote started. Send #yourchoice to participate."
voteend: "Quickvote ended. The results are:" voteend: "Quickvote ended. The results are:"
votenobody: "Nobody casted a vote. :(" votenobody: "Nobody casted a vote. :("
voteresult: "Voting has ended. The result is:"
votes: "Votes" votes: "Votes"
log: log:

48
tts.py
View file

@ -20,21 +20,21 @@
along with this program. If not, see <http://www.gnu.org/licenses/>. along with this program. If not, see <http://www.gnu.org/licenses/>.
""" """
import json
import logging
import socket
import sys import sys
import time import time
import json
import socket
import logging
import datetime import datetime
import socketserver
import urllib.request
import urllib.parse
import webbrowser import webbrowser
import socketserver
import urllib.parse
import urllib.request
from threading import Thread from threading import Thread
from http.server import BaseHTTPRequestHandler
from urllib.parse import parse_qs
from collections import Counter from collections import Counter
from urllib.parse import parse_qs
from http.server import BaseHTTPRequestHandler
import yaml import yaml
@ -207,6 +207,22 @@ class IRC:
logging.info("Nobody voted") logging.info("Nobody voted")
self.sendmsg(conf['IRC_CHANNEL'], "@chat", conf['MESSAGE']['VOTEEND']) self.sendmsg(conf['IRC_CHANNEL'], "@chat", conf['MESSAGE']['VOTEEND'])
self.sendmsg(conf['IRC_CHANNEL'], "*", conf['MESSAGE']['VOTENOBODY']) self.sendmsg(conf['IRC_CHANNEL'], "*", conf['MESSAGE']['VOTENOBODY'])
msg = {
"TTS": True,
"msg": conf['MESSAGE']['VOTENOBODY'],
"badges": True,
"subscriber": True,
"msgid": True,
"user": conf['IRC_USERNAME'],
"length": conf['IRC_TTS_LEN'],
"queuetime": datetime.datetime.now(),
"timestamp": str(time.time_ns())
}
msg_queue_raw.append(msg)
logging.info('The result is: %s', conf['MESSAGE']['VOTENOBODY'])
logging.debug('Votemsg: %s', msg)
self.quickvote = False self.quickvote = False
self.poll = {} self.poll = {}
return False return False
@ -218,6 +234,21 @@ class IRC:
logging.debug(count) logging.debug(count)
msg = {
"TTS": True,
"msg": conf['MESSAGE']['VOTERESULT'] +" "+ str(count[0]),
"badges": True,
"subscriber": True,
"msgid": True,
"user": conf['IRC_USERNAME'],
"length": conf['IRC_TTS_LEN'],
"queuetime": datetime.datetime.now(),
"timestamp": str(time.time_ns())
}
msg_queue_raw.append(msg)
logging.info('The result is: %s', conf['MESSAGE']['VOTERESULT'] +" "+ str(count[0]))
logging.debug('Votemsg: %s', msg)
for key, value in count: for key, value in count:
self.sendmsg( self.sendmsg(
conf['IRC_CHANNEL'], "*", conf['IRC_CHANNEL'], "*",
@ -534,6 +565,7 @@ def load_config():
conf['MESSAGE']['VOTESTART'] = cfg['messages']['votestart'] or "Quickvote started. Send #yourchoice to participate." conf['MESSAGE']['VOTESTART'] = cfg['messages']['votestart'] or "Quickvote started. Send #yourchoice to participate."
conf['MESSAGE']['VOTEEND'] = cfg['messages']['voteend'] or "Quickvote ended. The results are:" conf['MESSAGE']['VOTEEND'] = cfg['messages']['voteend'] or "Quickvote ended. The results are:"
conf['MESSAGE']['VOTENOBODY'] = cfg['messages']['votenobody'] or "Nobody casted a vote. :(" conf['MESSAGE']['VOTENOBODY'] = cfg['messages']['votenobody'] or "Nobody casted a vote. :("
conf['MESSAGE']['VOTERESULT'] = cfg['messages']['voteresult'] or "Voting has ended. The result is:"
conf['MESSAGE']['VOTES'] = cfg['messages']['votes'] or "Stimmen" conf['MESSAGE']['VOTES'] = cfg['messages']['votes'] or "Stimmen"
conf['USERMAP'] = cfg['usermapping'] or [] conf['USERMAP'] = cfg['usermapping'] or []