mirror of
https://github.com/Rudi9719/kbtui.git
synced 2026-03-22 05:17:27 +00:00
resolving upstream merge confilict
This commit is contained in:
@ -34,6 +34,10 @@ func cmdEdit(cmd []string) {
|
||||
printToView("Feed", fmt.Sprintf("%+v", origMessage))
|
||||
return
|
||||
}
|
||||
if origMessage.Result.Messages[0].Msg.Sender.Username != k.Username {
|
||||
printToView("Feed", "You cannot edit another user's messages.")
|
||||
return
|
||||
}
|
||||
editString := origMessage.Result.Messages[0].Msg.Content.Text.Body
|
||||
clearView("Edit")
|
||||
popupView("Edit")
|
||||
|
||||
64
cmdSet.go
Normal file
64
cmdSet.go
Normal file
@ -0,0 +1,64 @@
|
||||
// +build !rm_basic_commands allcommands setcmd
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func init() {
|
||||
command := Command{
|
||||
Cmd: []string{"set", "config"},
|
||||
Description: "Change various settings",
|
||||
Help: "",
|
||||
Exec: cmdSet,
|
||||
}
|
||||
|
||||
RegisterCommand(command)
|
||||
}
|
||||
|
||||
func cmdSet(cmd []string) {
|
||||
if len(cmd) < 2 {
|
||||
printToView("Feed", "No config value specified")
|
||||
return
|
||||
}
|
||||
if len(cmd) < 3 {
|
||||
switch cmd[1] {
|
||||
case "load":
|
||||
printToView("Feed", "Load values from file?")
|
||||
case "downloadPath":
|
||||
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], downloadPath))
|
||||
case "outputFormat":
|
||||
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], outputFormat))
|
||||
case "dateFormat":
|
||||
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], dateFormat))
|
||||
case "timeFormat":
|
||||
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], timeFormat))
|
||||
case "cmdPrefix":
|
||||
printToView("Feed", fmt.Sprintf("Setting for %s -> %s", cmd[1], cmdPrefix))
|
||||
default:
|
||||
printToView("Feed", fmt.Sprintf("Unknown config value %s", cmd[1]))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
switch cmd[1] {
|
||||
case "downloadPath":
|
||||
if len(cmd) != 3 {
|
||||
printToView("Feed", "Invalid download path.")
|
||||
}
|
||||
downloadPath = cmd[2]
|
||||
case "outputFormat":
|
||||
outputFormat = strings.Join(cmd[1:], " ")
|
||||
case "dateFormat":
|
||||
dateFormat = strings.Join(cmd[1:], " ")
|
||||
case "timeFormat":
|
||||
timeFormat = strings.Join(cmd[1:], " ")
|
||||
case "cmdPrefix":
|
||||
cmdPrefix = cmd[2]
|
||||
default:
|
||||
printToView("Feed", fmt.Sprintf("Unknown config value %s", cmd[1]))
|
||||
}
|
||||
|
||||
}
|
||||
63
cmdWallet.go
Normal file
63
cmdWallet.go
Normal file
@ -0,0 +1,63 @@
|
||||
// ignore
|
||||
// +build allcommands walletcmd
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
var walletConfirmationCode string
|
||||
var walletConfirmationUser string
|
||||
var walletTransactionAmnt string
|
||||
|
||||
func init() {
|
||||
command := Command{
|
||||
Cmd: []string{"wallet", "confirm"},
|
||||
Description: "$user $amount / $user $confirmation - Send or confirm a wallet payment",
|
||||
Help: "",
|
||||
Exec: cmdWallet,
|
||||
}
|
||||
|
||||
RegisterCommand(command)
|
||||
}
|
||||
|
||||
func cmdWallet(cmd []string) {
|
||||
if len(cmd) < 3 {
|
||||
return
|
||||
}
|
||||
if cmd[0] == "wallet" {
|
||||
rand.Seed(time.Now().UnixNano())
|
||||
chars := []rune("ABCDEFGHIJKLMNOPQRSTUVWXYZ" +
|
||||
"abcdefghijklmnopqrstuvwxyz" +
|
||||
"0123456789")
|
||||
length := 5
|
||||
var b strings.Builder
|
||||
for i := 0; i < length; i++ {
|
||||
b.WriteRune(chars[rand.Intn(len(chars))])
|
||||
}
|
||||
walletConfirmationCode = b.String()
|
||||
walletConfirmationUser = cmd[1]
|
||||
walletTransactionAmnt = cmd[2]
|
||||
printToView("Feed", fmt.Sprintf("To confirm sending %s to %s, type /confirm %s %s", cmd[2], cmd[1], cmd[1], walletConfirmationCode))
|
||||
|
||||
} else if cmd[0] == "confirm" {
|
||||
if cmd[1] == walletConfirmationUser && cmd[2] == walletConfirmationCode {
|
||||
txWallet := k.NewWallet()
|
||||
wAPI, err := txWallet.SendXLM(walletConfirmationUser, walletTransactionAmnt, "")
|
||||
if err != nil {
|
||||
printToView("Feed", fmt.Sprintf("There was an error with your wallet tx:\n\t%+v", err))
|
||||
} else {
|
||||
printToView("Feed", fmt.Sprintf("You have sent %sXLM to %s with tx ID: %s", wAPI.Result.Amount, wAPI.Result.ToUsername, wAPI.Result.TxID))
|
||||
}
|
||||
|
||||
} else {
|
||||
printToView("Feed", "There was an error validating your confirmation. Your wallet has been untouched.")
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
24
main.go
24
main.go
@ -411,34 +411,14 @@ func layout(g *gocui.Gui) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func layout2(g *gocui.Gui) error {
|
||||
maxX, maxY := g.Size()
|
||||
if feedView, err := g.SetView("Feed2", maxX/2-maxX/3, 0, maxX-1, maxY/5, 0); err != nil {
|
||||
if !gocui.IsUnknownView(err) {
|
||||
return err
|
||||
}
|
||||
feedView.Autoscroll = true
|
||||
feedView.Wrap = true
|
||||
fmt.Fprintln(feedView, "Feed Window - If you are mentioned or receive a PM it will show here")
|
||||
}
|
||||
if chatView, err2 := g.SetView("Chat2", maxX/2-maxX/3, maxY/5+1, maxX-1, maxY-5, 0); err2 != nil {
|
||||
if !gocui.IsUnknownView(err2) {
|
||||
return err2
|
||||
}
|
||||
chatView.Autoscroll = true
|
||||
chatView.Wrap = true
|
||||
fmt.Fprintf(chatView, "Welcome %s!\n\nYour chats will appear here.\nSupported commands are as follows:\n\n", k.Username)
|
||||
RunCommand("help")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getInputString(viewName string) (string, error) {
|
||||
inputView, err := g.View(viewName)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
retString := strings.Join(inputView.BufferLines(), " ")
|
||||
retString := inputView.Buffer()
|
||||
retString = strings.ReplaceAll(retString, "\n", "")
|
||||
return retString, err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user