Skip to content
This repository has been archived by the owner on Jun 9, 2019. It is now read-only.

Commit

Permalink
Update twitch-autoemote.py
Browse files Browse the repository at this point in the history
-Added primitive support for subscriber emotes
-Updated global emote list
  • Loading branch information
Poorchop committed Aug 18, 2014
1 parent d8c01c8 commit 418f818
Showing 1 changed file with 148 additions and 91 deletions.
239 changes: 148 additions & 91 deletions twitch-autoemote.py
Original file line number Diff line number Diff line change
@@ -1,108 +1,163 @@
# coding=utf-8

import hexchat
import os

__module_name__ = "Twitch Emote Autoformat"
__module_author__ = "PDog"
__module_version__ = "0.6"
__module_description__ = "Automatically format twitch.tv emote names with proper capitalization"
__module_author__ = "Poorchop"
__module_version__ = "0.7"
__module_description__ = "Automatically format TwitchTV emote names with proper capitalization"
# TODO: cross platform support
# TODO: emote unicode character support
# TODO: only load subscriber emotes for subscribed/specified channels

# change this value to False if you do not wish to use subscriber emotes
allow_sub_emotes = True

events = ("Channel Message", "Channel Msg Hilight",
"Channel Action", "Channel Action Hilight",
"Your Message")
edited = False

# emote names taken from: http://twitchemotes.com/
# list last updated Sept 20, 2013
emote_dict = {'4head' : '4Head',
'arsonnosexy' : 'ArsonNoSexy',
'asianglow' : 'AsianGlow',
'bcwarrior' : 'BCWarrior',
'bort' : 'BORT',
'batchest' : 'BatChest',
'biblethump' : 'BibleThump',
'bigbrother' : 'BigBrother',
'bionicbunion' : 'BionicBunion',
'blargnaunt' : 'BlargNaut',
'bloodtrail' : 'BloodTrail',
'brainslug' : 'BrainSlug',
'brokeback' : 'BrokeBack',
'cougarhunt' : 'CougarHunt',
'daesuppy' : 'DAESuppy',
'dbstyle' : 'DBstyle',
'dansgame' : 'DansGame',
'datsheffy' : 'DatSheffy',
'dogface' : 'DogFace',
'eagleeye' : 'EagleEye',
'evilfetus' : 'EvilFetus',
'fpsmarksman' : 'FPSMarksman',
'fungineer' : 'FUNgineer',
'failfish' : 'FailFish',
'frankerz' : 'FrankerZ',
'freakinstinkin' : 'FreakinStinkin',
'fuzzyotteroo' : 'FuzzyOtterOO',
'gingerpower' : 'GingerPower',
'hassanchop' : 'HassanChop',
'hotpokket' : 'HotPokket',
'itsboshytime' : 'ItsBoshyTime',
'jkanstyle' : 'JKanStyle',
'jebaited' : 'Jebaited',
'joncarnage' : 'JonCarnage',
'kappa' : 'Kappa',
'keepo' : 'Keepo',
'kevinturtle' : 'KevinTurtle',
'kippa' : 'Kippa',
'kreygasm' : 'Kreygasm',
'mvgame' : 'MVGame',
'mrdestructoid' : 'MrDestructoid',
'ninjatroll' : 'NinjaTroll',
'nonospot' : 'NoNoSpot',
'omgscoots' : 'OMGScoots',
'onehand' : 'OneHand',
'opieop' : 'OpieOP',
'optimizeprime' : 'OptimizePrime',
'pjsalt' : 'PJSalt',
'pmstwin' : 'PMSTwin',
'pazpazowitz' : 'PazPazowitz',
'picomause' : 'PicoMause',
'pogchamp' : 'PogChamp',
'poooound' : 'Poooound',
'punchtrees' : 'PunchTrees',
'ralpherz' : 'RalpherZ',
'redcoat' : 'RedCoat',
'residentsleeper' : 'ResidentSleeper',
'rulefive' : 'RuleFive',
'smorc' : 'SMOrc',
'smskull' : 'SMSkull',
'ssssss' : 'SSSsss',
'shazbotstix' : 'ShazBotstix',
'sobayed' : 'SoBayed',
'sonnerlater' : 'SoonerLater',
'stonelightning' : 'StoneLightning',
'strawbeary' : 'StrawBeary',
'supervinlin' : 'SuperVinlin',
'swiftrage' : 'SwiftRage',
'tf2john' : 'TF2John',
'tehfunrun' : 'TehFunrun',
'theringer' : 'TheRinger',
'therarfu' : 'TheTarFu',
'thunbeast' : 'ThunBeast',
'tinyface' : 'TinyFace',
'toospicy' : 'TooSpicy',
'trihard' : 'TriHard',
'uleetbackup' : 'UleetBackup',
'unsane' : 'UnSane',
'volcania' : 'Volcania',
'wtruck' : 'WTRuck',
'wholewheat' : 'WholeWheat',
'winwaker' : 'WinWaker'}
# list last updated August 18, 2014
emote_dict = {'4head': '4Head',
'arsonnosexy': 'ArsonNoSexy',
'asianglow': 'AsianGlow',
'atgl': 'AtGL',
'ativy': 'AtIvy',
'atww': 'AtWW',
'bcwarrior': 'BCWarrior',
'bort': 'BORT',
'batchest': 'BatChest',
'biblethump': 'BibleThump',
'bigbrother': 'BigBrother',
'bionicbunion': 'BionicBunion',
'blargnaunt': 'BlargNaut',
'bloodtrail': 'BloodTrail',
'brainslug': 'BrainSlug',
'brokeback': 'BrokeBack',
'cougarhunt': 'CougarHunt',
'daesuppy': 'DAESuppy',
'dbstyle': 'DBstyle',
'dansgame': 'DansGame',
'datsheffy': 'DatSheffy',
'dogface': 'DogFace',
'eagleeye': 'EagleEye',
'elegiggle': 'EleGiggle',
'evilfetus': 'EvilFetus',
'fpsmarksman': 'FPSMarksman',
'fungineer': 'FUNgineer',
'failfish': 'FailFish',
'frankerz': 'FrankerZ',
'freakinstinkin': 'FreakinStinkin',
'fuzzyotteroo': 'FuzzyOtterOO',
'gasjoker': 'GasJoker',
'gingerpower': 'GingerPower',
'grammarking': 'GrammarKing',
'hassaanchop': 'HassaanChop',
'hassanchop': 'HassanChop',
'hotpokket': 'HotPokket',
'itsboshytime': 'ItsBoshyTime',
'jkanstyle': 'JKanStyle',
'jebaited': 'Jebaited',
'joncarnage': 'JonCarnage',
'kapow': 'KAPOW',
'kzassault': 'KZassault',
'kzcover': 'KZcover',
'kzguerilla': 'KZguerilla',
'kzhelghast': 'KZhelghast',
'kzowl': 'KZowl',
'kzskull': 'KZskull',
'kappa': 'Kappa',
'keepo': 'Keepo',
'kevinturtle': 'KevinTurtle',
'kippa': 'Kippa',
'kreygasm': 'Kreygasm',
'mvgame': 'MVGame',
'mechasupes': 'MechaSupes',
'mrdestructoid': 'MrDestructoid',
'nightbat': 'NightBat',
'ninjatroll': 'NinjaTroll',
'nonospot': 'NoNoSpot',
'omgscoots': 'OMGScoots',
'onehand': 'OneHand',
'opieop': 'OpieOP',
'optimizeprime': 'OptimizePrime',
'pjharley': 'PJHarley',
'pjsalt': 'PJSalt',
'pmstwin': 'PMSTwin',
'panicvis': 'PanicVis',
'pazpazowitz': 'PazPazowitz',
'peopleschamp': 'PeoplesChamp',
'picomause': 'PicoMause',
'pipehype': 'PipeHype',
'pogchamp': 'PogChamp',
'poooound': 'Poooound',
'punchtrees': 'PunchTrees',
'ralpherz': 'RalpherZ',
'redcoat': 'RedCoat',
'residentsleeper': 'ResidentSleeper',
'ritzmitz': 'RitzMitz',
'rulefive': 'RuleFive',
'smorc': 'SMOrc',
'smskull': 'SMSkull',
'ssssss': 'SSSsss',
'shazbotstix': 'ShazBotstix',
'shazam': "Shazam",
'sobayed': 'SoBayed',
'sonnerlater': 'SoonerLater',
'srihead': 'SriHead',
'stonelightning': 'StoneLightning',
'strawbeary': 'StrawBeary',
'supervinlin': 'SuperVinlin',
'swiftrage': 'SwiftRage',
'tf2john': 'TF2John',
'tehfunrun': 'TehFunrun',
'theringer': 'TheRinger',
'thetarfu': 'TheTarFu',
'thething': 'TheThing',
'thunbeast': 'ThunBeast',
'tinyface': 'TinyFace',
'toospicy': 'TooSpicy',
'trihard': 'TriHard',
'uleetbackup': 'UleetBackup',
'unsane': 'UnSane',
'unclenox': 'UncleNox',
'volcania': 'Volcania',
'wtruck': 'WTRuck',
'wholewheat': 'WholeWheat',
'winwaker': 'WinWaker',
'youwhy': 'YouWHY',
'aneleanele': 'aneleanele',
'noscope420': 'noScope420',
'shazamicon': 'shazamicon'}

if allow_sub_emotes:
file_path = os.path.join(hexchat.get_info("configdir"),
"addons", "twitch-sub-emotes.txt")

if os.path.exists(file_path):
f = open(file_path, "r")
for line in f:
stripped_emote = line.replace("\n", "")
lowercase_emote = stripped_emote.lower()
emote_dict[lowercase_emote] = stripped_emote
f.close()
else:
print("*** Subscriber emote list not found! Download it at "
"https://raw.githubusercontent.com/Poorchop/hexchat-scripts/master/twitch-sub-emotes.txt, "
"place it in your HexChat addons folder, and then reload this script to use subscriber emotes. ***")


def is_twitch():
if "twitch.tv" in hexchat.get_info("host"):
server = hexchat.get_info("host")
if server and "twitch.tv" in server:
return True
else:
else:
return False



def keypress_cb(word, word_eol, userdata):
key = word[0]
mod = word[1]
Expand All @@ -116,7 +171,7 @@ def keypress_cb(word, word_eol, userdata):

if msg:
split_words = msg.split(" ")

for w in split_words:
if w.lower() in emote_dict:
split_words[split_words.index(w)] = emote_dict[w.lower()]
Expand All @@ -125,6 +180,7 @@ def keypress_cb(word, word_eol, userdata):
hexchat.command("SETTEXT {}".format(new_msg))
hexchat.command("SETCURSOR {}".format(len(new_msg)))


def emote_cb(word, word_eol, event):
word = [(word[i] if len(word) > i else "") for i in range(4)]
global edited
Expand All @@ -134,7 +190,7 @@ def emote_cb(word, word_eol, event):

if is_twitch():
word[1] = word[1] \
.replace(":)", "") \
.replace(":)", "😊") \
.replace(":(", "☹") \
.replace(":z", "😴") \
.replace("B)", "😎") \
Expand All @@ -156,6 +212,7 @@ def emote_cb(word, word_eol, event):

return hexchat.EAT_ALL


hexchat.hook_print("Key Press", keypress_cb)
for event in events:
hexchat.hook_print(event, emote_cb, event, priority=hexchat.PRI_HIGH)
Expand Down

0 comments on commit 418f818

Please sign in to comment.