SphtBot - version 3.01 build 540


Screenshot

Features

Download

About

  • SphtBot was primarily designed to be an efficient Battle.net chat bot, with a BotNet layer for clan and database management, which supports logging on to Battle.net as StarCraft, Brood War, Japan StarCraft, Warcraft II, Diablo II, Lord of Destruction, Warcraft III, and The Frozen Throne; as well as the classic games Diablo, Diablo Shareware, StarCraft shareware, and the experimental text-mode gateway.
  • Support for the enhanced "Kp_Version_1" BotNet protocol (with backward compatibility for all previous server revisions), the BinaryChat plugin API, multiple account profiles, local and remote (BNLS) version checking, SOCKS4/5 and HTTP proxies, Diablo II realm and game server, the WebChannel ISAPI, SVP (short visit protection) standard, and various chat encryption standards.
  • Offers a basic, but highly useful and functional Internet Relay Chat (IRC) client which operates concurrently within the main UI much like BotNet. Note: If you intend to use the IRC client in several active channels, while also on Battle.net, you may want to set up a separate dedicated profile for IRC to reduce on-screen clutter.
  • Supports downloading and rendering backward/forward-order icons.bni. Also supports all the Warcraft III (including World Cyber Games), StarCraft, Warcraft II, and classic Diablo icons.

Installation and notes

  • Download and extract the contents of the zip to your personal SphtBot directory. If SphtBot fails to launch, you may be missing some required run-time DLLs. Download and install.
  • The first time you run SphtBot, you will be prompted for various information that is required for the Battle.net connection. You should fill in the information that is relative to the product(s) which you intend to log on as. Please note that SphtBot stores a separate CD-key for every product, so you should select a product from the dropdown before entering a CD-key for it.
  • Enable "Connect to Battle.net" to automatically connect to Battle.net when the bot starts up. /forceconnect is a useful command to override any delays caused by subsequent failed connection attempts.
  • You can enter multiple comma-delimited addresses for Battle.net and BNLS, and bot will randomly choose an address each time.
  • Use /display to configure basic color settings to your likings. If colorful names is enabled, a unique color is computed for each user and IRC #channel which is consistent for all iterations of SphtBot.
  • Navigate the registry to access many additional settings (HKEY_CURRENT_USER\Software\Valhalla's Legends\Spht\SphtBot). When making changes to the registry, /reload will be sufficient for most options, but generally the bot should be restarted.
  • Bot will download and use icons.bni and icons_STAR.bni if it is available. You can also use classic_icons.bni for additional icons. Open the About dialog to view all icons that are currently loaded into memory.
  • Supports logging on with a pre-hashed password (X-SHA1 logon protocol only). To use this, you must specify a password in the format SHA1:<40 hex characters>. Use /randsha1 to generate a random password.
  • The official Battle.net Logon Server (BNLS) is no longer active, so you should use a trusted and reliable third-party server. BNLS is optional and only used for version checking so users need not worry about juggling and updating game files. CD-key and password hashing is performed locally for all products so sensitive information is never transmitted plain-text over the network.

Creating a profile

  • Launching the executable directly (with no command-line) will open the default profile. Simply run SphtBot with the command-line "myprofile" (no spaces) to create or launch a separate configuration profile, where "myprofile" (in quotes) is the name of your profile. For your convenience, I recommend creating a Windows shortcut to SphtBot with the necessary command-lines for each profile you've created. You DO NOT need to create multiple copies of the exe to access additional profiles.

Battle.net Product Setup

Download and extract Storm.dll to your SphtBot installation directory. Depending on which product(s) you want to log on as, the following files will need to be copied into the appropriate directories (you may setup SphtBot to work with multiple products):
  • StarCraft/Brood War: Copy StarCraft.exe, Storm.dll, and Battle.snp from your StarCraft install into the subdirectory 'StarCraft' in SphtBot's installation directory.
  • Warcraft II: Battle.net Edition: Copy Warcraft II BNE.exe, Storm.dll, and Battle.snp from your Warcraft II install into the subdirectory 'War2BNE' in SphtBot's installation directory.
  • Diablo II: Copy Game.exe (and optionally D2client.dll and Bnclient.dll if emulating older versions) from your Diablo II install into the subdirectory 'Diablo II' in SphtBot's installation directory.
  • Diablo II: Lord of Destruction: Copy Game.exe from your Lord of Destruction install into the subdirectory 'Lord of Destruction' in SphtBot's installation directory.
  • Japanese StarCraft: Copy StarCraftJ.exe, Storm.dll, and Battle.snp from your Japanese StarCraft install into the subdirectory 'Japan StarCraft' in SphtBot's installation directory.
  • Warcraft III and The Frozen Throne: Copy Warcraft III.exe (and optionally Storm.dll and Game.dll if emulating older versions) from your Warcraft III install into the subdirectory 'Warcraft III' in SphtBot's installation directory.
  • Diablo (classic): Copy Diablo.exe (and/or Diablo_s.exe for Shareware), Storm.dll, Battle.snp from your Diablo install into the subdirectory 'Diablo' in SphtBot's installation directory.
  • StarCraft Shareware: Copy StarCraft.exe, Storm.dll, and Battle.snp from your StarCraft Shareware install into the subdirectory 'StarCraft Shareware' in SphtBot's installation directory.

Known issues

  • Bot may sometimes appear out of sight when using multiple monitors. Close the bot, locate and edit registry setting "Window options" (KEY_CURRENT_USER\Software\Valhalla's Legends\Spht\SphtBot) and set it to 4 or 5, whichever works best.
  • There has been several changes to classic Battle.net's infrastructure over the past couple years:
    • The official Battle.net servers now use a new logon method for StarCraft involving Blizzard accounts which is currently not supported.
    • Battle.net's new anti-spam system will sometimes drop messages arbitrarily without notifying the user, even if you aren't necessarily "spamming". There is currently no implemented solution to determine on the fly when this is happening. Tip: It currently appears that you will always get messages from users on your /friends list.
    • Your CD-key may still be "in use" after reconnecting. CD-key usage tends to linger sometimes for a couple minutes after disconnecting.
    • You can only use one non-Warcraft3 CD-key at a time on Battle.net now (instead of one per gateway), and the 8 connection limit is no longer per-gateway either. Also, CD-key spawning has been disabled for Warcraft II.
    • There are several new restrictions, autobans, server-specific temporary CD-key/account bans, etc. I recommend entering multiple comma-delimited Battle.net servers for the bot to choose from to automatically evade some of these problems. Eg: 199.108.55.57, 199.108.55.58, 199.108.55.59 instead of useast.battle.net since the DNS can often resolve to the same address for hours at a time.
  • You may sometimes get IP banned from Battle.net through no fault of your own. My sincerest apologies for the immense sense of acute hopelessness you feel when this happens.

Commands which can be entered using the user-input box

/botnetinfo <botnet user> *** Displays information about a BotNet user
/bnd [<msg>] *** Sends a message to everyone on the BotNet who is in your database. If <msg> is omitted, enables chat lock for BotNet
/bnc [<msg>] *** Sends a message to everyone on the BotNet (must be ADMIN). If <msg> is omitted, enables chat lock for BotNet
/med <msg> *** Emotes a message to the BotNet database
/meb <msg> *** Emotes a message to the entire BotNet (must be ADMIN)
/bnw <botnet user> <msg> *** Sends a message to a bot (must be on a database for user to receive message)
/mew <botnet user> <msg> *** Emotes a message to a bot (must be on a database for user to receive message)
/botnet <source> <cmd> *** Sends a command to all bots on current database
/broadcast <source> <cmd> *** Sends a command to all bots (must be ADMIN to send outside of database)
/botnetmessage <source> <botnet user> <cmd> *** Sends a command to a bot (must be ADMIN to send outside of database)
/setuser <usermask> [operation]<flags> *** Modifies a database entry, removes a database entry, or creates a database entry
/deluser <usermask> *** Deletes a database entry
/find <usermask> *** Finds and lists all flags which apply to a username/mask, and the entries which contribute them
/findex <user> *** Finds and lists flags which specifically apply to the specified username alone
/findname <usermask> *** Finds and lists all names which match the specified usermask
/findin <user> *** Finds and lists all usermasks that match the specified username while excluding the specific username
/findattr <flags> *** Lists all entries with the specified attributes
/countattr <flags> *** Returns number of entries with the specified attributes
/expattr <usermask> <flags> *** Finds and lists masks which apply to username to show specifically why username has specified flags
/setchatlock <bnd|bnc|battlenet|#channel> *** Sets where text is sent to by default
/setbnwlock <none|botnet user> *** Sets BotNet whisper lock
/bnr <msg> *** Whispers the user that last whispered you over BotNet
/bnrw <msg> *** Whispers the user that you last messaged over BotNet
/chatdropoptions *** Displays the current BotNet chat drop options
/setchatdropoptions <0|1|2> <0|1|2> <0|1|2> <0|1> *** Sets BotNet chat drop options. See BotNet protocol specification for more information
/botnetusers *** Displays the number of users connected to BotNet
/databaseusers *** Displays the number of users in the database
/reconnect *** Reconnects to Battle.net
/forceconnect *** Forces a connect to Battle.net (bypasses any holds the bot has put on connecting)
/bnreconnect *** Reconnects to BotNet
/bnforceconnect *** Forces a connect to BotNet (bypasses any holds the bot has put on connecting)
/clearqueue *** Clears the chat queue
/clearscreen *** Clears the chat window
/battlenet [<msg>] *** Sends a message to Battle.net. If <msg> is omitted, enables chat lock for Battle.net
/fjoin *** Forces a channel join, ignoring any full / empty / restricted warnings
/rejoin [<channel>] *** Rejoins the current channel. Can be used to quickly adjust caps if rejoining an empty channel
/setwlock <user> *** Sets Battle.net whisperlock
/r <msg> *** Whispers the user that last whispered you
/rw <msg> *** Whispers the user that you last messaged
/profile <user> *** Displays a user's profile
/sysrecorddata <user> *** Queries system data on an account
/recorddata <user> *** Queries record data on an account
/ladderrecorddata <user> <product> *** Queries ladder record data on an account
/rawquery <user> <path> *** Queries a database entry on an account
/setvalue <user> <path>:<value> *** Sets a database entry on an account (must be ADMIN to write other accounts, or to write to non profile\ of your own account)
/ladderdata <type> <league> <sort> <starting rank> <count> *** Works for STAR/SEXP/W2BN/JSTR, can be used from ANY product. An invalid sort method will result in you being disconnected, but NOT ipbanned.
/laddersearch <username> <type> <league> <sort> *** Works for STAR/SEXP/W2BN/JSTR, can be used from ANY product. An invalid sort method will result in you being disconnected, but NOT ipbanned.
/downloadfile <ip>:<port> <filename> *** Downloads a file from Battle.net
/canceldownload *** Cancels a file download
/forcecanceldownload *** Forcefully cancels a file download
/downloadprogress *** Displays the progress of a file download
/uptime *** Displays various uptime statistics
/status *** Displays various system statistics
/version *** Displays the bot version
/networkstatus <battlenet|bnls|botnet|all> *** Displays various connection statistics
/listplugins *** Displays the loaded plugins
/loadplugin <filename> *** Loads a plugin
/unloadplugin <filename> *** Unloads a plugin
/reload *** Reloads configuration settings
/fbnr *** Queries information on the user that last whispered you over BotNet
/fbnrw *** Queries information on the user that you last messaged over BotNet
/fr *** Queries information on the user that last whispered you
/frw *** Queries information on the user that you last messaged
/refreshicons *** Reloads the icon files
/claninfo <user> *** Displays various information about a user's clan statistics
/ping <user> *** Displays a user's ping
/listgames
/gameinfo <title>
/gameinfop <title>{ctrl+tab}<password>
/news
/queryrealms *** Lists available realms
/mcplistgames *** Realm only
/mcpgameinfo <title> *** Realm only
/mcpmakegame <title> *** Realm only
/mcpjoingame <title> *** Realm only
/mcpleavegame *** Realm only
/mcpmotd *** Realm only
/mcpladderdata <type> <position> *** Realm only
/mcpladdersearch <username> <hardcore> <expansion> *** Realm only
/debug
/realmlogon <realm> *** Logs onto realm
/createchar <charactername> *** Creates a character
/logonchar <charactername> *** Logs on a character
/deletechar <charactername>
/listchars *** Can be used even after logging on as a character
/realmreconnect
/setstatstring <statstring> *** Updates your statstring in the channel
/copystatstring <user> *** Copies a user's statstring
/resetstatstring
/statchat <message> *** Sends a statchat message (Diablo only)
/poke <user>
/ktbpa *** Sends "#ktbpa" to Battle.net (Keep the Battle.net pride alive!)
/hex <message>
/des *** Sends 3DES encrypted chat
/rsa *** Sends RSA encrypted chat
/settarget <user> (user to encrypt rsa to, and for sending deskeys)
/listkeys *** Lists 3DES keys
/key *** Displays active 3DES key
/randomize <type stuff for randomizing deskey>
/sendkey <keyname or wildcard mask>
/makekey <keyname> (use randomize first)
/delkey <keyname or wildcard mask>
/setkey <keyname or wildcard mask, new active deskey>
/dmencrypt <message> *** Sends DMEncrypt-compatible text scrambling
/reverse <message> *** Sends "coolio" reverse
/rot13 <message> *** Sends ROT13-compatible text scrambling
/rot47 <message> *** Sends ROT47-compatible text scrambling
/showundecoded *** Toggles option to show undecoded text for text scrambling ciphers
/channels *** Lists available product-specific channels
/randsha1 *** Generates a random pre-hashed X-SHA1 password
/irc *** Sends a IRC command
/irclist *** Enables/disables the visual IRC channel list
/ircusers <#channel>
/ircboot <#channel> <user> [<message>]
/ircw <target> <message>
/irctrout <#channel> <target>
/ircnotify <on|off> *** Toggles IRC enter/leave notifications
/ircping <target>
/ircctcp <target> <request>
/ircsetfinger
/ircignoremask
/ircr *** Whispers the user that last whispered you.
/ircrw *** Whispers the user that you last messaged.
/fircr *** Queries information on the IRC user that last whispered you
/fircrw *** Queries information on the IRC user that you last messaged
/#[<channel>] *** Sends message to IRC channel. Omit <channel> and use /# to send message to last channel.

Special thanks

Skywing, for his expert advice and leadership. For development of the Battle.net Logon Server, BotNet server, BinaryChat plugin API, WebChannel ISAPI, and many more innovations and standards. Furthermore, as is quite obvious from the start, I've used many of the conventions set in place by BinaryChat when developing SphtBot.
Yoni, for co-development of the Battle.net Logon Server.
Kp, for co-development of the BotNet server.
Adron, without him this bot would not have been possible. His revolutionary NBBot paved the way for Battle.net bots and got me interested in programming for Battle.net in the first place.
Chewbacca, for truly setting the standard for Battle.net bots. Chewbacca's bot went far beyond any other Battle.net bot of the time.
DarkMinion, for introducing me to Clan [vL] and supporting my membership.
Soulburner, his DamnBot proved to be a great inspiration to me.

The members of Valhalla Legends and all the wonderful people who beta tested the bot despite poor documentation and precious little tech support.

oper.dll

  • oper.dll is a BinaryChat plugin that will transform SphtBot into a full-fledged Battle.net channel moderation bot, designed to safeguard Clan channels.
  • This plugin was heavily inspired by Skywing's ZeroBot (the bot used to moderate Clan [vL]) and designed to be cross-compatible with its database and scripting system. If you are familiar with ZeroBot or NBBot you should have no problem using this plugin.
  • Features: A highly flexible custom command system (including userdefined variables and advanced conditionals), an intuitive flags-based access control system coupled with a limited form of regular expression wildcard matching, and a powerful set of channel moderation functionality.
  • The original readme is available for download.

TriviaBot.dll

  • TriviaBot.dll is a BinaryChat plugin that will transform SphtBot into a fully-functional and stable trivia bot for hosting trivia games in your channel.
  • The readme contains instructions for use and its features.

Plugin Developer Reference

SphtBot supports the powerful BinaryChat plugin API that allows end-users to customize the program to a great degree. Allowing the user to transfer control to an external dll allows complete near customization of the bot for specialized purposes. Users are encouraged to develop their own plugin dlls for SphtBot. Following is the information required to use this plugin API in C/C++.

Managing plugins:
To load a plugin, use the /loadplugin <Plugin path> command. The /unloadplugin <Plugin path> command unloads a plugin from memory, and the /listplugins command displays all active plugins. SphtBot will automatically load all plugins in its directory on startup.

Plugin format:
BinaryChat plugins are regular Win32 DLL files with the .bcp extension. All BinaryChat plugins must export the function SetInterfaceInformation. This function receives a pointer to a PluginInformation structure. You should determine which PluginInformation version you are using through the dwSize member. Your plugin should take note of the addresses of various BinaryChat-supplied API functions for future reference. In addition, if you wish to install one of the provided hooks, you should set the corresponding function pointer (and, optionally, the 32-bit parameter associated with it) in the structure to the address of your hook function. By default, all of the hook functions are set to NULL, which indicates to BinaryChat that no plugin hook is present.

Plugin header definitions:

struct PluginInformation;
struct StateInformation;

// User functions
typedef BOOL (WINAPI * SetInterfaceInformationProc)(PluginInformation * lpInterfaceInfo);
typedef BOOL (WINAPI * MessageHookProc)(DWORD dwConnectionId, BYTE MessageId,
										LPCVOID lpMessageData, DWORD nMessageSize,
										LPARAM lParam);
typedef BOOL (WINAPI * EnumChannelProc)(LPCSTR lpszUniqueName, LPCSTR lpszStatstring,
										DWORD dwFlags, DWORD dwPing, BOOL bInvisible,
										DWORD dwAccountNumber, DWORD dwRegAuthority,
										LPARAM lParam);
typedef BOOL (WINAPI * ConnectionHookProc)(DWORD dwConnectionId, DWORD dwEventCode,
										DWORDLONG qwPlatformId, LPARAM lParam);
typedef DWORD (WINAPI * PluginTimerProc)(DWORD dwTimeDelay, LPARAM lParam);
typedef BOOL (WINAPI * CommandHookProc)(LPCSTR lpszMessage, LPCSTR lpszSendingUser,
										BOOL bFromTelnet, LPARAM lParam);
typedef BOOL (WINAPI * EventHookProc)(LPARAM lParam);

// APIs
typedef BOOL (WINAPI * ClearMessageProc)(BYTE MessageId);
typedef BOOL (WINAPI * IsMessageSetProc)(BYTE MessageId);
typedef BOOL (WINAPI * SetMessageProc)(BYTE MessageId);
typedef BOOL (WINAPI * QueueMessageProc)(BYTE MessageId, LPCVOID lpMessageData,
										DWORD nMessageSize);
typedef BOOL (WINAPI * QueueChatMessageProc)(LPSTR lpszChatMessage, BOOL bFixD2Command);
typedef BOOL (WINAPI * QueryStateInformationProc)(StateInformation * lpStateInfo);
typedef BOOL (WINAPI * QueryChannelInformationProc)(EnumChannelProc lpCallback,
										LPARAM lParam);
typedef BOOL (WINAPI * CloseConnectionProc)(DWORD dwConnectionId);
typedef BOOL (WINAPI * SendConnectionMessageProc)(DWORD dwConnectionId, BYTE MessageId,
										LPCVOID lpMessageData, DWORD nMessageSize);
typedef BOOL (WINAPI * SetOutputColorProc)(BYTE ColorId);
typedef BOOL (WINAPI * WriteOutputTimestampProc)(void);
typedef BOOL (WINAPI * WriteOutputStringProc)(LPCSTR lpszString);
typedef BOOL (WINAPI * ProcessBotCommandProc)(LPCSTR lpszCommand);
typedef LPCSTR (WINAPI * GetRegistryPathProc)(void);
typedef BOOL (WINAPI * ResetAwayIdleProc)(void);
typedef HWND (WINAPI * GetWindowProc)(DWORD dwWindowId);
typedef BOOL (WINAPI * IsServiceProc)(void);
typedef HMENU (WINAPI * GetMenuProc)(DWORD dwMenuId);

struct PluginInformation {
	DWORD dwSize;

	ClearMessageProc PNetClearMessage;
	IsMessageSetProc PNetIsMessageSet;
	SetMessageProc PNetSetMessage;
	QueueMessageProc PNetQueueMessage;
	QueueChatMessageProc PNetQueueChatMessage;
	QueryStateInformationProc PSysQueryStateInformation;
	QueryChannelInformationProc PSysQueryChannelInformation;
	CloseConnectionProc PNetCloseConnection;
	SendConnectionMessageProc PNetSendConnectionMessage;
	SetOutputColorProc PUISetColor;
	WriteOutputTimestampProc PUIWriteTimestamp;
	WriteOutputStringProc PUIWriteString;

	HINSTANCE hBotNetClient;
#ifdef _PLUGIN_SUPPORTS_BOTNET
	BotNetConnectionState * lpBotNetConnection;
#else
	void * lpBotNetConnection;
#endif

	MessageHookProc MessageHook;		// non-const
	LPARAM MessageHookParam;		// non-const

	ConnectionHookProc ConnectionHook;	// non-const
	LPARAM ConnectionHookParam;		// non-const

	PluginTimerProc PluginTimer;		// non-const
	LPARAM PluginTimerParam;		// non-const

	CommandHookProc CommandHook;		// non-const
	LPARAM CommandHookParam;		// non-const

	HINSTANCE hPlugin;

	EventHookProc EventHook;		// non-const
	LPARAM EventHookParam;			// non-const
	HANDLE hPluginEvent;
};

struct PluginInformation2 : public PluginInformation {
	ProcessBotCommandProc PSysProcessBotCommand;
};

struct PluginInformation3 : public PluginInformation2 {
	GetRegistryPathProc PRegGetRegistryPath;
	ResetAwayIdleProc PNetResetAwayIdle;
	GetWindowProc PUIGetWindow;
	IsServiceProc PSysIsService;
	GetMenuProc PUIGetMenu;
};

struct PluginInformation4 : public PluginInformation3 {
	IsUserFilteredProc PFltIsUserFiltered;
	IsMessageFilteredProc PFltIsMessageFiltered;
	EnumUserFiltersProc PFltEnumUserFilters;
	EnumMessageFiltersProc PFltEnumMessageFilters;
	AddUserFilterProc PFltAddUserFilter;
	AddMessageFilterProc PFltAddMessageFilter;
	RemoveUserFilterProc PFltRemoveUserFilter;
	RemoveMessageFilterProc PFltRemoveMessageFilter;
	NotifyMsgProc PUINotifyMsg;
	EnumLoadedPluginsProc PSysEnumLoadedPlugins;
};


Valid HTML 4.01! There is plenty more to discover...
Have fun!
- Spht[vL]