Skip to content
This repository has been archived by the owner on Jul 30, 2024. It is now read-only.

How do I make the bot send custom messages? #302

Closed
ghost opened this issue May 27, 2013 · 5 comments
Closed

How do I make the bot send custom messages? #302

ghost opened this issue May 27, 2013 · 5 comments

Comments

@ghost
Copy link

ghost commented May 27, 2013

Hello there. Just wanted to ask how to make the bot sending custom messages? I mean, if the user say "Hello there", the bot should say something like "What's up?"

@DrProfAxesome
Copy link

The code you will want to add will go in the OnMessage Function.

What you want to do is add if and else if statements to read the message and see what it is.

For example:
if (message.StartsWith("Hello")
{
Bot.SteamFriends.SendChatMessage(OtherSID, type, "What's up?");
}

Then if you wanted to add more situations, just add else if's for other things the user might say

@StormReaper
Copy link
Contributor

Look at the OnMessage and OnTradeMessage methods in the AdminUserHandler or equivalent handlers.

@ghost
Copy link
Author

ghost commented May 27, 2013

Huh, still having problems with it. Can you explain where I have to put it?

@DrProfAxesome
Copy link

It will go inside the OnMessage function

@ghost
Copy link
Author

ghost commented May 27, 2013

Uh should it look like this? I think i've made it wrong because it doesn't work :c

public override void OnMessage (string message, EChatEntryType type)
{
Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse);
if (message.StartsWith("Hello")
{
Bot.SteamFriends.SendChatMessage(OtherSID, type, "What's up?");
}

@StormReaper
Copy link
Contributor

You have now 2 responses in the method, you can delete the default one

"Bot.SteamFriends.SendChatMessage(OtherSID, type, Bot.ChatResponse);"

And why doesn't it work? compiler error or is the bot not responding? also note this is for a steam chat response when talking through friends.

@DrProfAxesome
Copy link

What I would suggest is to, after you have included all of your custom responses, end with an else that responds with the default greeting. Also, like StormReaper said, this wont' work if you are messaging the bot while in a trade. For that you would have to use the OnTradeMessage function

@ghost
Copy link
Author

ghost commented May 27, 2013

Thanks to both of you I finally managed it. Thanks c:

@ghost ghost closed this as completed May 27, 2013
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants