Update README.md, missing changes

This commit is contained in:
MennoMax 2021-05-20 23:43:16 +02:00 committed by mennomax
parent b107c4901a
commit 65aacbcf2a
11 changed files with 36 additions and 46 deletions

View File

@ -1,3 +0,0 @@
source_md5="8dd9ff1eebf38898a54579d8c01b0a88"
dest_md5="da70afec3c66d4e872db67f808e12edb"

View File

@ -1,3 +0,0 @@
source_md5="a968f7207fa0b577199e591bee3d650b"
dest_md5="d352d63ef80c05346da08dcf324711fd"

View File

@ -13,12 +13,12 @@ func put_chat(senderdata : SenderData, msg : String):
for d in data[1].split(","):
var start_end = d.split("-")
locations.append(EmoteLocation.new(data[0], int(start_end[0]), int(start_end[1])))
locations.sort_custom(self, "greater")
locations.sort_custom(EmoteLocation, "smaller")
var offset = 0
for loc in locations:
var emote_string = "[img=center]" + $"../Gift".image_cache.get_emote(loc.id).resource_path +"[/img]"
msg = msg.substr(0, loc.start + offset) + emote_string + msg.substr(loc.end + offset + 1)
offset += emote_string.length() - loc.end - loc.start - 1
offset += emote_string.length() + loc.start - loc.end - 1
var bottom : bool = $Chat/ScrollContainer.scroll_vertical == $Chat/ScrollContainer.get_v_scrollbar().max_value - $Chat/ScrollContainer.get_v_scrollbar().rect_size.y
msgnode.set_msg(str(time["hour"]) + ":" + ("0" + str(time["minute"]) if time["minute"] < 10 else str(time["minute"])), senderdata, msg, badges)
$Chat/ScrollContainer/ChatMessagesContainer.add_child(msgnode)
@ -26,9 +26,6 @@ func put_chat(senderdata : SenderData, msg : String):
if (bottom):
$Chat/ScrollContainer.scroll_vertical = $Chat/ScrollContainer.get_v_scrollbar().max_value
func smaller(a : EmoteLocation, b : EmoteLocation):
return a.start < b.start
class EmoteLocation extends Reference:
var id : String
var start : int
@ -38,3 +35,6 @@ class EmoteLocation extends Reference:
self.id = emote_id
self.start = start_idx
self.end = end_idx
static func smaller(a : EmoteLocation, b : EmoteLocation):
return a.start < b.start

61
Gift.gd
View File

@ -1,7 +1,19 @@
extends Gift
func _ready() -> void:
connect("cmd_no_permission", self, "no_permission")
# I use a file in the working directory to store auth data
# so that I don't accidentally push it to the repository.
# Replace this or create a auth file with 3 lines in your
# project directory:
# <bot username>
# <oauth token>
# <initial channel>
var authfile := File.new()
authfile.open("./auth", File.READ)
var botname := authfile.get_line()
var token := authfile.get_line()
var initial_channel = authfile.get_line()
connect_to_twitch()
yield(self, "twitch_connected")
@ -9,31 +21,34 @@ func _ready() -> void:
# You will have to either get a oauth token yourself or use
# https://twitchapps.com/tokengen/
# to generate a token with custom scopes.
authenticate_oauth("<account_name>", "<oauth_token>")
authenticate_oauth(botname, token)
if(yield(self, "login_attempt") == false):
print("Invalid username or token.")
return
join_channel("<channel_name>")
join_channel(initial_channel)
connect("cmd_no_permission", get_parent(), "no_permission")
connect("chat_message", get_parent(), "chat_message")
# Adds a command with a specified permission flag.
# All implementations must take at least one arg for the command info.
# Implementations that recieve args requrires two args,
# the second arg will contain all params in a PoolStringArray
# This command can only be executed by VIPS/MODS/SUBS/STREAMER
add_command("test", self, "command_test", 0, 0, PermissionFlag.NON_REGULAR)
add_command("test", get_parent(), "command_test", 0, 0, PermissionFlag.NON_REGULAR)
# These two commands can be executed by everyone
add_command("helloworld", self, "hello_world")
add_command("greetme", self, "greet_me")
add_command("helloworld", get_parent(), "hello_world")
add_command("greetme", get_parent(), "greet_me")
# This command can only be executed by the streamer
add_command("streamer_only", self, "streamer_only", 0, 0, PermissionFlag.STREAMER)
add_command("streamer_only", get_parent(), "streamer_only", 0, 0, PermissionFlag.STREAMER)
# Command that requires exactly 1 arg.
add_command("greet", self, "greet", 1, 1)
add_command("greet", get_parent(), "greet", 1, 1)
# Command that prints every arg seperated by a comma (infinite args allowed), at least 2 required
add_command("list", self, "list", -1, 2)
add_command("list", get_parent(), "list", -1, 2)
# Adds a command alias
add_alias("test","test1")
@ -55,32 +70,10 @@ func _ready() -> void:
# Send a chat message to the only connected channel (<channel_name>)
# Fails, if connected to more than one channel.
chat("TEST")
# chat("TEST")
# Send a chat message to channel <channel_name>
chat("TEST", "<channel_name>")
# chat("TEST", initial_channel)
# Send a whisper to target user
whisper("TEST", "<target_name>")
# Check the CommandInfo class for the available info of the cmd_info.
func command_test(cmd_info : CommandInfo) -> void:
print("A")
func hello_world(cmd_info : CommandInfo) -> void:
chat("HELLO WORLD!")
func streamer_only(cmd_info : CommandInfo) -> void:
chat("Streamer command executed")
func no_permission(cmd_info : CommandInfo) -> void:
chat("NO PERMISSION!")
func greet(cmd_info : CommandInfo, arg_ary : PoolStringArray) -> void:
chat("Greetings, " + arg_ary[0])
func greet_me(cmd_info : CommandInfo) -> void:
chat("Greetings, " + cmd_info.sender_data.tags["display-name"] + "!")
func list(cmd_info : CommandInfo, arg_ary : PoolStringArray) -> void:
chat(arg_ary.join(", "))
# whisper("TEST", initial_channel)

View File

@ -10,6 +10,10 @@ Godot IRC For Twitch addon
***
Below is a working example of this plugin, which is included in this project. A replication of the twitch chat.
![image](https://user-images.githubusercontent.com/12477395/119052327-b9fc9980-b9c4-11eb-8f45-a2a8f2d98977.png)
### Examples
The following code is also [included](https://github.com/MennoMax/gift/blob/master/Gift.gd) in this repository.

View File

@ -81,7 +81,6 @@ func _ready() -> void:
websocket.connect("connection_error", self, "connection_error")
if(get_images):
image_cache = ImageCache.new(disk_cache, disk_cache_path)
# add_child(image_cache)
func connect_to_twitch() -> void:
if(websocket.connect_to_url("wss://irc-ws.chat.twitch.tv:443") != OK):

Binary file not shown.

Before

Width:  |  Height:  |  Size: 363 B

After

Width:  |  Height:  |  Size: 2.0 KiB

0
addons/gift/icon.png.import Executable file → Normal file
View File

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.4 KiB

After

Width:  |  Height:  |  Size: 2.1 KiB