Name |
ChatMessage
|
Type
| Method |
Summary
| Sends a message to a chat user (raw format) |
Prototype
| long ChatMessage(long ID, short Message, BSTR Text);
|
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.
Note: Available in version 3.37 onwards.
|
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.
|
Returns
| eChatIDNotFound: That chat ID is not connected
eOK: Sent OK
|
Introduced in version
| 3.37 |
Enter a word or phrase in the box below to narrow the list down to those that match.
The function name, prototype, summary, and description are searched.
Leave blank to show all functions.
Many functions return a "code" which indicates the success or otherwise
of the function.
The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).