Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
P
PlayBot
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Requêtes de fusion
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Déploiement
Releases
Registre de modèles
Surveillance
Incidents
Analyse
Données d'analyse des chaînes de valeur
Analyse des contributeurs
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é GitLab
Contribuer à GitLab
Donner votre avis
Raccourcis clavier
?
Extraits de code
Groupes
Projets
Afficher davantage de fils d'Ariane
Alexandre MORIGNOT
PlayBot
Validations
90f45290
Valider
90f45290
rédigé
Il y a 10 ans
par
Alexandre Morignot
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
trying to do a less shit with the db
parent
a20d1bb2
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
2
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
2 fichiers modifiés
lib/sessions/irc.pm
+1
-10
1 ajout, 10 suppressions
lib/sessions/irc.pm
lib/sites/parser.pm
+23
-11
23 ajouts, 11 suppressions
lib/sites/parser.pm
avec
24 ajouts
et
21 suppressions
lib/sessions/irc.pm
+
1
−
10
Voir le fichier @
90f45290
...
...
@@ -144,7 +144,6 @@ sub setConf
{
commands::parser::
setConf
(
$irc
,
$dbh
,
$log
,
\
%lastID
);
$
sites::parser::
dbh
=
$dbh
;
$
sites::parser::
irc
=
$irc
;
$
sites::parser::
log
=
$log
;
}
...
...
@@ -288,15 +287,7 @@ sub on_speak
# first we test if it's a command
if
(
!
commands::parser::
exec
(
@args
))
{
# if not, maybe there is an url we can parse
my
$id
=
sites::parser::
parse
(
@args
);
# if there is a new content, there is a new id to save
if
(
$id
)
{
$lastID
{
$chan
->
[
0
]}
=
$id
;
# we insert the potiential tags
commands::parser::
tag
(
$msg
,
$chan
);
}
sites::parser::
parse
(
@args
);
}
}
...
...
Ce diff est replié.
Cliquez pour l'agrandir.
lib/sites/parser.pm
+
23
−
11
Voir le fichier @
90f45290
...
...
@@ -8,10 +8,11 @@ use zippy;
use
dailymotion
;
use
lib
"
$FindBin
::Bin/lib/
";
use
utils::
db
;
use
utils::
print
;
use
commands::
parser
;
our
$irc
;
our
$dbh
;
our
$log
;
sub
parse
{
...
...
@@ -20,6 +21,7 @@ sub parse {
my
%content
;
my
$id
;
my
$dbh
=
utils::db::
main_session
();
# parsing
if
(
$msg
=~
m#(?:^|[^!])https?://(?:www.youtube.com/watch\?[a-zA-Z0-9_=&-]*v=|youtu.be/)([a-zA-Z0-9_-]+)#
)
{
...
...
@@ -73,11 +75,14 @@ sub parse {
or
$log
->
error
("
Couldn't finish transaction:
"
.
$dbh
->
errstr
);
}
my
@tags
;
# sélection de l'id de la vidéo insérée
$id
=
$sth
->
{
mysql_insertid
};
if
(
!
$id
)
{
# la vido avait déjà été insérée
# L'état de la bdd est stable (puisqu'on a en fait rien fait),
# on peut commiter.
$dbh
->
commit
;
my
$sth
=
$dbh
->
prepare_cached
('
SELECT id FROM playbot WHERE url = ?
');
$log
->
error
("
Couldn't prepare querie; aborting
")
unless
(
defined
$sth
);
...
...
@@ -87,6 +92,21 @@ sub parse {
$id
=
$sth
->
fetch
->
[
0
];
}
# insertion du chan
my
$sth
=
$dbh
->
prepare_cached
('
INSERT INTO playbot_chan (content, chan, sender_irc)
VALUES (?,?,?)
');
$log
->
error
("
Couldn't prepare querie; aborting
")
unless
(
defined
$sth
);
$sth
->
execute
(
$id
,
$chan
->
[
0
],
$nick
)
or
$log
->
error
("
Couldn't finish transaction:
"
.
$dbh
->
errstr
);
# in all cases, we commit now
$dbh
->
commit
;
commands::parser::
tag
(
$msg
,
$chan
);
my
@tags
;
# get tags
$sth
=
$dbh
->
prepare
("
select tag
from playbot_tags
...
...
@@ -99,15 +119,7 @@ sub parse {
$tag
=~
s/([a-zA-Z0-9_-]+)/#$1/
;
push
@tags
,
$tag
;
}
# insertion du chan
my
$sth
=
$dbh
->
prepare_cached
('
INSERT INTO playbot_chan (content, chan, sender_irc)
VALUES (?,?,?)
');
$log
->
error
("
Couldn't prepare querie; aborting
")
unless
(
defined
$sth
);
$sth
->
execute
(
$id
,
$chan
->
[
0
],
$nick
)
or
$log
->
error
("
Couldn't finish transaction:
"
.
$dbh
->
errstr
);
$dbh
->
commit
;
# message sur irc
$content
{'
id
'}
=
$id
;
...
...
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