Skip to content
Extraits de code Groupes Projets
Valider 9469e7d3 rédigé par Alexandre Morignot's avatar Alexandre Morignot
Parcourir les fichiers

IRC print

parent 11de38ab
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -46,7 +46,8 @@ func (yt Youtube) Read(url string) (*Content, error) { ...@@ -46,7 +46,8 @@ func (yt Youtube) Read(url string) (*Content, error) {
return &Content{ return &Content{
Author: video.Snippet.ChannelTitle, Author: video.Snippet.ChannelTitle,
Duration: duration + 1, Duration: duration,
Title: video.Snippet.Title,
Source: "youtube", Source: "youtube",
SourceId: video.Id, SourceId: video.Id,
Url: "https://www.youtube.com/watch?v=" + video.Id, Url: "https://www.youtube.com/watch?v=" + video.Id,
......
Fichier supprimé
Fichier supprimé
...@@ -29,6 +29,6 @@ func (t *IrcTransport) privmsg(conn *irc.Conn, line *irc.Line) { ...@@ -29,6 +29,6 @@ func (t *IrcTransport) privmsg(conn *irc.Conn, line *irc.Line) {
go b.ParseLine(line.Nick, msg, contents) go b.ParseLine(line.Nick, msg, contents)
for content := range contents { for content := range contents {
t.printContent(content) t.printContent(conn, content, channel)
} }
} }
package irc package irc
import ( import (
"fmt"
"log" "log"
irc "github.com/fluffle/goirc/client"
"git.iiens.net/morignot2011/playbot/site" "git.iiens.net/morignot2011/playbot/site"
) )
func (t *IrcTransport) printContent(content *site.Content) { const (
log.Printf("Print lol: %q", content) NORMAL string = "\x0f"
BOLD string = "\x02"
UNDERLINE string = "\x1f"
REVERSE string = "\x16"
ITALIC string = "\x1d"
FIXED string = "\x11"
BLINK string = "\x06"
WHITE string = "\x0300"
BLACK string = "\x0301"
BLUE string = "\x0302"
GREEN string = "\x0303"
RED string = "\x0304"
BROWN string = "\x0305"
PURPLE string = "\x0306"
ORANGE string = "\x0307"
YELLOW string = "\x0308"
LIGHT_GREEN string = "\x0309"
TEAL string = "\x0310"
LIGHT_CYAN string = "\x0311"
LIGHT_BLUE string = "\x0312"
PINK string = "\x0313"
GREY string = "\x0314"
LIGHT_GREY string = "\x0315"
)
func (t *IrcTransport) printContent(conn *irc.Conn, content *site.Content, channel string) {
msg := fmt.Sprintf("%s[%d] %s%s", YELLOW, content.Id, GREEN, content.Title)
if content.Author != "" {
msg += " | " + content.Author
}
if content.Duration > 0 {
h := content.Duration / 3600
m := (content.Duration % 3600) / 60
s := (content.Duration % 3600) % 60
msg += LIGHT_BLUE + " ("
if h > 0 {
msg += fmt.Sprintf("%02d:", h)
}
if m > 0 {
msg += fmt.Sprintf("%02d:", m)
}
msg += fmt.Sprintf("%02d)%s", s, NORMAL)
}
msg += " => " + content.Url + ORANGE
conn.Privmsg(channel, msg)
} }
func (t *IrcTransport) printError(err error) { func (t *IrcTransport) printError(err error) {
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter