Download the PHP package voniersa/twitch-live-chat without Composer
On this page you can find all versions of the php package voniersa/twitch-live-chat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download voniersa/twitch-live-chat
More information about voniersa/twitch-live-chat
Files in voniersa/twitch-live-chat
Package twitch-live-chat
Short Description A simple and easy to use library for reading from and writing to the twitch irc live chats by partially using the observer design pattern
License MIT
Informations about the package twitch-live-chat
Twitch Live Chat Library
A simple and easy to use library for reading from and writing to the twitch irc live chats by partially using the observer design pattern.
With this library you can easily build your own twitch chatbot with PHP.
Requirements
PHP Version 8.2 or higher
How to use
You can install the library with composer:
Functionalities
Firstly you have to create a new TwitchChatAdapter:
With this Adapter you can open a connection to twitch live chats by executing the openConnection() function. This function needs the parameters
- UserName - the username of your account which you want to use as your chatbot
- https://twitchtokengenerator.com/
- ChannelCollection - a collection of all channels where your chatbot should be active. A channel always needs a # in front of the channel name
You can open multiple connections with different users and channels.
To this connection you can add as many observers as you want by executing the detach() function to remove an observer.
You have to write the Observers by yourself. For that simply create a new class which implements the Message.
This update() method gets called everytime when a message is written to the live chats. Here you can define what should happen if a message appears.
To actually start reading the chat simply call the function MessageCollection which contains all messages that are written to the chat in that time period:
With this library you cannot only read from specific live chats. You can also write something to the chat by simply call the writeMessage() function.
Example
In the demo.php you can find a simple code snippet, how you can use this library.
To run this example script, execute the following command:
License
This library is released under the MIT Licence. See the bundled LICENSE file for details.
Author
Sascha Vonier (@voniersa)
All versions of twitch-live-chat with dependencies
ext-openssl Version *