fixed crash in the chat example when bot sent emotes/badges
This commit is contained in:
parent
dc070e8cb1
commit
e556e95841
@ -8,11 +8,12 @@ func put_chat(senderdata : SenderData, msg : String):
|
|||||||
var result = await($"../Gift".get_badge(badge, senderdata.tags["room-id"]))
|
var result = await($"../Gift".get_badge(badge, senderdata.tags["room-id"]))
|
||||||
badges += "[img=center]" + result.resource_path + "[/img] "
|
badges += "[img=center]" + result.resource_path + "[/img] "
|
||||||
var locations : Array = []
|
var locations : Array = []
|
||||||
for emote in senderdata.tags["emotes"].split("/", false):
|
if (senderdata.tags.has("emotes")):
|
||||||
var data : Array = emote.split(":")
|
for emote in senderdata.tags["emotes"].split("/", false):
|
||||||
for d in data[1].split(","):
|
var data : Array = emote.split(":")
|
||||||
var start_end = d.split("-")
|
for d in data[1].split(","):
|
||||||
locations.append(EmoteLocation.new(data[0], int(start_end[0]), int(start_end[1])))
|
var start_end = d.split("-")
|
||||||
|
locations.append(EmoteLocation.new(data[0], int(start_end[0]), int(start_end[1])))
|
||||||
locations.sort_custom(Callable(EmoteLocation, "smaller"))
|
locations.sort_custom(Callable(EmoteLocation, "smaller"))
|
||||||
var offset = 0
|
var offset = 0
|
||||||
for loc in locations:
|
for loc in locations:
|
||||||
|
@ -48,7 +48,7 @@ var last_msg : int = Time.get_ticks_msec()
|
|||||||
# Mapping of channels to their channel info, like available badges.
|
# Mapping of channels to their channel info, like available badges.
|
||||||
var channels : Dictionary = {}
|
var channels : Dictionary = {}
|
||||||
# Last Userstate of the bot for channels. Contains <channel_name> -> <userstate_dictionary> entries.
|
# Last Userstate of the bot for channels. Contains <channel_name> -> <userstate_dictionary> entries.
|
||||||
var last_userstate : Dictionary = {}
|
var last_state : Dictionary = {}
|
||||||
# Dictionary of commands, contains <command key> -> <Callable> entries.
|
# Dictionary of commands, contains <command key> -> <Callable> entries.
|
||||||
var commands : Dictionary = {}
|
var commands : Dictionary = {}
|
||||||
|
|
||||||
@ -166,10 +166,10 @@ func chat(message : String, channel : String = ""):
|
|||||||
if (channel.begins_with("#")):
|
if (channel.begins_with("#")):
|
||||||
channel = channel.right(-1)
|
channel = channel.right(-1)
|
||||||
chat_queue.append("PRIVMSG #" + channel + " :" + message + "\r\n")
|
chat_queue.append("PRIVMSG #" + channel + " :" + message + "\r\n")
|
||||||
chat_message.emit(SenderData.new(last_userstate[channels.keys()[0]]["display-name"], channel, last_userstate[channels.keys()[0]]), message)
|
chat_message.emit(SenderData.new(last_state[channels.keys()[0]]["display-name"], channel, last_state[channels.keys()[0]]), message)
|
||||||
elif(keys.size() == 1):
|
elif(keys.size() == 1):
|
||||||
chat_queue.append("PRIVMSG #" + channels.keys()[0] + " :" + message + "\r\n")
|
chat_queue.append("PRIVMSG #" + channels.keys()[0] + " :" + message + "\r\n")
|
||||||
chat_message.emit(SenderData.new(last_userstate[channels.keys()[0]]["display-name"], channels.keys()[0], last_userstate[channels.keys()[0]]), message)
|
chat_message.emit(SenderData.new(last_state[channels.keys()[0]]["display-name"], channels.keys()[0], last_state[channels.keys()[0]]), message)
|
||||||
else:
|
else:
|
||||||
print_debug("No channel specified.")
|
print_debug("No channel specified.")
|
||||||
|
|
||||||
@ -319,8 +319,13 @@ func handle_message(message : String, tags : Dictionary) -> void:
|
|||||||
whisper_message.emit(sender_data, msg[3].right(-1))
|
whisper_message.emit(sender_data, msg[3].right(-1))
|
||||||
"RECONNECT":
|
"RECONNECT":
|
||||||
twitch_restarting = true
|
twitch_restarting = true
|
||||||
"USERSTATE":
|
"USERSTATE", "ROOMSTATE":
|
||||||
last_userstate[msg[2].right(-1)] = tags
|
var room = msg[2].right(-1)
|
||||||
|
if (!last_state.has(room)):
|
||||||
|
last_state[room] = tags
|
||||||
|
else:
|
||||||
|
for key in tags:
|
||||||
|
last_state[room][key] = tags[key]
|
||||||
_:
|
_:
|
||||||
unhandled_message.emit(message, tags)
|
unhandled_message.emit(message, tags)
|
||||||
|
|
||||||
|
@ -3,5 +3,5 @@
|
|||||||
name="Godot IRC For Twitch"
|
name="Godot IRC For Twitch"
|
||||||
description="Godot websocket implementation for Twitch IRC."
|
description="Godot websocket implementation for Twitch IRC."
|
||||||
author="issork"
|
author="issork"
|
||||||
version="2.0.0"
|
version="2.0.1"
|
||||||
script="gift.gd"
|
script="gift.gd"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user