Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
P
PlayBot 2
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Compilation
Pipelines
Jobs
Planifications de pipeline
Artéfacts
Déploiement
Releases
Registre de conteneur
Registre de modèles
Opération
Environnements
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
Données d'analyse CI/CD
Données d'analyse du dépôt
Expériences du modèle
Aide
Aide
Support
Documentation de GitLab
Comparer les forfaits GitLab
Forum de la communauté
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Ce projet est archivé. Le dépôt et les autres ressources du projet sont en lecture seule.
Afficher davantage de fils d'Ariane
Alexandre MORIGNOT
PlayBot 2
Validations
11de38ab
Valider
11de38ab
rédigé
8 years ago
par
Alexandre Morignot
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
Instanciate readers from conf
parent
d8f3e276
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
1
Masquer les modifications d'espaces
En ligne
Côte à côte
Affichage de
1 fichier modifié
main.go
+29
-10
29 ajouts, 10 suppressions
main.go
avec
29 ajouts
et
10 suppressions
main.go
+
29
−
10
Voir le fichier @
11de38ab
...
@@ -13,12 +13,32 @@ import (
...
@@ -13,12 +13,32 @@ import (
)
)
type
config
struct
{
type
config
struct
{
Db
bot
.
DbParams
Db
bot
.
DbParams
Transport
map
[
string
]
transportParams
`yaml:"transports"`
Transports
map
[
string
]
transportParams
`yaml:"transports"`
Readers
map
[
string
]
readerParams
`yaml:"sites"`
}
}
type
readerParams
map
[
string
]
interface
{}
type
transportParams
map
[
string
]
interface
{}
type
transportParams
map
[
string
]
interface
{}
func
getReader
(
name
string
,
config
map
[
string
]
interface
{})
site
.
Reader
{
var
err
error
var
reader
site
.
Reader
switch
name
{
case
"youtube"
:
reader
,
err
=
site
.
NewYoutube
(
config
[
"api_key"
]
.
(
string
))
default
:
log
.
Fatalf
(
"Unsupported site '%s'"
,
name
)
}
if
err
!=
nil
{
log
.
Fatal
(
err
)
}
return
reader
}
func
startTransport
(
name
string
,
config
transportParams
,
factory
bot
.
Factory
)
chan
bool
{
func
startTransport
(
name
string
,
config
transportParams
,
factory
bot
.
Factory
)
chan
bool
{
transportType
,
ok
:=
config
[
"type"
]
transportType
,
ok
:=
config
[
"type"
]
if
!
ok
{
if
!
ok
{
...
@@ -54,19 +74,18 @@ func main() {
...
@@ -54,19 +74,18 @@ func main() {
var
config
config
var
config
config
err
=
yaml
.
Unmarshal
(
file
,
&
config
)
err
=
yaml
.
Unmarshal
(
file
,
&
config
)
quit
:=
make
(
map
[
string
](
chan
bool
))
quit
:=
make
(
map
[
string
](
chan
bool
))
var
readers
[]
site
.
Reader
youtube
,
err
:=
site
.
NewYoutube
(
"AIzaSyD32EU9lb9cnNcEaSUBKCkKodk6rjl3HYc"
)
for
name
,
readerCfg
:=
range
config
.
Readers
{
if
err
!=
nil
{
reader
:=
getReader
(
name
,
readerCfg
)
log
.
Fatal
(
err
)
readers
=
append
(
readers
,
reader
)
}
readers
:=
[]
site
.
Reader
{
//&site.Youtube{},
youtube
,
}
}
factory
:=
bot
.
NewPlayBotFactory
(
config
.
Db
,
readers
)
factory
:=
bot
.
NewPlayBotFactory
(
config
.
Db
,
readers
)
for
name
,
config
:=
range
config
.
Transport
{
for
name
,
config
:=
range
config
.
Transport
s
{
c
:=
startTransport
(
name
,
config
,
factory
)
c
:=
startTransport
(
name
,
config
,
factory
)
quit
[
name
]
=
c
quit
[
name
]
=
c
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
Aperçu
0%
Chargement en cours
Veuillez réessayer
ou
joindre un nouveau fichier
.
Annuler
You are about to add
0
people
to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Enregistrer le commentaire
Annuler
Veuillez vous
inscrire
ou vous
se connecter
pour commenter