2021-11-14 06:31:51 +02:00
|
|
|
// gorc project
|
2022-01-24 04:23:02 +02:00
|
|
|
// Copyright (C) 2022 IllusionMan1212
|
2021-11-14 06:31:51 +02:00
|
|
|
//
|
|
|
|
|
// This program is free software; you can redistribute it and/or modify
|
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
|
|
|
// (at your option) any later version.
|
|
|
|
|
//
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
// GNU General Public License for more details.
|
|
|
|
|
//
|
|
|
|
|
// You should have received a copy of the GNU General Public License along
|
|
|
|
|
// with this program; if not, see https://www.gnu.org/licenses.
|
|
|
|
|
|
2022-01-24 04:23:02 +02:00
|
|
|
package cmds
|
2021-11-14 06:19:46 +02:00
|
|
|
|
|
|
|
|
import (
|
2022-02-19 16:24:39 +02:00
|
|
|
"fmt"
|
|
|
|
|
"time"
|
|
|
|
|
|
2021-11-14 06:19:46 +02:00
|
|
|
tea "github.com/charmbracelet/bubbletea"
|
2022-01-24 04:23:02 +02:00
|
|
|
"github.com/illusionman1212/gorc/irc"
|
2021-11-14 06:19:46 +02:00
|
|
|
)
|
|
|
|
|
|
2022-01-24 04:23:02 +02:00
|
|
|
type ConnectMsg struct{}
|
|
|
|
|
|
|
|
|
|
func Connect() tea.Msg {
|
|
|
|
|
return ConnectMsg{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func Quit(client *irc.Client) tea.Cmd {
|
|
|
|
|
return func() tea.Msg {
|
|
|
|
|
if client.TcpConn != nil {
|
|
|
|
|
client.SendCommand("QUIT")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return tea.Quit()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SendPrivMsgMsg struct {
|
2022-02-19 16:24:39 +02:00
|
|
|
Msg string
|
|
|
|
|
Timestamp string
|
2022-01-05 00:54:54 +02:00
|
|
|
}
|
|
|
|
|
|
2022-01-24 04:23:02 +02:00
|
|
|
func SendPrivMsg(msg string) tea.Cmd {
|
2022-01-05 00:54:54 +02:00
|
|
|
return func() tea.Msg {
|
2022-02-19 16:24:39 +02:00
|
|
|
now := time.Now()
|
|
|
|
|
timestamp := fmt.Sprintf("[%02d:%02d]", now.Hour(), now.Minute())
|
|
|
|
|
|
|
|
|
|
return SendPrivMsgMsg{
|
|
|
|
|
Msg: msg,
|
|
|
|
|
Timestamp: timestamp,
|
|
|
|
|
}
|
2022-01-05 00:54:54 +02:00
|
|
|
}
|
|
|
|
|
}
|
2022-01-15 21:56:06 +02:00
|
|
|
|
|
|
|
|
type ReceivedIRCMsgMsg struct{}
|
|
|
|
|
|
|
|
|
|
func ReceivedIRCMsg() tea.Msg {
|
|
|
|
|
return ReceivedIRCMsgMsg{}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
type SwitchChannelsMsg struct{}
|
|
|
|
|
|
|
|
|
|
func SwitchChannels() tea.Msg {
|
|
|
|
|
return SwitchChannelsMsg{}
|
|
|
|
|
}
|
2022-01-24 04:23:02 +02:00
|
|
|
|
|
|
|
|
type UpdateTabBarMsg struct{}
|
|
|
|
|
|
|
|
|
|
func UpdateTabBar() tea.Msg {
|
|
|
|
|
return UpdateTabBarMsg{}
|
|
|
|
|
}
|