Skip to content
GitLab
Explorer
Connexion
Navigation principale
Rechercher ou aller à…
Projet
N
nardco
Gestion
Activité
Membres
Labels
Programmation
Tickets
Tableaux des tickets
Jalons
Wiki
Wiki externe
Code
Dépôt
Branches
Validations
Étiquettes
Graphe du dépôt
Comparer les révisions
Extraits de code
Déploiement
Releases
Registre de conteneurs
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
Loris TICHADOU
nardco
Validations
90047850
Valider
90047850
rédigé
22 août 2019
par
Loris TICHADOU
Parcourir les fichiers
Options
Téléchargements
Correctifs
Plain Diff
des idiots partout
parent
4f67adae
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Modifications
3
Afficher les modifications d'espaces
En ligne
Côte à côte
Affichage de
3 fichiers modifiés
.gitignore
+1
-0
1 ajout, 0 suppression
.gitignore
nardco.py
+152
-163
152 ajouts, 163 suppressions
nardco.py
philotron.py
+81
-79
81 ajouts, 79 suppressions
philotron.py
avec
234 ajouts
et
242 suppressions
.gitignore
+
1
−
0
Voir le fichier @
90047850
...
...
@@ -2,3 +2,4 @@
.idea
canaux_reddit.txt
praw.ini
config.py
Ce diff est replié.
Cliquez pour l'agrandir.
nardco.py
+
152
−
163
Voir le fichier @
90047850
...
...
@@ -23,7 +23,11 @@ from useless import useless
from
haddock
import
haddock
from
manger
import
is_l_heure_de_manger
,
should_ban
from
bdsm
import
bdsm
import
config
# import rateau
def
couper
(
pseudo
):
return
pseudo
.
split
(
"
!
"
)[
0
]
...
...
@@ -47,6 +51,7 @@ def aram():
"
Zyra
"
]
return
Champ
[
random
.
randint
(
0
,
len
(
Champ
)
-
1
)]
last_args
=
None
last_cmd
=
None
global
pour
...
...
@@ -55,10 +60,6 @@ global suple
suple
=
-
1
global
cmdCarac
cmdCarac
=
"
$
"
personnalizedCmd
=
{}
...
...
@@ -69,19 +70,20 @@ scores = {}
tour
=
0
total
=
0
def
isCommande
(
string
):
global
cmdCarac
return
string
[
0
]
==
cmdCarac
return
string
[
0
]
==
config
.
cmdCarac
def
no_hl
(
pseudo
):
ins
=
u
'
\u200C
'
.
encode
(
"
utf-8
"
)
return
pseudo
[
0
]
+
str
(
ins
)
+
pseudo
[
1
:]
class
Boooob
(
ircbot
.
SingleServerIRCBot
):
def
__init__
(
self
):
ircbot
.
SingleServerIRCBot
.
__init__
(
self
,
[(
"
irc.iiens.net
"
,
6667
)],
"
nardco
"
,
"
Je suis un bot
"
)
ircbot
.
SingleServerIRCBot
.
__init__
(
self
,
[(
"
irc.iiens.net
"
,
6667
)],
config
.
nick
,
"
Je suis un bot
"
)
self
.
temps
=
0
self
.
reddit_temps
=
0
self
.
fichier_reddit
=
"
canaux_reddit.txt
"
...
...
@@ -93,7 +95,8 @@ class Boooob(ircbot.SingleServerIRCBot):
serv
.
join
(
"
#fokontest
"
)
serv
.
join
(
"
#Titch
"
)
# serv.join("#gynecoloc")
serv
.
privmsg
(
"
NickServ
"
,
"
IDENTIFY MotDePasse
"
)
# rejoint #nardco à sa connexion
serv
.
privmsg
(
"
NickServ
"
,
"
IDENTIFY {0}
"
.
format
(
config
.
password
))
# rejoint #nardco à sa connexion
#
def
on_join
(
self
,
serv
,
ev
):
# Quand qq entre dans le chann, le bot inclus
...
...
@@ -105,20 +108,15 @@ class Boooob(ircbot.SingleServerIRCBot):
canal
=
ev
.
arguments
()[
0
]
serv
.
privmsg
(
"
Titch
"
,
couper
(
personne
)
+
"
m
'
a invité sur
"
+
canal
)
def
on_kick
(
self
,
serv
,
ev
):
serv
.
join
(
"
#nardco
"
)
print
(
"
kick
"
)
personne
=
ev
.
source
()
personne
=
couper
(
personne
)
canal
=
ev
.
target
()
if
canal
==
"
#Titch
"
and
personne
!=
"
Titch
"
:
serv
.
mode
(
canal
,
"
-o
"
+
personne
)
def
on_pubmsg
(
self
,
serv
,
ev
):
# quand qq ecrit dans le chat
global
suple
global
cmdCarac
global
personnalizedCmd
global
last_args
global
last_cmd
...
...
@@ -138,7 +136,7 @@ class Boooob(ircbot.SingleServerIRCBot):
split
=
message
.
split
(
"
"
)
if
"
op pls
"
in
message
or
"
op plz
"
in
message
:
serv
.
mode
(
canal
,
"
+o
"
+
personne
)
if
'
nardco
'
in
split
[
0
]
and
'
ou
'
in
message
:
if
config
.
nick
in
split
[
0
]
and
'
ou
'
in
message
:
splt
=
split
[
1
:]
idx
=
splt
.
index
(
"
ou
"
)
choice
=
random
.
randint
(
0
,
1
)
...
...
@@ -183,23 +181,21 @@ class Boooob(ircbot.SingleServerIRCBot):
if
"
aucun lien
"
in
message
:
serv
.
privmsg
(
canal
,
"
Je suis fils unique...
"
)
# fonctions de deplacement dans les chann
if
"
Titch
"
in
personne
and
"
goto
"
in
message
and
"
nardco
"
in
message
:
if
"
Titch
"
in
personne
and
"
goto
"
in
message
and
config
.
nick
in
message
:
f
=
0
for
f
in
range
(
len
(
message
)
-
4
):
if
message
[
f
:
f
+
4
]
==
"
goto
"
:
serv
.
join
(
"
#
"
+
message
[
f
+
5
:])
break
if
"
Titch
"
in
personne
and
"
leave
"
in
message
and
"
nardco
"
in
message
:
if
"
Titch
"
in
personne
and
"
leave
"
in
message
and
config
.
nick
in
message
:
serv
.
part
(
canal
)
if
reponse
is
not
None
:
if
fuzz
.
ratio
(
message
,
reponse
)
>
60
and
personne
not
in
a_repondu
:
serv
.
privmsg
(
canal
,
personne
+
"
a trouvé la reponse : {0} ! Bien joué !
"
.
format
(
reponse
))
serv
.
privmsg
(
canal
,
personne
+
"
a trouvé la reponse : {0} ! Bien joué !
"
.
format
(
reponse
))
reponse
=
None
a_repondu
=
[]
pas_reponse
=
[]
...
...
@@ -217,7 +213,8 @@ class Boooob(ircbot.SingleServerIRCBot):
if
scores
[
pseudo
]
>
maxScore
:
maxScore
=
scores
[
pseudo
]
gagnant
=
pseudo
serv
.
privmsg
(
canal
,
"
{0} a gagné avec un score de {1}
"
.
format
(
gagnant
,
maxScore
))
serv
.
privmsg
(
canal
,
"
{0} a gagné avec un score de {1}
"
.
format
(
gagnant
,
maxScore
))
scores
=
{}
tour
=
0
total
=
0
...
...
@@ -230,18 +227,14 @@ class Boooob(ircbot.SingleServerIRCBot):
serv
.
privmsg
(
canal
,
"
Question : {0}
"
.
format
(
question
.
format
(
'
utf8
'
)))
serv
.
privmsg
(
canal
,
"
Choix: {0}
"
.
format
(
'
,
'
.
join
(
choix
).
format
(
'
utf8
'
)))
else
:
print
pas_reponse
print
message
for
mot
in
pas_reponse
:
if
mot
.
lower
()
in
message
and
not
(
personne
in
a_repondu
):
serv
.
privmsg
(
canal
,
"
WRONG, {0}
"
.
format
(
personne
))
a_repondu
.
append
(
personne
)
if
not
is_l_heure_de_manger
()
and
should_ban
(
message
):
serv
.
privmsg
(
canal
,
"
PUTAIN ON A DIT NON
"
)
# REDDIT // A COMPLETER
if
isCommande
(
message
):
serv
.
privmsg
(
"
Titch
"
,
"
{0} : {1}
"
.
format
(
personne
,
message
))
...
...
@@ -259,7 +252,8 @@ class Boooob(ircbot.SingleServerIRCBot):
last_args
=
args
last_cmd
=
cmd
cmds
=
[
'
help
'
,
'
bdsm
'
,
'
haddock
'
,
'
useless
'
,
'
quizz
'
,
'
ecole
'
,
'
ffs
'
,
'
thanos
'
,
'
chuck
'
,
'
roll
'
,
'
rateau
'
,
'
viieux
'
,
'
kohlanta
'
,
'
new
'
,
'
del
'
,
'
get
'
,
'
debat
'
,
'
pipo
'
,
'
np
'
,
'
commit
'
,
'
zertyu
'
,
'
getsub
'
,
'
sub
'
,
'
delsub
'
,
'
addsub
'
,
'
reddit
'
]
cmds
=
[
'
help
'
,
'
bdsm
'
,
'
haddock
'
,
'
useless
'
,
'
quizz
'
,
'
ecole
'
,
'
ffs
'
,
'
thanos
'
,
'
chuck
'
,
'
roll
'
,
'
rateau
'
,
'
viieux
'
,
'
kohlanta
'
,
'
new
'
,
'
del
'
,
'
get
'
,
'
debat
'
,
'
pipo
'
,
'
np
'
,
'
commit
'
,
'
zertyu
'
,
'
getsub
'
,
'
sub
'
,
'
delsub
'
,
'
addsub
'
,
'
reddit
'
]
most_likely
=
(
cmd
,
0
)
if
cmd
not
in
cmds
:
...
...
@@ -273,8 +267,6 @@ class Boooob(ircbot.SingleServerIRCBot):
if
'
spoil
'
in
args
or
'
spoil
'
in
cmd
:
serv
.
privmsg
(
canal
,
"
Le risque de spoil est present. je fais pas ça.
"
)
elif
cmd
==
"
help
"
:
if
len
(
message
.
split
(
"
"
))
>
1
:
if
"
reddit
"
in
message
.
split
(
"
"
)[
1
]:
...
...
@@ -286,7 +278,7 @@ class Boooob(ircbot.SingleServerIRCBot):
"
{0}delsub <sub> ;
"
"
{0}getsub .
"
"
(getsub renvoie des infos sur
"
"
tous les subs enregistrés pour le chann)
"
).
format
(
cmdCarac
))
"
tous les subs enregistrés pour le chann)
"
).
format
(
config
.
cmdCarac
))
else
:
serv
.
privmsg
(
canal
,
(
"
Commandes disponibles :{0}
"
).
format
(
'
,
'
.
join
(
cmds
)))
...
...
@@ -304,7 +296,6 @@ class Boooob(ircbot.SingleServerIRCBot):
chosen
=
chosen
[
1
:]
serv
.
privmsg
(
canal
,
bdsm
(
personne
,
chosen
))
elif
cmd
==
"
quizz
"
:
if
len
(
args
)
>
1
:
...
...
@@ -314,7 +305,8 @@ class Boooob(ircbot.SingleServerIRCBot):
total
=
10
else
:
total
=
10
serv
.
privmsg
(
canal
,
"
{0} a commencé un quizz ! Jouez ! {1} questions !
"
.
format
(
personne
,
total
))
serv
.
privmsg
(
canal
,
"
{0} a commencé un quizz ! Jouez ! {1} questions !
"
.
format
(
personne
,
total
))
datas
=
quizz
()
reponse
=
datas
[
'
reponse
'
].
lower
()
choix
=
datas
[
'
choix
'
]
...
...
@@ -328,24 +320,24 @@ class Boooob(ircbot.SingleServerIRCBot):
try
:
if
len
(
args
)
>
1
:
serv
.
privmsg
(
canal
,
"
Oui, vous êtes bien à l
'
{}
"
.
format
(
ensiee
(
''
.
join
(
args
[
1
:]))))
serv
.
privmsg
(
canal
,
"
Oui, vous êtes bien à l
'
{}
"
.
format
(
ensiee
(
''
.
join
(
args
[
1
:]))))
else
:
serv
.
privmsg
(
canal
,
"
Oui, vous êtes bien à l
'
{}
"
.
format
(
ensiee
()))
except
:
pass
elif
cmd
==
"
ffs
"
:
serv
.
privmsg
(
canal
,
"
Nom de Dieu de putain de bordel de merde de saloperie de connard d
'
enculé de ta mère
"
)
serv
.
privmsg
(
canal
,
"
Nom de Dieu de putain de bordel de merde de saloperie de connard d
'
enculé de ta mère
"
)
elif
cmd
==
"
chuck
"
:
try
:
parser
=
HTMLParser
()
r
=
requests
.
get
(
"
http://www.chucknorrisfacts.fr/api/get?data=tri:alea;nb:1
"
)
rep
=
r
.
json
()[
0
][
'
fact
'
]
rep
=
parser
.
unescape
(
rep
)
print
(
rep
)
serv
.
privmsg
(
canal
,
rep
.
encode
(
'
utf8
'
))
except
Exception
:
print
str
(
Exception
)
serv
.
privmsg
(
canal
,
"
erreur :(
"
)
elif
cmd
==
"
thanos
"
and
personne
==
"
Titch
"
:
liste
=
self
.
channels
[
canal
].
users
()
...
...
@@ -353,9 +345,9 @@ class Boooob(ircbot.SingleServerIRCBot):
serv
.
privmsg
(
canal
,
"
snap !
"
)
cleanlist
=
[]
for
f
in
liste
:
if
f
[
0
]
in
[
"
~
"
,
"
&
"
,
"
@
"
,
"
%
"
,
"
+
"
]
and
'
nardco
'
not
in
f
:
if
f
[
0
]
in
[
"
~
"
,
"
&
"
,
"
@
"
,
"
%
"
,
"
+
"
]
and
config
.
nick
not
in
f
:
cleanlist
.
append
(
no_hl
(
f
))
elif
'
nardco
'
not
in
f
:
elif
config
.
nick
not
in
f
:
cleanlist
.
append
(
no_hl
(
f
))
live
=
cleanlist
[:
len
(
liste
)
//
2
]
dead
=
cleanlist
[
len
(
liste
)
//
2
+
1
:]
...
...
@@ -363,7 +355,7 @@ class Boooob(ircbot.SingleServerIRCBot):
ts
=
live
[
random
.
randint
(
0
,
len
(
live
)
-
1
)]
serv
.
nick
(
'
{0}_
'
.
format
(
pp
))
serv
.
privmsg
(
canal
,
"
I don
'
t feel so good mr {0}
"
.
format
(
ts
))
serv
.
nick
(
'
nardco
'
)
serv
.
nick
(
config
.
nick
)
live_
=
[]
dead_
=
[]
for
f
in
live
:
...
...
@@ -409,8 +401,8 @@ class Boooob(ircbot.SingleServerIRCBot):
newCmd
[
'
author
'
]
=
personne
newCmd
[
'
channel
'
]
=
canal
personnalizedCmd
[
args
[
1
]]
=
newCmd
print
personnalizedCmd
serv
.
privmsg
(
canal
,
'
commande ajoutée : ${0}, par {1}, pour le chann {2}
'
.
format
(
args
[
1
],
personne
,
canal
))
serv
.
privmsg
(
canal
,
'
commande ajoutée : ${0}, par {1}, pour le chann {2}
'
.
format
(
args
[
1
],
personne
,
canal
))
elif
cmd
==
"
del
"
:
if
len
(
args
)
>
1
:
if
args
[
1
]
in
personnalizedCmd
.
keys
():
...
...
@@ -426,7 +418,6 @@ class Boooob(ircbot.SingleServerIRCBot):
res
.
append
(
f
)
serv
.
privmsg
(
canal
,
'
commandes pour {0} : {1}
'
.
format
(
canal
,
"
,
"
.
join
(
res
)))
elif
cmd
==
"
debat
"
:
serv
.
privmsg
(
canal
,
philotron
.
genererSujet
())
elif
cmd
==
"
pipo
"
:
...
...
@@ -445,7 +436,6 @@ class Boooob(ircbot.SingleServerIRCBot):
elif
args
[
1
]
==
"
decode
"
:
serv
.
privmsg
(
canal
,
codage
.
decode
(
"
"
.
join
(
args
[
2
:])))
elif
cmd
==
"
getsub
"
:
res
=
red
.
get_new
(
self
.
fichier_reddit
,
canal
)
for
f
in
res
:
...
...
@@ -456,7 +446,8 @@ class Boooob(ircbot.SingleServerIRCBot):
for
f
in
bd
:
try
:
if
canal
==
f
.
split
(
"
|
"
)[
0
]:
serv
.
privmsg
(
canal
,
"
Liste des subs pour
"
+
canal
+
"
:
"
+
f
.
split
(
"
|
"
)[
1
])
serv
.
privmsg
(
canal
,
"
Liste des subs pour
"
+
canal
+
"
:
"
+
f
.
split
(
"
|
"
)[
1
])
except
:
pass
...
...
@@ -550,7 +541,5 @@ class Boooob(ircbot.SingleServerIRCBot):
serv
.
privmsg
(
canal
,
personnalizedCmd
[
cmd
][
'
result
'
])
if
__name__
==
"
__main__
"
:
Boooob
().
start
()
Ce diff est replié.
Cliquez pour l'agrandir.
philotron.py
+
81
−
79
Voir le fichier @
90047850
# coding:utf8
import
random
def
genererSujet
():
sujets
=
[[
"
l
'
oeuvre d
'
art
"
,
"
f
"
],
[
"
la réalité
"
,
"
f
"
],
...
...
@@ -44,14 +45,16 @@ def genererSujet() :
[
"
Que vaut l
'
opposition de **1 et de **2
"
,
"
Que vaut l
'
opposition de **1 et de **2
"
],
[
"
**1 peut-il se satisfaire de **2
"
,
"
**1 peut-elle se satisfaire de **2
"
],
[
"
La recherche de **1 est-elle **e
"
,
"
La recherche de **1 est-elle **e
"
],
[
"
**1 transforme-t-il notre conscience de **2
"
,
"
**1 transforme-t-elle notre conscience de **2
"
],
[
"
**1 transforme-t-il notre conscience de **2
"
,
"
**1 transforme-t-elle notre conscience de **2
"
],
[
"
Peut-on comprendre **1
"
,
"
Peut-on comprendre **1
"
],
[
"
**1 peut-il s
'
éduquer
"
,
"
**1 peut-elle s
'
éduquer
"
],
[
"
Peut-on échapper à **1
"
,
"
Peut-on échapper à **1
"
],
[
"
**1 n
'
est-il qu
'
un outil
"
,
"
**1 n
'
est-elle qu
'
un outil
"
],
[
"
**1 se limite-t-il à **2
"
,
"
**1 se limite-t-elle à **2
"
],
[
"
Que devons-nous à **1
"
,
"
Que devons-nous à **1
"
],
[
"
**1 nous permet-il de prendre conscience de **2
"
,
"
**1 nous permet-elle de prendre conscience de **2
"
],
[
"
**1 nous permet-il de prendre conscience de **2
"
,
"
**1 nous permet-elle de prendre conscience de **2
"
],
[
"
Devons-nous aspirer à maîtriser **1
"
,
"
Devons-nous aspirer à maîtriser **1
"
],
[
"
**1 est-il contraire à **2
"
,
"
**1 est-elle contraire à **2
"
],
[
"
Peut-on vivre sans **1
"
,
"
Peut-on vivre sans **1
"
],
...
...
@@ -91,4 +94,3 @@ def genererSujet() :
result
=
result
[
0
].
upper
()
+
result
[
1
:]
result
=
result
+
"
?
"
return
result
print
(
genererSujet
())
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
Please
se connecter
to comment