diff --git a/README.md b/README.md index 3e6a850..61edb41 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,7 @@ messages: votestart: "Quickvote started. Send #yourchoice to participate." voteend: "Quickvote ended. The results are:" votenobody: "Nobody casted a vote. :(" + voteresult: "Voting has ended. The result is:" votes: "Votes" 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. * `voteend`: Message if a quickvote ends. * `votenobody`: Message if quickvote ends, but nobody has voted. + * `voteresult`: Prefix for the result (will be read out) * `votes`: Suffix to vote count. ##### log diff --git a/config-dist.yml b/config-dist.yml index 60a6801..aa9f22f 100644 --- a/config-dist.yml +++ b/config-dist.yml @@ -29,6 +29,7 @@ messages: # Things the bot can send as chat message votestart: "Quickvote started. Send #yourchoice to participate." voteend: "Quickvote ended. The results are:" votenobody: "Nobody casted a vote. :(" + voteresult: "Voting has ended. The result is:" votes: "Votes" log: diff --git a/tts.py b/tts.py index 9713644..9e0565d 100644 --- a/tts.py +++ b/tts.py @@ -20,21 +20,21 @@ along with this program. If not, see . """ -import json -import logging -import socket import sys import time +import json +import socket +import logging import datetime -import socketserver -import urllib.request -import urllib.parse import webbrowser +import socketserver +import urllib.parse +import urllib.request from threading import Thread -from http.server import BaseHTTPRequestHandler -from urllib.parse import parse_qs from collections import Counter +from urllib.parse import parse_qs +from http.server import BaseHTTPRequestHandler import yaml @@ -207,6 +207,22 @@ class IRC: logging.info("Nobody voted") self.sendmsg(conf['IRC_CHANNEL'], "@chat", conf['MESSAGE']['VOTEEND']) 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.poll = {} return False @@ -218,6 +234,21 @@ class IRC: 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: self.sendmsg( 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']['VOTEEND'] = cfg['messages']['voteend'] or "Quickvote ended. The results are:" 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['USERMAP'] = cfg['usermapping'] or []