@laboralphy/o876-txat
v1.3.2
Published
An embeddable chat library, multi channels, moderation, event based
Readme
O876 TXAT
Classes
TxatManager
This class acts as a front-class providing method to controls all other chat sub classes.
Channel
A channel gather all user that wish to talk about a specific topic.
Message
A message sent by a user. Can be public or private. Public messages are sent to all users connected to a channel. Private messages are sent to only one user.
Properties
- content {string} : Message content
- sender {User} : User who sent this message
- timestamp {integet} : When this message has been sent.
User
A user connected to chat manager. This class holds all information about a user.
Properties
- id {string} : user identifier
- name {string} : user display name
- connected {boolean} : true if user is currently connected
- data {object} : a simple objet to hold data
Ban
A user may be banned from a channel, this prevents them to joined the channel again. This is a functionnality used to expel user that infringe channel rules of conduct. This class holds all data about a ban.
Properties
- user {User} : instance of banned user
- reason {string} : The reason why this user is banned
- until {Date} : Date time when user will be able to come back to channel
- permanent {boolean} : If true the ban is permanent, and the user can never go back to the channel unless a moderator cancels the ban.
- banner {User} : Instance of user who has created the ban.
Events from TxatManager
EVENT_CHANNEL_MESSAGE
Type: Communication event This event is sent to all users connected to the channel.
- recipient {string} : Id of user whose message must be sent.
- channel {Channel} : channel on which the message is being sent.
- message {Message} : message composed by the speaking user.
EVENT_USER_BANNED
Type: Communication event This event is an information about a user being banned from a channel.
- recipient {string} : Id of user whose message must be sent - this is NOT the banned user instance.
- channel {Channel} : channel from which the user is banned.
- ban {Ban} : all information about the ban (see class Ban).
EVENT_USER_UNBANNED
Type: Communication event This event is an information about a user ban being cancelled.
- recipient {string} : Id of recipient whose message must be delivered - this is NOT the banned user instance.
- user {User} : instance of user being unbanned.
- channel {Channel} : channel from which the user was banned, and now unbanned.
EVENT_USER_JOINED_CHANNEL
Type: Communication event This event is sent when a user joins a channel.
- recipient {string} : Id of recipient whose message must be delivered.
- channel {Channel} : channel joined by user.
- user {User} : Instance of user joining the channel.
EVENT_USER_LEFT_CHANNEL
Type: Communication event This event is sent when a user leaves a channel.
- recipient {string} : Id of recipient whose message must be delivered.
- channel {Channel} : channel left by user.
- user {User} : Instance of user leaving the channel.
EVENT_USER_INVITED
Type: Communication event Event sent when a channel moderator, admin, or host, invites a user to join the channel. The user joins immediatly the channel.
- recipient {string} : Id of recipient whose message must be delivered
- channel {Channel} : Instance of channel which user is invited to.
- user {User} : Invited user instance.
EVENT_USER_INSUFFICIENT_CAPABILITY
Type: Technical event This event is fired when a user cannot use functionality. This is because use has not a sufficient rank to use a specific command. Ex: a user with rank : USER_RANK_CHATTER will fire this event if it tries to change topic, or ban another user.
- user {User} : Instance of user who tries to use functionality
- capability {string} : capability in cause
- channel {Channel} : channel where user is trying to use functionality
EVENT_CHANNEL_CREATED
Type: Technical event This event is fired when a new channel is created.
- channel {Channel} : instance of new channel
EVENT_CHANNEL_DESTROYED
Type: Technical event This event is fired when a channel is destroyed.
- channel {Channel} : instance of channel being destroyed
EVENT_USER_RECEIVE_PRIVATE_MESSAGE
Type: Communication event This event is fired when a user sends a message directly to another user.
- recipient {string} : id of user whose message is sent
- message {Message} : Message composed.
EVENT_USER_CONNECTED
This event is fired when a user connects to the chat system.
- user {User} : instance of user newly connected
EVENT_USER_DISCONNECTED
This event is fired when a user disconnects from the chat system.
- user {User} : instance of user disconnection from server
