11# coding=utf-8
22
33import hexchat
4+ import os
45
56__module_name__ = "Twitch Emote Autoformat"
6- __module_author__ = "PDog"
7- __module_version__ = "0.6"
8- __module_description__ = "Automatically format twitch.tv emote names with proper capitalization"
7+ __module_author__ = "Poorchop"
8+ __module_version__ = "0.7"
9+ __module_description__ = "Automatically format TwitchTV emote names with proper capitalization"
10+ # TODO: cross platform support
11+ # TODO: emote unicode character support
12+ # TODO: only load subscriber emotes for subscribed/specified channels
13+
14+ # change this value to False if you do not wish to use subscriber emotes
15+ allow_sub_emotes = True
916
1017events = ("Channel Message" , "Channel Msg Hilight" ,
1118 "Channel Action" , "Channel Action Hilight" ,
1219 "Your Message" )
1320edited = False
1421
1522# emote names taken from: http://twitchemotes.com/
16- # list last updated Sept 20, 2013
17- emote_dict = {'4head' : '4Head' ,
18- 'arsonnosexy' : 'ArsonNoSexy' ,
19- 'asianglow' : 'AsianGlow' ,
20- 'bcwarrior' : 'BCWarrior' ,
21- 'bort' : 'BORT' ,
22- 'batchest' : 'BatChest' ,
23- 'biblethump' : 'BibleThump' ,
24- 'bigbrother' : 'BigBrother' ,
25- 'bionicbunion' : 'BionicBunion' ,
26- 'blargnaunt' : 'BlargNaut' ,
27- 'bloodtrail' : 'BloodTrail' ,
28- 'brainslug' : 'BrainSlug' ,
29- 'brokeback' : 'BrokeBack' ,
30- 'cougarhunt' : 'CougarHunt' ,
31- 'daesuppy' : 'DAESuppy' ,
32- 'dbstyle' : 'DBstyle' ,
33- 'dansgame' : 'DansGame' ,
34- 'datsheffy' : 'DatSheffy' ,
35- 'dogface' : 'DogFace' ,
36- 'eagleeye' : 'EagleEye' ,
37- 'evilfetus' : 'EvilFetus' ,
38- 'fpsmarksman' : 'FPSMarksman' ,
39- 'fungineer' : 'FUNgineer' ,
40- 'failfish' : 'FailFish' ,
41- 'frankerz' : 'FrankerZ' ,
42- 'freakinstinkin' : 'FreakinStinkin' ,
43- 'fuzzyotteroo' : 'FuzzyOtterOO' ,
44- 'gingerpower' : 'GingerPower' ,
45- 'hassanchop' : 'HassanChop' ,
46- 'hotpokket' : 'HotPokket' ,
47- 'itsboshytime' : 'ItsBoshyTime' ,
48- 'jkanstyle' : 'JKanStyle' ,
49- 'jebaited' : 'Jebaited' ,
50- 'joncarnage' : 'JonCarnage' ,
51- 'kappa' : 'Kappa' ,
52- 'keepo' : 'Keepo' ,
53- 'kevinturtle' : 'KevinTurtle' ,
54- 'kippa' : 'Kippa' ,
55- 'kreygasm' : 'Kreygasm' ,
56- 'mvgame' : 'MVGame' ,
57- 'mrdestructoid' : 'MrDestructoid' ,
58- 'ninjatroll' : 'NinjaTroll' ,
59- 'nonospot' : 'NoNoSpot' ,
60- 'omgscoots' : 'OMGScoots' ,
61- 'onehand' : 'OneHand' ,
62- 'opieop' : 'OpieOP' ,
63- 'optimizeprime' : 'OptimizePrime' ,
64- 'pjsalt' : 'PJSalt' ,
65- 'pmstwin' : 'PMSTwin' ,
66- 'pazpazowitz' : 'PazPazowitz' ,
67- 'picomause' : 'PicoMause' ,
68- 'pogchamp' : 'PogChamp' ,
69- 'poooound' : 'Poooound' ,
70- 'punchtrees' : 'PunchTrees' ,
71- 'ralpherz' : 'RalpherZ' ,
72- 'redcoat' : 'RedCoat' ,
73- 'residentsleeper' : 'ResidentSleeper' ,
74- 'rulefive' : 'RuleFive' ,
75- 'smorc' : 'SMOrc' ,
76- 'smskull' : 'SMSkull' ,
77- 'ssssss' : 'SSSsss' ,
78- 'shazbotstix' : 'ShazBotstix' ,
79- 'sobayed' : 'SoBayed' ,
80- 'sonnerlater' : 'SoonerLater' ,
81- 'stonelightning' : 'StoneLightning' ,
82- 'strawbeary' : 'StrawBeary' ,
83- 'supervinlin' : 'SuperVinlin' ,
84- 'swiftrage' : 'SwiftRage' ,
85- 'tf2john' : 'TF2John' ,
86- 'tehfunrun' : 'TehFunrun' ,
87- 'theringer' : 'TheRinger' ,
88- 'therarfu' : 'TheTarFu' ,
89- 'thunbeast' : 'ThunBeast' ,
90- 'tinyface' : 'TinyFace' ,
91- 'toospicy' : 'TooSpicy' ,
92- 'trihard' : 'TriHard' ,
93- 'uleetbackup' : 'UleetBackup' ,
94- 'unsane' : 'UnSane' ,
95- 'volcania' : 'Volcania' ,
96- 'wtruck' : 'WTRuck' ,
97- 'wholewheat' : 'WholeWheat' ,
98- 'winwaker' : 'WinWaker' }
23+ # list last updated August 18, 2014
24+ emote_dict = {'4head' : '4Head' ,
25+ 'arsonnosexy' : 'ArsonNoSexy' ,
26+ 'asianglow' : 'AsianGlow' ,
27+ 'atgl' : 'AtGL' ,
28+ 'ativy' : 'AtIvy' ,
29+ 'atww' : 'AtWW' ,
30+ 'bcwarrior' : 'BCWarrior' ,
31+ 'bort' : 'BORT' ,
32+ 'batchest' : 'BatChest' ,
33+ 'biblethump' : 'BibleThump' ,
34+ 'bigbrother' : 'BigBrother' ,
35+ 'bionicbunion' : 'BionicBunion' ,
36+ 'blargnaunt' : 'BlargNaut' ,
37+ 'bloodtrail' : 'BloodTrail' ,
38+ 'brainslug' : 'BrainSlug' ,
39+ 'brokeback' : 'BrokeBack' ,
40+ 'cougarhunt' : 'CougarHunt' ,
41+ 'daesuppy' : 'DAESuppy' ,
42+ 'dbstyle' : 'DBstyle' ,
43+ 'dansgame' : 'DansGame' ,
44+ 'datsheffy' : 'DatSheffy' ,
45+ 'dogface' : 'DogFace' ,
46+ 'eagleeye' : 'EagleEye' ,
47+ 'elegiggle' : 'EleGiggle' ,
48+ 'evilfetus' : 'EvilFetus' ,
49+ 'fpsmarksman' : 'FPSMarksman' ,
50+ 'fungineer' : 'FUNgineer' ,
51+ 'failfish' : 'FailFish' ,
52+ 'frankerz' : 'FrankerZ' ,
53+ 'freakinstinkin' : 'FreakinStinkin' ,
54+ 'fuzzyotteroo' : 'FuzzyOtterOO' ,
55+ 'gasjoker' : 'GasJoker' ,
56+ 'gingerpower' : 'GingerPower' ,
57+ 'grammarking' : 'GrammarKing' ,
58+ 'hassaanchop' : 'HassaanChop' ,
59+ 'hassanchop' : 'HassanChop' ,
60+ 'hotpokket' : 'HotPokket' ,
61+ 'itsboshytime' : 'ItsBoshyTime' ,
62+ 'jkanstyle' : 'JKanStyle' ,
63+ 'jebaited' : 'Jebaited' ,
64+ 'joncarnage' : 'JonCarnage' ,
65+ 'kapow' : 'KAPOW' ,
66+ 'kzassault' : 'KZassault' ,
67+ 'kzcover' : 'KZcover' ,
68+ 'kzguerilla' : 'KZguerilla' ,
69+ 'kzhelghast' : 'KZhelghast' ,
70+ 'kzowl' : 'KZowl' ,
71+ 'kzskull' : 'KZskull' ,
72+ 'kappa' : 'Kappa' ,
73+ 'keepo' : 'Keepo' ,
74+ 'kevinturtle' : 'KevinTurtle' ,
75+ 'kippa' : 'Kippa' ,
76+ 'kreygasm' : 'Kreygasm' ,
77+ 'mvgame' : 'MVGame' ,
78+ 'mechasupes' : 'MechaSupes' ,
79+ 'mrdestructoid' : 'MrDestructoid' ,
80+ 'nightbat' : 'NightBat' ,
81+ 'ninjatroll' : 'NinjaTroll' ,
82+ 'nonospot' : 'NoNoSpot' ,
83+ 'omgscoots' : 'OMGScoots' ,
84+ 'onehand' : 'OneHand' ,
85+ 'opieop' : 'OpieOP' ,
86+ 'optimizeprime' : 'OptimizePrime' ,
87+ 'pjharley' : 'PJHarley' ,
88+ 'pjsalt' : 'PJSalt' ,
89+ 'pmstwin' : 'PMSTwin' ,
90+ 'panicvis' : 'PanicVis' ,
91+ 'pazpazowitz' : 'PazPazowitz' ,
92+ 'peopleschamp' : 'PeoplesChamp' ,
93+ 'picomause' : 'PicoMause' ,
94+ 'pipehype' : 'PipeHype' ,
95+ 'pogchamp' : 'PogChamp' ,
96+ 'poooound' : 'Poooound' ,
97+ 'punchtrees' : 'PunchTrees' ,
98+ 'ralpherz' : 'RalpherZ' ,
99+ 'redcoat' : 'RedCoat' ,
100+ 'residentsleeper' : 'ResidentSleeper' ,
101+ 'ritzmitz' : 'RitzMitz' ,
102+ 'rulefive' : 'RuleFive' ,
103+ 'smorc' : 'SMOrc' ,
104+ 'smskull' : 'SMSkull' ,
105+ 'ssssss' : 'SSSsss' ,
106+ 'shazbotstix' : 'ShazBotstix' ,
107+ 'shazam' : "Shazam" ,
108+ 'sobayed' : 'SoBayed' ,
109+ 'sonnerlater' : 'SoonerLater' ,
110+ 'srihead' : 'SriHead' ,
111+ 'stonelightning' : 'StoneLightning' ,
112+ 'strawbeary' : 'StrawBeary' ,
113+ 'supervinlin' : 'SuperVinlin' ,
114+ 'swiftrage' : 'SwiftRage' ,
115+ 'tf2john' : 'TF2John' ,
116+ 'tehfunrun' : 'TehFunrun' ,
117+ 'theringer' : 'TheRinger' ,
118+ 'thetarfu' : 'TheTarFu' ,
119+ 'thething' : 'TheThing' ,
120+ 'thunbeast' : 'ThunBeast' ,
121+ 'tinyface' : 'TinyFace' ,
122+ 'toospicy' : 'TooSpicy' ,
123+ 'trihard' : 'TriHard' ,
124+ 'uleetbackup' : 'UleetBackup' ,
125+ 'unsane' : 'UnSane' ,
126+ 'unclenox' : 'UncleNox' ,
127+ 'volcania' : 'Volcania' ,
128+ 'wtruck' : 'WTRuck' ,
129+ 'wholewheat' : 'WholeWheat' ,
130+ 'winwaker' : 'WinWaker' ,
131+ 'youwhy' : 'YouWHY' ,
132+ 'aneleanele' : 'aneleanele' ,
133+ 'noscope420' : 'noScope420' ,
134+ 'shazamicon' : 'shazamicon' }
135+
136+ if allow_sub_emotes :
137+ file_path = os .path .join (hexchat .get_info ("configdir" ),
138+ "addons" , "twitch-sub-emotes.txt" )
139+
140+ if os .path .exists (file_path ):
141+ f = open (file_path , "r" )
142+ for line in f :
143+ stripped_emote = line .replace ("\n " , "" )
144+ lowercase_emote = stripped_emote .lower ()
145+ emote_dict [lowercase_emote ] = stripped_emote
146+ f .close ()
147+ else :
148+ print ("*** Subscriber emote list not found! Download it at "
149+ "https://raw.githubusercontent.com/Poorchop/hexchat-scripts/master/twitch-sub-emotes.txt, "
150+ "place it in your HexChat addons folder, and then reload this script to use subscriber emotes. ***" )
151+
99152
100153def is_twitch ():
101- if "twitch.tv" in hexchat .get_info ("host" ):
154+ server = hexchat .get_info ("host" )
155+ if server and "twitch.tv" in server :
102156 return True
103- else :
157+ else :
104158 return False
105-
159+
160+
106161def keypress_cb (word , word_eol , userdata ):
107162 key = word [0 ]
108163 mod = word [1 ]
@@ -116,7 +171,7 @@ def keypress_cb(word, word_eol, userdata):
116171
117172 if msg :
118173 split_words = msg .split (" " )
119-
174+
120175 for w in split_words :
121176 if w .lower () in emote_dict :
122177 split_words [split_words .index (w )] = emote_dict [w .lower ()]
@@ -125,6 +180,7 @@ def keypress_cb(word, word_eol, userdata):
125180 hexchat .command ("SETTEXT {}" .format (new_msg ))
126181 hexchat .command ("SETCURSOR {}" .format (len (new_msg )))
127182
183+
128184def emote_cb (word , word_eol , event ):
129185 word = [(word [i ] if len (word ) > i else "" ) for i in range (4 )]
130186 global edited
@@ -134,7 +190,7 @@ def emote_cb(word, word_eol, event):
134190
135191 if is_twitch ():
136192 word [1 ] = word [1 ] \
137- .replace (":)" , "☺ " ) \
193+ .replace (":)" , "😊 " ) \
138194 .replace (":(" , "☹" ) \
139195 .replace (":z" , "😴" ) \
140196 .replace ("B)" , "😎" ) \
@@ -156,6 +212,7 @@ def emote_cb(word, word_eol, event):
156212
157213 return hexchat .EAT_ALL
158214
215+
159216hexchat .hook_print ("Key Press" , keypress_cb )
160217for event in events :
161218 hexchat .hook_print (event , emote_cb , event , priority = hexchat .PRI_HIGH )
0 commit comments