title: How to make the bot know if its messaged someone before? C# based SteamBot
body: <p>Ok, firstly, I'm not very advanced at this, xD</p>
  
  <p>In <code>public override void OnMessage (string message, EChatEntryType type)</code> I want to execute a series of tests to figure out which response to send. </p>
  
  <ol>
  <li><p>The first test is to see if the message starts with a command. I'm an admin for a CSGO server group called "Warmup Servers" and this will be a string of parts which will generate and feed back information into a separate log file. </p></li>
  <li><p>So I'm working on a custom <code>UserHandler.cs</code> for my steambot. I plan on writing a simple script, so that I can do <code>exec [botname] TGTOnline</code> &amp; <code>exec [botname] TGTOffline</code> to tell the bot if using its account. (Like playing games or something on that account).</p></li>
  <li><p>To test if the message starts with any of the predefined responses. (More to be added later)</p></li>
  <li><p>To test if the bot has sent a message before. I don't want someone to start a conversation with me and the bot to be sending its default response every time it recieves a message, it would be annoying for both parties. </p></li>
  </ol>
  
  <p>So before the default message is called, I need to have a function which checks to see if the bot account (Both bot response or human response) has sent a message to the user recently (Last 5 Minutes) and if it has, tell the bot to do nothing...</p>
  
  <p>However I have no clue on where to start with this script and would love some advice!</p>
  
  <p>Here is my <code>TGTUserHandler.cs</code> section which relates:</p>
  
  <pre><code>using System;
  using SteamKit2;
  using System.Threading.Tasks;
  using System.Collections.Generic;
  using SteamTrade;
  using SteamTrade.TradeOffer;
  using SteamTrade.TradeWebAPI;
  
  namespace SteamBot
  {
      public class TGTUserHandler : UserHandler
      {
          private bool TGTOnline = false;
          private TaskCompletionSource&lt;string&gt; _UserReport;
          public TGTUserHandler(Bot bot, SteamID sid) : base(bot, sid) { }
  
          private bool HandleUserReport(string message)
          {
              if (_UserReport == null)
                  return false;
  
              //to be scripted in the morning
              _UserReport = null;
              return true;
          }
  
         public override void OnMessage(string message, EChatEntryType type)
          {
              if (message.StartsWith("!"))
              {
                  if (message.StartsWith("!help"))
                  {
                      SendChatMessage("Welcome to the TGTGaming Automated Bots, We have very limited commands and currently do not do any type of automated trade. Here is the list of current commands you can use:");
                      SendChatMessage("!WarmupServers [help | Report | Issue] | This command is used for all issues related to the WarmupServer's. Do `!Warmupservers help` for more information");
                      SendChatMessage("!getadmin | This command is used to contact a TGTGaming administrator. Please do `!getadmin help` for more information");
                  }
                  if (message.StartsWith("!WarmupServers"))
                  {
                      if (message.StartsWith("!WarmupServers help"))
                      {
                          SendChatMessage("Warmup Servers Automated Support by TGTGamer");
                          SendChatMessage("Commands:");
                          SendChatMessage("!WarmupServers Report | Used to report a user for specific reasons. This is step by step process");
                          SendChatMessage("!WarmupServers issue | Used to report a issue with the servers. This is a step by step process");
                      }
                      if (message.StartsWith("!WarmupServers Report"))
                      {
                         GetUserResponse("You have started the user reporting process, please confirm this is what you wanted to do. [y/n]");
                         if (message.StartsWith("y"))
                         {
                              SendChatMessage("A few quick questions first, please respond yes or no");
                              GetUserResponse("Are you still in the server?");
                              if (message.StartsWith("y"))
                              {
                                  GetUserResponse("Is the User you wish to report still in your server?");
                                  if (message.StartsWith("y"))
                                  {
                                      GetUserResponse("Is there a VIP in the server?");
                                      if (message.StartsWith("y"))
                                      {
                                          SendChatMessage("Please ask the VIP to do a !startvote on this user with your reason.");
                                      }
                                      else
                                      {
                                          _UserReport = new TaskCompletionSource&lt;string&gt;();
                                          return _UserReport.Task;
                                      }
                                  }
                                  else
                                  {
                                      _UserReport = new TaskCompletionSource&lt;string&gt;();
                                      return _UserReport.Task;
                                  }
                              }
                              else
                              {
                                  _UserReport = new TaskCompletionSource&lt;string&gt;();
                                  return _UserReport.Task;
                              }
                         }
                         else
                         {
                              SendChatMessage("You have cancelled this action");
                         }
                      }
                  }
              }
              else
              {
                  if (TGTOnline)
                  {
                      //general Responses
                      if (message.StartsWith("Hello"))
                      {
                          SendChatMessage("What's up?");
                      }
                      if (message.StartsWith("Heya"))
                      {
                          SendChatMessage("Hello");
                      }
                      if (message.StartsWith("Hi"))
                      {
                          SendChatMessage("Heya");
                      }
                      else
                      {
                          //defualt response
                          SendChatMessage(Bot.ChatResponse);
                      }
                  }
                  else
                  {
                      //defualt response
                      SendChatMessage(Bot.ChatResponse);
                  }
              }
          }
      }
  }
  </code></pre>
  
  <p>All and any help will be appreciated.</p>
  
  <p>Kind regards. </p>
  
  <h2>TGT</h2>
  
  <p>External Links you may find useful:</p>
  
  <p>Bot Github: <a href="https://github.com/Jessecar96/SteamBot/" rel="nofollow noreferrer">https://github.com/Jessecar96/SteamBot/</a></p>
  
  <p>UserHandler.cs: <a href="https://github.com/Jessecar96/SteamBot/blob/master/SteamBot/UserHandler.cs" rel="nofollow noreferrer">https://github.com/Jessecar96/SteamBot/blob/master/SteamBot/UserHandler.cs</a></p>
  
  <p>Footnotes:</p>
  
  <p>Steam Subscriber Agreement:</p>
  
  <p>The steam Subscriber Agreement States the following: </p>
  
  <blockquote>
    <p>You may not use Cheats, automation software (bots), mods, hacks, or
    any other unauthorized third-party software, to modify or automate any
    Subscription Marketplace process.</p>
  </blockquote>
  
  <p>As I am using this bot to automate 3rd party server actions (Rcon Kick's, Server restarts &amp; such) it is within the steam subscriber agreement acceptance for bots. If I then started to sell or buy automatically with this bot, it would breach the subscriber agreement. </p>