diff options
author | Alex Auvolat <alex@adnab.me> | 2020-02-26 22:49:27 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2020-02-26 22:49:27 +0100 |
commit | 8a5ed3f507d37c52e2a68a23ced6942cc752221d (patch) | |
tree | 14e85d2f6031d6b38ad34bb7b360df3918c1c9e4 /connector/irc | |
parent | 775fc7b2172a632587e82cd44b9d7400ca4f4f74 (diff) | |
download | easybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.tar.gz easybridge-8a5ed3f507d37c52e2a68a23ced6942cc752221d.zip |
Initial ability to configure accounts from web interface
Diffstat (limited to 'connector/irc')
-rw-r--r-- | connector/irc/config.go | 32 | ||||
-rw-r--r-- | connector/irc/irc.go | 24 |
2 files changed, 55 insertions, 1 deletions
diff --git a/connector/irc/config.go b/connector/irc/config.go new file mode 100644 index 0000000..26d9a63 --- /dev/null +++ b/connector/irc/config.go @@ -0,0 +1,32 @@ +package irc + +import ( + . "git.deuxfleurs.fr/Deuxfleurs/easybridge/connector" +) + +func init() { + Register("irc", ConfigSchema{ + &ConfigEntry{ + Name: "nick", + Description: "Nickname", + Required: true, + }, + &ConfigEntry{ + Name: "server", + Description: "Server", + Required: true, + }, + &ConfigEntry{ + Name: "port", + Description: "Port", + IsNumeric: true, + Default: "6667", + }, + &ConfigEntry{ + Name: "ssl", + Description: "Use SSL", + IsBoolean: true, + Default: "false", + }, + }) +} 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) { |