aboutsummaryrefslogtreecommitdiff
path: root/connector/irc/irc.go
diff options
context:
space:
mode:
Diffstat (limited to 'connector/irc/irc.go')
-rw-r--r--connector/irc/irc.go24
1 files changed, 23 insertions, 1 deletions
diff --git a/connector/irc/irc.go b/connector/irc/irc.go
index 2ed3923..d69884e 100644
--- a/connector/irc/irc.go
+++ b/connector/irc/irc.go
@@ -127,6 +127,10 @@ func (irc *IRC) SetUserInfo(info *UserInfo) error {
}
func (irc *IRC) SetRoomInfo(roomId RoomID, info *RoomInfo) error {
+ if irc.conn == nil {
+ return fmt.Errorf("Not connected")
+ }
+
ch, err := irc.checkRoomId(roomId)
if err != nil {
return err
@@ -145,6 +149,10 @@ func (irc *IRC) SetRoomInfo(roomId RoomID, info *RoomInfo) error {
}
func (irc *IRC) Join(roomId RoomID) error {
+ if irc.conn == nil {
+ return fmt.Errorf("Not connected")
+ }
+
ch, err := irc.checkRoomId(roomId)
if err != nil {
return err
@@ -155,6 +163,10 @@ func (irc *IRC) Join(roomId RoomID) error {
}
func (irc *IRC) Invite(userId UserID, roomId RoomID) error {
+ if irc.conn == nil {
+ return fmt.Errorf("Not connected")
+ }
+
who, err := irc.checkUserId(userId)
if err != nil {
return err
@@ -174,6 +186,10 @@ func (irc *IRC) Invite(userId UserID, roomId RoomID) error {
}
func (irc *IRC) Leave(roomId RoomID) {
+ if irc.conn == nil {
+ return
+ }
+
ch, err := irc.checkRoomId(roomId)
if err != nil {
return
@@ -183,6 +199,10 @@ func (irc *IRC) Leave(roomId RoomID) {
}
func (irc *IRC) Send(event *Event) error {
+ if irc.conn == nil {
+ return fmt.Errorf("Not connected")
+ }
+
// Workaround girc bug
if event.Text[0] == ':' {
event.Text = " " + event.Text
@@ -231,7 +251,9 @@ func (irc *IRC) Send(event *Event) error {
func (irc *IRC) Close() {
conn := irc.conn
irc.conn = nil
- conn.Close()
+ if conn != nil {
+ conn.Close()
+ }
}
func (irc *IRC) connectLoop(c *girc.Client) {