Add twitch point song requests to the bot
This commits adds new feature for galchedbot: video requests in the twitch chat via highlighted chat messages. This messages parsed by the bot and added to the video queue, that can be accessed by the dedicated web server. Video queue requires authorization based on random token added to the cookies.
This commit is contained in:
parent
65fc1ccad4
commit
f0f31a8415
18 changed files with 813 additions and 13 deletions
|
@ -1,24 +1,29 @@
|
|||
package settings
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"log"
|
||||
"time"
|
||||
)
|
||||
|
||||
const (
|
||||
version = "4.2.0"
|
||||
version = "5.0.0"
|
||||
twitchUser = "galchedbot"
|
||||
twitchIRCRoom = "galched"
|
||||
discordTokenPath = "./tokens/.discordtoken"
|
||||
twitchTokenPath = "./tokens/.twitchtoken"
|
||||
subdayDataPath = "./backups/subday"
|
||||
youtubeTokenPath = "./tokens/.youtubetoken"
|
||||
webLoginsPath = "./tokens/.weblogins"
|
||||
|
||||
// Permitted roles in discord for subday
|
||||
subRole1 = "433672344737677322"
|
||||
subRole2 = "433680494635515904"
|
||||
galchedRole = "301467455497175041"
|
||||
smorcRole = "301470784491356172"
|
||||
|
||||
defaultQueueAddr = ":8888"
|
||||
)
|
||||
|
||||
type (
|
||||
|
@ -36,10 +41,14 @@ type (
|
|||
TwitchUser string
|
||||
TwitchIRCRoom string
|
||||
TwitchToken string
|
||||
YoutubeToken string
|
||||
SubdayDataPath string
|
||||
PermittedRoles []string
|
||||
DiscordVoiceChannel string
|
||||
Songs []SongInfo
|
||||
|
||||
QueueAddress string
|
||||
LoginUsers map[string]string
|
||||
}
|
||||
)
|
||||
|
||||
|
@ -52,11 +61,27 @@ func New() (*Settings, error) {
|
|||
if err != nil {
|
||||
log.Print("settings: cannot read twitch token file", err)
|
||||
}
|
||||
youtubetoken, err := ioutil.ReadFile(youtubeTokenPath)
|
||||
if err != nil {
|
||||
log.Print("settings: cannot read twitch token file", err)
|
||||
}
|
||||
|
||||
webLogins := make(map[string]string)
|
||||
webLoginsRaw, err := ioutil.ReadFile(webLoginsPath)
|
||||
if err != nil {
|
||||
log.Print("settings: cannot read web login file", err)
|
||||
} else {
|
||||
err = json.Unmarshal(webLoginsRaw, &webLogins)
|
||||
if err != nil {
|
||||
log.Print("settings: cannot parse web login file", err)
|
||||
}
|
||||
}
|
||||
|
||||
return &Settings{
|
||||
Version: version,
|
||||
DiscordToken: string(discordToken),
|
||||
TwitchToken: string(twitchToken),
|
||||
YoutubeToken: string(youtubetoken),
|
||||
TwitchUser: twitchUser,
|
||||
TwitchIRCRoom: twitchIRCRoom,
|
||||
SubdayDataPath: subdayDataPath,
|
||||
|
@ -66,7 +91,7 @@ func New() (*Settings, error) {
|
|||
{
|
||||
Path: "songs/polka.dca",
|
||||
Signature: "!song",
|
||||
Description: "сыграть гимн галчед (только для избранных",
|
||||
Description: "сыграть гимн галчед (только для избранных)",
|
||||
Permissions: []string{"AlexV", "Rummy_Quamox", "Lidiya_owl"},
|
||||
Timeout: 10 * time.Second,
|
||||
},
|
||||
|
@ -76,6 +101,14 @@ func New() (*Settings, error) {
|
|||
Description: "kreygasm",
|
||||
Timeout: 20 * time.Second,
|
||||
},
|
||||
{
|
||||
Path: "songs/st.dca",
|
||||
Signature: "!chiki",
|
||||
Description: "briki v damki",
|
||||
Timeout: 20 * time.Second,
|
||||
},
|
||||
},
|
||||
QueueAddress: defaultQueueAddr,
|
||||
LoginUsers: webLogins,
|
||||
}, nil
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue