Well, the teamspeak bot needs to initiate the connection to POL through the configured AUX port (
auxsvc.cfg). From there, the POL script is fired. The POL script could send strings to the teamspeak bot that the bot will process as commands, it can also receive commands from the teamspeak bot if needed. What you do is make the AUX script an event based script, set the PID to a global prop, then send events that will forward as commands to the teamspeak bot.
Here's an example of the POL AUX script that I made for IRC
in IRC, if players would type !online, the IRC bot sends "sonline" to POL (important: remember the 's' for string, 'i' for integer). It then ran the function and transmitted back the number of online players, typically i## like 'i25' for 25 players online.
An example of a POL script sending an event to the script which gets passed to the bot would be the Pages() function. The string would be constructed in the AUX script and transmitted to the bot.
Code: Select all
// AccountBot connection script by CWO
// This script handles various communications both AccountBot-Server and Server-AccountBot.
use uo;
use os;
program AccountBot(con)
Print("AccountBot has connected to POL");
SetGlobalProperty("accountbot", getpid()); // This needs to be set so that other scripts can send events to it. Ex: Paging.
while(con) // While the connection is active
var ev := wait_for_event(120); // Wait up to 120 seconds for anything to happen.
if (!ev)
continue; // If nothing has come in, re-loop
endif
Print("AccountBot communication: " + CStr(ev.value));
var thevalue := SplitWords(ev.value);
case(thevalue[1])
"p" : con.transmit("p"); // AccountBot ping/pong.
"online" : con.transmit("online:" + Online()); // Number of players online.
"player" : PlayerInfo(con, ev.value); // Specific player info.
"stats" : ServerStats(con); // Server Stats.
"page" : Pages(con, ev); // Page transmission to IRC.
endcase
endwhile
Print("AccountBot disconnected");
endprogram
function Online()
var count := 0;
foreach player in EnumerateOnlineCharacters()
if (!player.cmdlevel)
count := count + 1;
endif
endforeach
return count; // Number of non-staff online.
endfunction
function PlayerInfo(con, value)
value["player "] := "";
foreach player in EnumerateOnlineCharacters()
if (lower(value) == lower(player.name) && !player.cmdlevel)
con.transmit("player:" +player.name + ":" + CStr(GetObjProperty(player, "Fame") + ":" + GetObjProperty(player, "Karma") + ":" + GetObjProperty(player, "onlinetimer")/60)); //Player is online. Send info.
return;
endif
endforeach
con.transmit("player:x"); //Player is offline.
endfunction
function ServerStats(con)
con.transmit("stats:" + CStr(polcore().itemcount + ":" + polcore().mobilecount + ":" + polcore().sysload + ":" + polcore().sysload_severity + ":" + polcore().uptime + ":" + Online() + ":" + polcore().instr_per_min));
endfunction
function Pages(con, ev)
if (ev.pagername) //If POL is sending a new page out
con.transmit("page:" + ev.pagername + ":" + ev.page);
else //Else a staff member sent the !pages command from IRC
var status;
var people := EnumerateOnlineCharacters();
foreach page in GetGlobalProperty("Pagelist")
if (SystemFindObjectBySerial(page.chrserial) in people) //Pager is online
status := "onln";
else
foreach player in people
if (player.acctname == page.acctname) //Pager is online but on another character
status := "acct";
endif
endforeach
if (status != "acct") //Pager is offline
status := "ofln";
endif
endif
con.transmit("pagecmd:" + status + ":" + page.name + ":" + page.text); // Send individual page
endforeach
if (!status)
con.transmit("pagecmd:nopages"); // There are no pages currently
endif
endif
endfunction
So this is an example of what the POL side could look like. I couldn't help you from the teamspeak side.