ChatMessage
Script function

world.ChatMessage

DOC_scripting Read about scripting

Type

Method

Summary

Sends a message to a chat user (raw format)

Prototype

long ChatMessage(long ID, short Message, BSTR Text);

DOC_data_types View list of data type meanings


Description

This sends a "raw" chat message to the particular chat user identified by the chat ID.

You would not normally use this, as this is a low-level routine which is used by other script functions (such as ChatPersonal).

However you could use it to do custom chat messages (eg. use message number 200) which the receiving client could pick up in a plugin callback routine.

For an example of doing that, see:

http://www.gammon.com.au/mushclient/chat.htm#EXAMPLE

Another possible use would be to send chat messages with custom colours, or custom formatting (eg. different colours).

The "Message" argument is the chat message number, which is used at the start of the chat message. These numbers are currently defined:

1 Name_change
2 Request_connections
3 Connection_list
4 Text_everybody
5 Text_personal
6 Text_group
7 Message
8 Do_not_disturb
9 Send_action
10 Send_alias
11 Send_macro
12 Send_variable
13 Send_event
14 Send_gag
15 Send_highlight
16 Send_list
17 Send_array
18 Send_baritem
19 Version
20 File_start
21 File_deny
22 File_block_request
23 File_block
24 File_end
25 File_cancel
26 Ping_request
27 Ping_response
28 Peek_connections
29 Peek_list
30 Snoop
31 Snoop_data
105 Send_command

The "Text" argument is the text of the message to be sent. It can be empty. See the chat specifications for more details about what should be in the text field. You do *not* need to put the message number at the start of the text field, nor do you need to put the message terminator (hex FF) at the end of the text field. MUSHclient does that for you automatically.


Each call is identified by its "chat ID" - each chat session has a unique ID, which starts at one, and is incremented by one, per world.

You can use GetChatList to find a list of chat IDs that is current.

You can use ChatGetID to find the chat ID corresponding to a particular chat name.



VBscript example

ChatMessage ChatGetID ("fred"), 30, ""  ' start snooping Fred
'
'  do a custom coloured "chat to everybody" (using bold magenta)
'
' (The chat is only sent to connection Bruce, however)
'

ChatMessage ChatGetID ("bruce"), 4, _
             vbCrLf & ANSI (35) & ANSI (1) & _
             "<CHAT> The chat system is great!" & _
             vbCrLf



Jscript example

ChatMessage (ChatGetID ("fred"), 30, "");  // start snooping Fred
//
//  do a custom coloured "chat to everybody" (using bold magenta)
//
// (The chat is only sent to connection Bruce, however)

ChatMessage (ChatGetID ("bruce"), 4, 
             "\n" + ANSI (35) + ANSI (1) + 
             "<CHAT> The chat system is great!\n");



PerlScript example

ChatMessage (ChatGetID ("fred"), 30, "");  # start snooping Fred
#
#  do a custom coloured "chat to everybody" (using bold magenta)
#
# (The chat is only sent to connection Bruce, however)

ChatMessage (ChatGetID ("bruce"), 4, 
             "\n" . ANSI (35) . ANSI (1) . 
             "<CHAT> The chat system is great!\n");



Python example

world.ChatMessage (world.ChatGetID ("fred"), 30, "")  # start snooping Fred
#
#  do a custom coloured "chat to everybody" (using bold magenta)
#
# (The chat is only sent to connection Bruce, however)

world.ChatMessage (world.ChatGetID ("bruce"), 4, 
             "n" + world.ANSI (35) + world.ANSI (1) + 
             "<CHAT> The chat system is great!n")



Lua example

ChatMessage (ChatGetID ("fred"), 30)  -- start snooping Fred
--
--  do a custom coloured "chat to everybody" (using bold magenta)
--
-- (The chat is only sent to connection Bruce, however)

ChatMessage (ChatGetID ("bruce"), 4, 
             "n" .. ANSI (35) .. ANSI (1) .. 
             "<CHAT> The chat system is great!n")



Lua notes

The message is optional and defaults to the empty string.



Return value

eChatIDNotFound: That chat ID is not connected
eOK: Sent OK


DOC_errors View list of return code meanings


See Also ...

Topics

DOC_chat Chat system
DOC_starting Getting started

Functions

FNC_ChatAcceptCalls ChatAcceptCalls (Accepts incoming chat calls)
FNC_ChatCall ChatCall (Calls a chat server (makes an outgoing call) using the MudMaster chat protocol)
FNC_ChatCallzChat ChatCallzChat (Calls a zChat chat server (makes an outgoing call))
FNC_ChatDisconnect ChatDisconnect (Disconnects a current chat call)
FNC_ChatDisconnectAll ChatDisconnectAll (Disconnects all current chat calls)
FNC_ChatEverybody ChatEverybody (Sends a chat message to every connected chat user)
FNC_ChatGetID ChatGetID (Looks up what chat ID (identifier) corresponds to a particular chat name)
FNC_ChatGroup ChatGroup (Sends a chat message to every connected chat user in the specified group)
FNC_ChatID ChatID (Sends a chat message to a particular chat session)
FNC_ChatNameChange ChatNameChange (Changes your chat name)
FNC_ChatNote ChatNote (Does a note using ANSI codes for the chat system)
FNC_ChatPasteEverybody ChatPasteEverybody (Pastes the clipboard contents to every connected person)
FNC_ChatPasteText ChatPasteText (Pastes the clipboard contents to that person)
FNC_ChatPeekConnections ChatPeekConnections (Sends a "peek connections" message to the specified chat user)
FNC_ChatPersonal ChatPersonal (Sends a chat message to a particular person)
FNC_ChatPing ChatPing (Sends a ping message to the specified chat user)
FNC_ChatRequestConnections ChatRequestConnections (Sends a "request connections" message to the specified chat user)
FNC_ChatSendFile ChatSendFile (Starts sending a file to the specified chat user)
FNC_ChatStopAcceptingCalls ChatStopAcceptingCalls (Stops this world from accepting chat calls)
FNC_ChatStopFileTransfer ChatStopFileTransfer (Stops a file transfer in progress to that chat user)
FNC_GetChatInfo GetChatInfo (Get information about a chat connection)
FNC_GetChatList GetChatList (Gets the list of chat sessions)
FNC_GetChatOption GetChatOption (Gets the value of a chat session option)
FNC_SetChatOption SetChatOption (Sets the value of a chat session option)

(Help topic: function=ChatMessage)

DOC_contents Documentation contents page