updated README and LICENSE
This commit is contained in:
parent
a615a60909
commit
dc070e8cb1
2
Gift.gd
2
Gift.gd
@ -71,7 +71,7 @@ func _ready() -> void:
|
||||
|
||||
# Send a chat message to the only connected channel (<channel_name>)
|
||||
# Fails, if connected to more than one channel.
|
||||
# gchat("TEST")
|
||||
# chat("TEST")
|
||||
|
||||
# Send a chat message to channel <channel_name>
|
||||
# chat("TEST", initial_channel)
|
||||
|
2
LICENSE
2
LICENSE
@ -1,6 +1,6 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019-2021 Max Kross
|
||||
Copyright (c) 2019-2023 Max Kross
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
156
README.md
156
README.md
@ -1,6 +1,8 @@
|
||||
# GIFT
|
||||
Godot IRC For Twitch addon
|
||||
|
||||
If you require help, feel free to join my >[Discord Server](https://discord.gg/28DQbuwMM2)< and ask your questions <3
|
||||
|
||||
- [Examples](https://github.com/MennoMax/gift#Examples)
|
||||
- [API](https://github.com/MennoMax/gift#API)
|
||||
- [Exported Variables](https://github.com/MennoMax/gift#Exported-Variables)
|
||||
@ -21,89 +23,114 @@ The following code is also [included](https://github.com/MennoMax/gift/blob/mast
|
||||
extends Gift
|
||||
|
||||
func _ready() -> void:
|
||||
connect("cmd_no_permission", self, "no_permission")
|
||||
connect_to_twitch()
|
||||
yield(self, "twitch_connected")
|
||||
super._ready()
|
||||
cmd_no_permission.connect(no_permission)
|
||||
chat_message.connect(on_chat)
|
||||
|
||||
# Login using your username and an oauth token.
|
||||
# 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>)
|
||||
if(yield(self, "login_attempt") == false):
|
||||
print("Invalid username or token.")
|
||||
return
|
||||
join_channel(<channel_name>)
|
||||
# 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 := FileAccess.open("./auth", FileAccess.READ)
|
||||
var botname := authfile.get_line()
|
||||
var token := authfile.get_line()
|
||||
var initial_channel = authfile.get_line()
|
||||
|
||||
# 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)
|
||||
connect_to_twitch()
|
||||
await(twitch_connected)
|
||||
|
||||
# These two commands can be executed by everyone
|
||||
add_command("helloworld", self, "hello_world")
|
||||
add_command("greetme", self, "greet_me")
|
||||
# Login using your username and an oauth token.
|
||||
# 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(botname, token)
|
||||
request_caps()
|
||||
if(await(login_attempt) == false):
|
||||
print("Invalid username or token.")
|
||||
return
|
||||
join_channel(initial_channel)
|
||||
|
||||
# This command can only be executed by the streamer
|
||||
add_command("streamer_only", self, "streamer_only", 0, 0, PermissionFlag.STREAMER)
|
||||
# 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 PackedStringArray
|
||||
# This command can only be executed by VIPS/MODS/SUBS/STREAMER
|
||||
add_command("test", command_test, 0, 0, PermissionFlag.NON_REGULAR)
|
||||
|
||||
# Command that requires exactly 1 arg.
|
||||
add_command("greet", self, "greet", 1, 1)
|
||||
# These two commands can be executed by everyone
|
||||
add_command("helloworld", hello_world)
|
||||
add_command("greetme", greet_me)
|
||||
|
||||
# Command that prints every arg seperated by a comma (infinite args allowed), at least 2 required
|
||||
add_command("list", self, "list", -1, 2)
|
||||
# This command can only be executed by the streamer
|
||||
add_command("streamer_only", streamer_only, 0, 0, PermissionFlag.STREAMER)
|
||||
|
||||
# Adds a command alias
|
||||
add_alias("test","test1")
|
||||
add_alias("test","test2")
|
||||
add_alias("test","test3")
|
||||
# Or do it in a single line
|
||||
# add_aliases("test", ["test1", "test2", "test3"])
|
||||
# Command that requires exactly 1 arg.
|
||||
add_command("greet", greet, 1, 1)
|
||||
|
||||
# Remove a single command
|
||||
remove_command("test2")
|
||||
# Command that prints every arg seperated by a comma (infinite args allowed), at least 2 required
|
||||
add_command("list", list, -1, 2)
|
||||
|
||||
# Now only knows commands "test", "test1" and "test3"
|
||||
remove_command("test")
|
||||
# Now only knows commands "test1" and "test3"
|
||||
# Adds a command alias
|
||||
add_alias("test","test1")
|
||||
add_alias("test","test2")
|
||||
add_alias("test","test3")
|
||||
# Or do it in a single line
|
||||
# add_aliases("test", ["test1", "test2", "test3"])
|
||||
|
||||
# Remove all commands that call the same function as the specified command
|
||||
purge_command("test1")
|
||||
# Now no "test" command is known
|
||||
# Remove a single command
|
||||
remove_command("test2")
|
||||
|
||||
# Send a chat message to the only connected channel (<channel_name>)
|
||||
# Fails, if connected to more than one channel.
|
||||
chat("TEST")
|
||||
# Now only knows commands "test", "test1" and "test3"
|
||||
remove_command("test")
|
||||
# Now only knows commands "test1" and "test3"
|
||||
|
||||
# Send a chat message to channel <channel_name>
|
||||
chat("TEST", <channel_name>)
|
||||
# Remove all commands that call the same function as the specified command
|
||||
purge_command("test1")
|
||||
# Now no "test" command is known
|
||||
|
||||
# Send a whisper to target user
|
||||
whisper("TEST", <target_name>)
|
||||
# Send a chat message to the only connected channel (<channel_name>)
|
||||
# Fails, if connected to more than one channel.
|
||||
# chat("TEST")
|
||||
|
||||
# Send a chat message to channel <channel_name>
|
||||
# chat("TEST", initial_channel)
|
||||
|
||||
# Send a whisper to target user
|
||||
# whisper("TEST", initial_channel)
|
||||
|
||||
func on_chat(data : SenderData, msg : String) -> void:
|
||||
%ChatContainer.put_chat(data, msg)
|
||||
|
||||
# Check the CommandInfo class for the available info of the cmd_info.
|
||||
func command_test(cmd_info : CommandInfo) -> void:
|
||||
print("A")
|
||||
print("A")
|
||||
|
||||
func hello_world(cmd_info : CommandInfo) -> void:
|
||||
chat("HELLO WORLD!")
|
||||
chat("HELLO WORLD!")
|
||||
|
||||
func streamer_only(cmd_info : CommandInfo) -> void:
|
||||
chat("Streamer command executed")
|
||||
chat("Streamer command executed")
|
||||
|
||||
func no_permission(cmd_info : CommandInfo) -> void:
|
||||
chat("NO PERMISSION!")
|
||||
chat("NO PERMISSION!")
|
||||
|
||||
func greet(cmd_info : CommandInfo, arg_ary : PoolStringArray) -> void:
|
||||
chat("Greetings, " + arg_ary[0])
|
||||
func greet(cmd_info : CommandInfo, arg_ary : PackedStringArray) -> void:
|
||||
chat("Greetings, " + arg_ary[0])
|
||||
|
||||
func greet_me(cmd_info : CommandInfo) -> void:
|
||||
chat("Greetings, " + cmd_info.sender_data.tags["display-name"] + "!")
|
||||
chat("Greetings, " + cmd_info.sender_data.tags["display-name"] + "!")
|
||||
|
||||
func list(cmd_info : CommandInfo, arg_ary : PackedStringArray) -> void:
|
||||
var msg = ""
|
||||
for i in arg_ary.size() - 1:
|
||||
msg += arg_ary[i]
|
||||
msg += ", "
|
||||
msg += arg_ary[arg_ary.size() - 1]
|
||||
chat(msg)
|
||||
|
||||
func list(cmd_info : CommandInfo, arg_ary : PoolStringArray) -> void:
|
||||
chat(arg_ary.join(", "))
|
||||
|
||||
```
|
||||
|
||||
@ -112,10 +139,8 @@ func list(cmd_info : CommandInfo, arg_ary : PoolStringArray) -> void:
|
||||
## API
|
||||
|
||||
### Exported Variables
|
||||
- **command_prefix**: PoolStringArray - Prefixes for commands. Every message that starts with one of these will be interpreted as one.
|
||||
- **command_prefix**: PackedStringArray - Prefixes for commands. Every message that starts with one of these will be interpreted as one.
|
||||
- **chat_timeout** : float - Time to wait before sending the next chat message. Values below ~0.31 will lead to a disconnect at 100 messages in the queue.
|
||||
- **get_badges** : bool - Wether or not badges should be downloaded and cached in RAM.
|
||||
- **get_emotes** : bool - Wether or not emotes should be downloaded and cached in RAM.
|
||||
- **disk_cache** : bool - If true, badges and emotes will be cached on the disk instead.
|
||||
- **disk_cache_path** : String - Path to the cache folder on the hard drive.
|
||||
|
||||
@ -129,11 +154,11 @@ func list(cmd_info : CommandInfo, arg_ary : PoolStringArray) -> void:
|
||||
|twitch_unavailbale|-|Could not establish a connection to Twitch.|
|
||||
|twitch_reconnect|-|Twitch requested the client to reconnect. (Will be unavailable until next connect)|
|
||||
|login_attempt|success(bool) - wether or not the login attempt was successful|The client tried to login.|
|
||||
|chat_message|sender_data(SenderData), message(String), channel(String)|User sent a message in chat.|
|
||||
|whisper_message|sender_data(SenderData), message(String), channel(String)|User sent a whisper message.|
|
||||
|chat_message|sender_data(SenderData), message(String)|User sent a message in chat.|
|
||||
|whisper_message|sender_data(SenderData), message(String)|User sent a whisper message.|
|
||||
|unhandled message|message(String), tags(Dictionary)|Unhandled message from Twitch.|
|
||||
|cmd_invalid_argcount|cmd_name(String), sender_data(SenderData), cmd_data(CommandData), arg_ary(PoolStringArray)|A command has been called by a chatter with an invalid amount of args.|
|
||||
|cmd_no_permission|cmd_name(String), sender_data(SenderData), cmd_data(CommandData), arg_ary(PoolStringArray)|A command has been called by a chater without having the required permissions.|
|
||||
|cmd_invalid_argcount|cmd_name(String), sender_data(SenderData), cmd_data(CommandData), arg_ary(PackedStringArray)|A command has been called by a chatter with an invalid amount of args.|
|
||||
|cmd_no_permission|cmd_name(String), sender_data(SenderData), cmd_data(CommandData), arg_ary(PackedStringArray)|A command has been called by a chatter without having the required permissions.|
|
||||
|pong|-|A ping from Twitch has been answered with a pong.|
|
||||
|
||||
***
|
||||
@ -142,10 +167,11 @@ func list(cmd_info : CommandInfo, arg_ary : PoolStringArray) -> void:
|
||||
|Function|Params|Description|
|
||||
|-|-|-|
|
||||
|authenticate_oauth|nick(String) - the accoutns username, token(String) - your oauth token|Authenticate yourself to use the Twitch API. Check out https://twitchapps.com/tokengen/ to generate a token.|
|
||||
|request_caps|caps(String) - capabilities to request from twitch|Request capabilities from Twitch.|
|
||||
|send|text(string) - the UTF8-String that should be sent to Twitch|Sends a UTF8-String to Twitch over the websocket.|
|
||||
|chat|message(String), channel(String) - DEFAULT: Only connected channel|Sends a chat message to a channel.|
|
||||
|whisper|message(String), target(String)| Sends a whisper message to the specified user.|
|
||||
|add_command|cmd_name(String), instance(Object), instance_func(String), max_args(int), min_args(int), permission_level(int), where(int)| Registers a command with a function to call on a specified object. You can also set min/max args allowed and where (whisper or chat) the command execution should be allowed to be requested.|
|
||||
|add_command|cmd_name(String), function(Callable), max_args(int), min_args(int), permission_level(int), where(int)| Registers a command with a function to call on a specified object. You can also set min/max args allowed and where (whisper or chat) the command execution should be allowed to be requested.|
|
||||
|remove_command|cmd_name(String)|Removes a single command or alias from the command registry.|
|
||||
|purge_command|cmd_name(String)| Removes all commands that call the same function on the same object as the specified command.|
|
||||
|add_alias|cmd_name(String), alias(String)|Registers a command alias.|
|
||||
|
Loading…
x
Reference in New Issue
Block a user