/
twitchy.py
executable file
·71 lines (50 loc) · 1.71 KB
/
twitchy.py
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
"""A pluggable Twitch chat-interaction UI.
"""
from twisted.internet import _threadedselect
_threadedselect.install()
from twisted.internet import reactor
import wx
from pubsub import pub
import gui
import config
import chat
import plugins
__appname__ = 'twitchy'
__description__ = 'An extensible GUI designed to improve Twitch TV streamer-chat interaction'
__version__ = '0.1.0-alpha'
__author__ = 'Ronald Rogers'
__email__ = 'ronald.d.rogers@gmail.com'
__license__ = 'BSD'
__download__ = 'http://github.com/ronald.d.rogers/twitchy/'
class App(object):
def __init__(self):
self.config = config.read('config.json')
if not 'twitch_id' in self.config:
raise config.ConfigurationError(
'Setting twitch_id incorrectly configured in config.json')
self.wx = wx.App()
self.plugins = plugins.PluginManager()
self.plugins.load('plugins/')
twitch_id = self.config['twitch_id']
login = self.config['services']['chat']['login']
bot_id = login['id']
bot_oauth = login['oauth']
chat.connect(bot_id, bot_oauth, twitch_id)
reactor.interleave(wx.CallAfter)
pub.subscribe(self.quit, 'command.quit')
self.icon = gui.Icon(self.plugins.plugins())
self.menu = gui.Menu(self.plugins.plugins())
self.wx.MainLoop()
def quit(self):
self._quit_twisted()
def _quit_wx(self, *args):
self.icon.RemoveIcon()
self.menu.Close()
self.wx.Exit()
def _quit_twisted(self):
reactor.addSystemEventTrigger(
'after', 'shutdown', self._quit_wx, True)
if reactor.running:
reactor.stop()
if __name__ == '__main__':
app = App()