Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using BattleCore;
- using BattleCore.Events;
- using BattleCorePsyOps;
- using System.Timers;
- namespace PsyModules
- {
- // Add the attribute and the base class
- [Behavior("ChatBridge", "true", "0.01", "PsyOps", "A cross biller chat bridge.")]
- public class ChatBridge:BotEventListener
- {
- public ChatBridge()
- {
- RegisterTimedEvent("MainTimer", 10, updateMainTimer);
- }
- string ChatLoginCommand = "?chat=BattleDev,Battle,Alpha,specrpg,";
- bool Initialized = false;
- // Custom module to help with chatevents mainly
- ShortChat msg = new ShortChat();
- // Stores botname and arena
- string BotName, Arena = "";
- // -------------------------------------------------------- SS GAME EVENTS //
- // ------------------------------------------------------------------------//
- // Monitor all incoming chat events
- public void MonitorChatEvents(object sender, ChatEvent c)
- {
- // Core sends each bot a pm with its own info 500ms after startup
- // I use it to initialize bot
- if (c.ChatType == ChatTypes.Private && c.Message.StartsWith("@BotInfo@"))
- // Initialize everything needed to get bot started
- InitializeBot(c.Message.Split(':')[1], c.Message.Split(':')[2]);
- else if (c.ChatType == ChatTypes.Arena && c.Message.StartsWith("This arena is Continuum-only. Please get Continuum client"))
- {
- DateTime time = DateTime.Now;
- if (!Initialized)
- {
- Game(msg.pub(ChatLoginCommand));
- Game(msg.arena("Login Detected! - " + time.ToString(" H:mm:ss ")));
- }
- else
- {
- Game(msg.pub(ChatLoginCommand));
- Game(msg.arena("Bot recovered from a crash! -" + time.ToString(" H:mm:ss ")));
- }
- }
- else if (c.ChatType == ChatTypes.Channel)
- {
- if (c.PlayerName == null) return;
- if (c.PlayerName.Length <= 0)
- {
- c.PlayerName = BotName;
- c.PlayerId = ushort.Parse(c.Message.Substring(0, c.Message.IndexOf(':')));
- SendCoreEvent(c);
- }
- else if (c.PlayerName != BotName)
- {
- msg.FormatMessage(c);
- c.Message = "<SZ> "+ c.PlayerName+ "> " + c.Message;
- msg.SCChanMessage((byte)c.PlayerId, c.Message);
- //Game(msg.chan((byte)c.PlayerId,c.Message));
- }
- }
- }
- // Initialize bot for first time
- public void InitializeBot(string BotName, string Arena)
- {
- this.BotName = BotName;
- this.Arena = Arena;
- // debug mode set to true
- msg.DebugMode = true;
- // make sure spam control is on for module
- msg.SpamControl = true;
- // Turn game on
- Initialized = true;
- // update chat with bot initialized msg
- msg.SCChanMessage(1, BotName + " initialized.");
- }
- //public void updateMainTimer(object sender, ElapsedEventArgs e)
- public void updateMainTimer()
- {
- // Check to see if we have any commands in our command chat q
- if (msg.NeedUpdate && Initialized) Game(msg.sendNextBCommand());
- }
- public override void Dispose()
- {
- throw new NotImplementedException();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement