Multiple Servers
How to set up multiple servers
Article By: Jamie Frater
Article Written: 6th January, 2001
Probably the most frequently asked question I have received since the release of Bersirc, is
"how do I set up multiple servers?". This has obviously suggested to us that we must make
multiple connections easier in Bersirc- this will happen :) But in the meantime, how do you set
up multiple servers?
In this article you will do three things:
- Connect to two servers when Bersirc loads,
- Join different channels depending on the network you have logged into,
- Send a private message to an eggdrop bot to give you ops.
Okay, let's get started! If you don't already have the Bersirc script editor, I strongly recommend
that you download it here. Open
the file events.ops in the script editor. Events.ops comes with the default install of Berirc.
All of our work will be done in this file.
On the left side of the editor, in the list of functions, double click "OnStartup". The OnStartup event
occurs once in the life cycle of a Bersirc session. This means, that it happens when you first
load Bersirc, and not again. This makes it perfect for setting up our servers. In the space between
the words begin and end; type the following code:
// connect to stanford (efnet)
Server('irc.stanford.edu', '', 6667);
// create a NEW server (independent)
NServer('irc.openface.ca', '', 6667);
Now save the script! If you were to restart bersirc now, bersirc would connect to the two servers named above.
This, however, is not sufficient - we want to join certain channels when we connect! On the left hand side,
double click "OnLogin". In the OnLogin section, we will do a bit of slightly more complicated code. This event
occurs everytime you connect to a server, and it allows us to perform certain tasks with the certainty that we
are logged on. Make sure that your OnLogin looks like the one here:
procedure OnLogin(ServerID: Integer; Nickname: String);
var
ServerName: String;
begin
// this gets the server name for us
ServerName := GetServerName(ServerID);
// Use Pos() to find a substring in a string.
// This method is useful when you use a
// round-robin server and the server
// name changes each time you log on.
// You normally find this with things
// like irc.efnet.org
if Pos('openface', ServerName) <> 0 then
Join(ServerID, '#One', '')
else if GetServerName(ServerID) = 'irc.stanford.edu' then
Join(ServerID, '#Bersirc', '');
end;
The code above, in plain English, says: "If the server I am connected to has the word 'openface' in it,
join #One, otherwise if the servername is 'irc.stanford.edu', join #Bersirc.
Save your code again! Now, let us presume you have ops on #one on openface, and your bot is named "julie".
To save your poor hands from the effort of typing /msg julie op MyPassword, we will script it! On the left
hand side of the editor, double click "OnJoined" - do NOT confuse this with OnJoin. OnJoined occurs when you
join a channel, and OnJoin occurs when someone else joins a channel.
Your code should look something like this:
procedure OnJoined(ServerID: Integer; Channel: String);
begin
// get the nice channel stats
ChanStats(ServerID, Channel);
// check we are on the right channel
if LowerCase(Channel) = '#one' then
begin
// check if the bot has ops
if IsOp(ServerID, 'julie', Channel) then
begin
// request ops using /msg
Msg(ServerID, 'julie', 'op Mypassword');
end;
end;
end;
Save your file! Congratulations! You have just written a script to connect to multiple servers!
When you restart bersirc, you should connect to both servers, and perform all of the appropriate
commands. What could be easier?
If you have any questions or problems, come to #Bersirc on EFnet (irc.efnet.org) and ask for
help - there are plenty of ops and users to help!
-- Jamie Frater