Fix crash when providing bad command line argument
[clinton/bobotpp.git] / source / Person.C
1 // Person.C -*- C++ -*-
2 // Copyright (c) 1998 Etienne BERNARD
3 // Copyright (c) 2005 Clinton Ebadi
4
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // any later version.
9
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
14
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
18 // 02110-1301, USA.
19
20 #include "Person.H"
21
22 #include "Bot.H"
23 #include "ServerConnection.H"
24 #include "Utils.H"
25
26 Person::Person(Bot *b, String a)
27 : bot(b), address(a)
28 { }
29
30 Person::Person(Person &p)
31 : bot(p.bot), address(p.address)
32 { }
33
34 Person *
35 Person::copy()
36 {
37 return new Person(*this);
38 }
39
40 String
41 Person::getNick() const
42 {
43 return Utils::get_nick (address);
44 }
45
46 String
47 Person::getAddress() const
48 {
49 return address;
50 }
51
52 Person &
53 Person::operator=(const String & a)
54 {
55 address = a;
56 return *this;
57 }
58
59 void
60 Person::sendNotice(String message)
61 {
62 bot->serverConnection->queue->sendNotice(getNick(), message);
63 }