aboutsummaryrefslogtreecommitdiff
path: root/connector/irc/irc.go
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2020-02-26 22:49:27 +0100
committerAlex Auvolat <alex@adnab.me>2020-02-26 22:49:27 +0100
commit8a5ed3f507d37c52e2a68a23ced6942cc752221d (patch)
tree14e85d2f6031d6b38ad34bb7b360df3918c1c9e4 /connector/irc/irc.go
parent775fc7b2172a632587e82cd44b9d7400ca4f4f74 (diff)
downloadeasybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.tar.gz
easybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.zip
Initial ability to configure accounts from web interface
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) {