[Home] [Downloads] [Search] [Help/forum]

MUSHclient scripting

Description of MUSHclient world function: world.ChatMessage


Name ChatMessage
Type Method
Summary Sends a message to a chat user (raw format)
Prototype long ChatMessage(long ID, short Message, BSTR Text);

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.


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

View list of return code meanings

Introduced in version 3.37

See also ...

Function Description
ChatEverybody Sends a chat message to every connected chat user
ChatGetID Looks up what chat ID (identifier) corresponds to a particular chat name
ChatGroup Sends a chat message to every connected chat user in the specified group
ChatID Sends a chat message to a particular chat session
ChatPasteEverybody Pastes the clipboard contents to every connected person
ChatPersonal Sends a chat message to a particular person
GetChatList Gets the list of chat sessions

Search for script function

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.

Search for:   

Leave blank to show all functions.


Return codes

Many functions return a "code" which indicates the success or otherwise of the function.

You can view a list of the return codes


Function prototypes

The "prototype" part of each function description lists exactly how the function is called (what arguments, if any, to pass to it).

You can view a list of the data types used in function prototypes


View all functions

[Back]

Quick links: MUSHclient. MUSHclient help. Forum shortcuts. Posting templates. Lua modules. Lua documentation.

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.

[Home]


Written by Nick Gammon - 5K   profile for Nick Gammon on Stack Exchange, a network of free, community-driven Q&A sites   Marriage equality

Comments to: Gammon Software support
[RH click to get RSS URL] Forum RSS feed ( https://gammon.com.au/rss/forum.xml )

[Best viewed with any browser - 2K]    [Hosted at FutureQuest]