Ajout des fichiers
This commit is contained in:
commit
5bde822623
20 changed files with 586 additions and 0 deletions
3
README.md
Normal file
3
README.md
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
#Klafirc
|
||||||
|
|
||||||
|
Klafirc is a simple irc bot which react to matches and pings.
|
46
bots.yaml
Normal file
46
bots.yaml
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
bots:
|
||||||
|
sel:
|
||||||
|
on_ping:
|
||||||
|
- "Arcas:`à viarezo ils font des caleçons.` Chibrac:`bah non au rezo, à viarezo ils ont pas de boules à couvrir`"
|
||||||
|
- "Unleash the salt"
|
||||||
|
- "Les lentilles c'est extrêmement pratique de base pour toute personne active [wink-wink Chibrac, NDLR]"
|
||||||
|
- "proxima (ViaRézo):Pour ce qui est du reste, nous avons, je crois, bien compris votre demande ; mais nos impératifs actuels, surtout pour Rennes et Metz, impliquent de passer par notre école, qui est a priori assez frileuse vis-à-vis du Crans et de ses relations avec le CROUS; nous espérons donc pouvoir à terme nous rapprocher de la présentation que tu décris, mais cela impliquerait un travail en amont pour ne pas contrevenir à nos propres efforts, et nous souhaiterions donc que vous présentiez pas, pour l’instant, vos démarches comme une action commune avec ViaRézo."
|
||||||
|
- "J'ai vraiment hâte de rencontrer les N1As de l'année prochaine."
|
||||||
|
- "À Metz vous êtes vraiment des experts."
|
||||||
|
- "Centrale Metz"
|
||||||
|
- "<David_5-1> bon, babel avec un pare-feu nftables, vous avez prévu d'y réfléchir pour 2042 ou ça a des chances d'arriver sous peu ?"
|
||||||
|
- "<Chibrac> je glande presque autant qu'un pelec"
|
||||||
|
- "<Chibrac> choisi l'excuse du moment chez ton supelec : l'inté, la campagne, les partiels, les vacances"
|
||||||
|
- "<Grubigrub> Chirac on connaît tous tes performances scolaires t'inquiète pas"
|
||||||
|
on_match:
|
||||||
|
'détruire le monde' : "Manu on fait des collages ?"
|
||||||
|
'{name}, pourquoi es-tu là ?' : "{user} : En l'an 2018, en plus d'être feignants, les Rézomen devinrent salés à cause de la fermeture du campus. C'est pourquoi un jeune Rézoman nommé Klafyvel m'a créé, afin d'avoir un salage automatique de {channel}. Depuis je hante le chan."
|
||||||
|
'on peut te joindre sur irc et telegram ?' : "{user} : oui, sur telegram pour que mes amis iraniens profitent de ma science et sur irc en attendant que les barbus en mode de reconnaissance se mettent à la page. Je pense qu'on devrait ajouter un bridge matrix \U0001f914"
|
||||||
|
Macron:
|
||||||
|
on_ping:
|
||||||
|
- "PARCE QUE C'EST NOTRE PROJEEEET !"
|
||||||
|
on_match:
|
||||||
|
'tocard' : "Est-ce que je peux dire autocar ?"
|
||||||
|
'^Manu.*\?' : "Tu m’appelles monsieur le président de la République, ou monsieur."
|
||||||
|
Patou:
|
||||||
|
on_ping:
|
||||||
|
- "En parlant de ça, Centrale ne sait vraiment pas travailler en multicampus"
|
||||||
|
- "On avait ouvert une voie d'escalade sur une des façades de la résidence"
|
||||||
|
- "Je vous ai parlé de la fois où j'ai discuté avec Bill Gates ?"
|
||||||
|
- "Bosse plutôt que de me faire la conversation !"
|
||||||
|
- "On parle, on parle, mais le code il avance pas beaucoup"
|
||||||
|
- "Garantie 5 ans puis poubelle"
|
||||||
|
- "Ben non, c'est une idée de merde"
|
||||||
|
- "Oui, vas-y, fait comme tu veux"
|
||||||
|
- "Je suis généreux, mais toi ça va pas être facile de te trouver des points"
|
||||||
|
- "Attend un peu, il y a Konrad qui m'appelle. Qu'est-ce qu'il me veut encore celui-là ?"
|
||||||
|
- "Hein !?"
|
||||||
|
- "Faites du vpn sur l'ecole ou sur la rez depuis l'exterieur"
|
||||||
|
- "Je viens donc de supprimer les comptes et de détruire les boites mail"
|
||||||
|
- "Au fait, j'ai l'impression que vous avez limité ma vitesse de téléchargement, c'est un peu lent je trouve ... évitez de brider ma machine svp"
|
||||||
|
|
||||||
|
channels:
|
||||||
|
- server: irc.rezometz.org
|
||||||
|
port: 6667
|
||||||
|
channel: "#test"
|
||||||
|
bots: [sel, Macron, Patou]
|
7
install.sh
Normal file
7
install.sh
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
pip3 install -r requirements.txt
|
||||||
|
mkdir /var/log/klafirc
|
||||||
|
mkdir /etc/klafirc
|
||||||
|
cp bots.yaml /etc/klafirc
|
||||||
|
cp klafirc.service /etc/systemd/system/
|
||||||
|
systemctl enable klafirc.service
|
||||||
|
systemctl start klafirc.service
|
14
klafirc.service
Normal file
14
klafirc.service
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
[Unit]
|
||||||
|
Description=Klafyirc bots
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
|
||||||
|
User=klafirc
|
||||||
|
Group=klafirc
|
||||||
|
|
||||||
|
ExecStart=python3 -m klafirc
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
7
klafirc/__init__.py
Normal file
7
klafirc/__init__.py
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
"""
|
||||||
|
A simple irc bot. See /etc/klafirc/bots.yaml to see which bots are runned.
|
||||||
|
"""
|
||||||
|
|
||||||
|
from .runner import run
|
||||||
|
|
||||||
|
__version__ = "0.1"
|
3
klafirc/__main__.py
Normal file
3
klafirc/__main__.py
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
from . import run
|
||||||
|
|
||||||
|
run()
|
BIN
klafirc/__pycache__/__init__.cpython-36.pyc
Normal file
BIN
klafirc/__pycache__/__init__.cpython-36.pyc
Normal file
Binary file not shown.
BIN
klafirc/__pycache__/__main__.cpython-36.pyc
Normal file
BIN
klafirc/__pycache__/__main__.cpython-36.pyc
Normal file
Binary file not shown.
BIN
klafirc/__pycache__/bot.cpython-36.pyc
Normal file
BIN
klafirc/__pycache__/bot.cpython-36.pyc
Normal file
Binary file not shown.
BIN
klafirc/__pycache__/irc.cpython-36.pyc
Normal file
BIN
klafirc/__pycache__/irc.cpython-36.pyc
Normal file
Binary file not shown.
BIN
klafirc/__pycache__/loader.cpython-36.pyc
Normal file
BIN
klafirc/__pycache__/loader.cpython-36.pyc
Normal file
Binary file not shown.
BIN
klafirc/__pycache__/runner.cpython-36.pyc
Normal file
BIN
klafirc/__pycache__/runner.cpython-36.pyc
Normal file
Binary file not shown.
BIN
klafirc/__pycache__/settings.cpython-36.pyc
Normal file
BIN
klafirc/__pycache__/settings.cpython-36.pyc
Normal file
Binary file not shown.
68
klafirc/bot.py
Normal file
68
klafirc/bot.py
Normal file
|
@ -0,0 +1,68 @@
|
||||||
|
import re
|
||||||
|
import random
|
||||||
|
|
||||||
|
class Bot:
|
||||||
|
def __init__(self, nickname):
|
||||||
|
"""Initialize a bot object
|
||||||
|
|
||||||
|
Args:
|
||||||
|
nickname: nickname of the bot on irc
|
||||||
|
"""
|
||||||
|
self.nickname = nickname
|
||||||
|
self.channel = None
|
||||||
|
self.port = None
|
||||||
|
self.server = None
|
||||||
|
self.reactions = {}
|
||||||
|
self.pings = []
|
||||||
|
self.ping_match = re.compile('^(<.+> )?\@?{name}'.format(name=nickname))
|
||||||
|
|
||||||
|
def add_reaction(self, match, reaction):
|
||||||
|
"""Add a reaction to the bot.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
match: The string which, if matched will trigger the answer.
|
||||||
|
reaction: The string which will be sent.
|
||||||
|
"""
|
||||||
|
context = {
|
||||||
|
'server': self.server,
|
||||||
|
'channel': self.channel,
|
||||||
|
'name': self.nickname,
|
||||||
|
}
|
||||||
|
self.reactions[re.compile(match.format(**context))] = reaction
|
||||||
|
|
||||||
|
def add_ping(self, reaction):
|
||||||
|
"""Add a reaction to a ping"""
|
||||||
|
|
||||||
|
self.pings.append(reaction)
|
||||||
|
|
||||||
|
def get_reaction(self, user, channel, message):
|
||||||
|
"""Get a reaction to a message.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
user: The user who sent the message.
|
||||||
|
channel: The channel on which the bot speak.
|
||||||
|
message: The message to which the bot has to react.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
Every matched reactions.
|
||||||
|
"""
|
||||||
|
username = user.split('!')[0]
|
||||||
|
|
||||||
|
context = {
|
||||||
|
'server': self.server,
|
||||||
|
'channel': channel,
|
||||||
|
'name': self.nickname,
|
||||||
|
'user': username,
|
||||||
|
'message': message
|
||||||
|
}
|
||||||
|
result = []
|
||||||
|
for m in self.reactions.keys():
|
||||||
|
if m.search(message):
|
||||||
|
result.append(self.reactions[m].format(**context))
|
||||||
|
|
||||||
|
if not result and self.ping_match.search(message):
|
||||||
|
sentence = random.choice(self.pings).format(**context)
|
||||||
|
result.append(' : '.join([username, sentence]))
|
||||||
|
|
||||||
|
return result
|
||||||
|
|
55
klafirc/irc.py
Normal file
55
klafirc/irc.py
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
from twisted.words.protocols import irc
|
||||||
|
from twisted.internet import reactor, protocol
|
||||||
|
|
||||||
|
from .bot import Bot
|
||||||
|
from .settings import logger
|
||||||
|
|
||||||
|
class IRCBot(irc.IRCClient):
|
||||||
|
"""An IRC bot"""
|
||||||
|
|
||||||
|
def connectionMade(self):
|
||||||
|
super(IRCBot, self).connectionMade()
|
||||||
|
logger.info('{name} is connected'.format(name=self.nickname))
|
||||||
|
self.join(self.factory.channel)
|
||||||
|
|
||||||
|
def connectionLost(self, reason):
|
||||||
|
super(IRCBot, self).connectionLost(reason)
|
||||||
|
logger.info('{name} is disconnected : {reason}'.format(
|
||||||
|
name=self.nickname,
|
||||||
|
reason = reason
|
||||||
|
))
|
||||||
|
|
||||||
|
def signedOn(self):
|
||||||
|
self.join(self.factory.channel)
|
||||||
|
|
||||||
|
def joined(self, channel):
|
||||||
|
logger.info(self.nickname + ' joined ' + self.factory.channel)
|
||||||
|
|
||||||
|
def privmsg(self, user, channel, msg):
|
||||||
|
results = self.factory.bot.get_reaction(user, channel, msg)
|
||||||
|
logger.debug(self.nickname + ' heard ' + msg)
|
||||||
|
if results:
|
||||||
|
logger.info(self.nickname + ' reacting to ' + msg)
|
||||||
|
for r in results:
|
||||||
|
self.say(self.factory.channel, r)
|
||||||
|
|
||||||
|
|
||||||
|
class IRCBotFactory(protocol.ClientFactory):
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
self.channel = bot.channel
|
||||||
|
|
||||||
|
def clientConnectionLost(self, connector, reason):
|
||||||
|
connector.connect()
|
||||||
|
logger.info("Client connexion lost")
|
||||||
|
|
||||||
|
def clientConnectionFailed(self, connector, reason):
|
||||||
|
logger.info("Connection failed : " + reason)
|
||||||
|
reactor.stop()
|
||||||
|
|
||||||
|
def buildProtocol(self, addr):
|
||||||
|
p = IRCBot()
|
||||||
|
p.factory = self
|
||||||
|
p.nickname = self.bot.nickname
|
||||||
|
return p
|
||||||
|
|
289
klafirc/klafirc.log
Normal file
289
klafirc/klafirc.log
Normal file
|
@ -0,0 +1,289 @@
|
||||||
|
2018-08-02 12:38:12,880 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 12:38:12,880 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 12:38:12,969 :: INFO :: sel is connected
|
||||||
|
2018-08-02 12:38:12,970 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 12:38:12,974 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 12:38:14,691 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 12:38:14,710 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 12:38:14,726 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 12:38:14,773 :: DEBUG :: Macron_ heard Hello
|
||||||
|
2018-08-02 12:38:14,777 :: DEBUG :: sel_ heard Hello
|
||||||
|
2018-08-02 12:38:14,790 :: DEBUG :: Patou heard Hello
|
||||||
|
2018-08-02 12:38:14,791 :: DEBUG :: Patou heard Hello
|
||||||
|
2018-08-02 12:38:14,878 :: DEBUG :: Macron_ heard Hello
|
||||||
|
2018-08-02 12:38:14,882 :: DEBUG :: sel_ heard Hello
|
||||||
|
2018-08-02 12:39:13,839 :: DEBUG :: Patou heard sel : est un tocard
|
||||||
|
2018-08-02 12:39:13,840 :: DEBUG :: sel_ heard sel : est un tocard
|
||||||
|
2018-08-02 12:39:13,841 :: INFO :: sel_ reacting to sel : est un tocard
|
||||||
|
2018-08-02 12:39:13,841 :: DEBUG :: Macron_ heard sel : est un tocard
|
||||||
|
2018-08-02 12:39:13,912 :: DEBUG :: Macron_ heard klafyvel : À Metz vous êtes vraiment des experts.
|
||||||
|
2018-08-02 12:39:13,913 :: DEBUG :: Patou heard klafyvel : À Metz vous êtes vraiment des experts.
|
||||||
|
2018-08-02 12:39:37,662 :: DEBUG :: sel_ heard tocard
|
||||||
|
2018-08-02 12:39:37,663 :: DEBUG :: Patou heard tocard
|
||||||
|
2018-08-02 12:39:37,664 :: DEBUG :: Macron_ heard tocard
|
||||||
|
2018-08-02 12:39:37,664 :: INFO :: Macron_ reacting to tocard
|
||||||
|
2018-08-02 12:39:37,746 :: DEBUG :: Patou heard Est-ce que je peux dire autocar ?
|
||||||
|
2018-08-02 12:39:37,766 :: DEBUG :: sel_ heard Est-ce que je peux dire autocar ?
|
||||||
|
2018-08-02 12:43:05,801 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 12:43:05,802 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 12:43:05,803 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 12:43:05,803 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 12:43:05,804 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 12:43:05,804 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 12:43:06,716 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 12:43:06,716 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 12:43:06,804 :: INFO :: sel is connected
|
||||||
|
2018-08-02 12:43:06,805 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 12:43:06,810 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 12:43:07,195 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 12:43:07,211 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 12:43:08,286 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 12:43:27,472 :: DEBUG :: Patou heard sel est un tocard
|
||||||
|
2018-08-02 12:43:27,473 :: DEBUG :: sel_ heard sel est un tocard
|
||||||
|
2018-08-02 12:43:27,474 :: INFO :: sel_ reacting to sel est un tocard
|
||||||
|
2018-08-02 12:43:27,475 :: DEBUG :: Macron_ heard sel est un tocard
|
||||||
|
2018-08-02 12:43:27,476 :: INFO :: Macron_ reacting to sel est un tocard
|
||||||
|
2018-08-02 12:43:27,549 :: DEBUG :: Patou heard klafyvel : Arcas:`à viarezo ils font des caleçons.` Chibrac:`bah non au rezo, à viarezo ils ont pas de boules à couvrir`
|
||||||
|
2018-08-02 12:43:27,550 :: DEBUG :: Macron_ heard klafyvel : Arcas:`à viarezo ils font des caleçons.` Chibrac:`bah non au rezo, à viarezo ils ont pas de boules à couvrir`
|
||||||
|
2018-08-02 12:43:27,553 :: DEBUG :: sel_ heard Est-ce que je peux dire autocar ?
|
||||||
|
2018-08-02 12:43:27,616 :: DEBUG :: Patou heard Est-ce que je peux dire autocar ?
|
||||||
|
2018-08-02 12:43:51,988 :: DEBUG :: sel_ heard bon maintenant que ça march
|
||||||
|
2018-08-02 12:43:51,988 :: DEBUG :: Patou heard bon maintenant que ça march
|
||||||
|
2018-08-02 12:43:51,990 :: DEBUG :: Macron_ heard bon maintenant que ça march
|
||||||
|
2018-08-02 12:44:00,396 :: DEBUG :: Patou heard voyons si on peut détruire le monde
|
||||||
|
2018-08-02 12:44:00,397 :: DEBUG :: sel_ heard voyons si on peut détruire le monde
|
||||||
|
2018-08-02 12:44:00,398 :: DEBUG :: Macron_ heard voyons si on peut détruire le monde
|
||||||
|
2018-08-02 12:45:22,325 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 12:45:22,325 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 12:45:22,325 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 12:45:22,326 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 12:45:22,326 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 12:45:22,327 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 12:45:23,250 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 12:45:23,251 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 12:45:23,341 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 12:45:23,342 :: INFO :: sel is connected
|
||||||
|
2018-08-02 12:45:23,345 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 12:45:24,779 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 12:45:24,799 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 12:45:24,817 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 12:45:39,875 :: DEBUG :: Patou heard voyons si on peut détruire le monde
|
||||||
|
2018-08-02 12:45:39,876 :: DEBUG :: sel_ heard voyons si on peut détruire le monde
|
||||||
|
2018-08-02 12:45:39,876 :: INFO :: sel_ reacting to voyons si on peut détruire le monde
|
||||||
|
2018-08-02 12:45:39,877 :: DEBUG :: Macron_ heard voyons si on peut détruire le monde
|
||||||
|
2018-08-02 12:45:39,948 :: DEBUG :: Patou heard Manu on fait des collages ?
|
||||||
|
2018-08-02 12:45:39,948 :: DEBUG :: Macron_ heard Manu on fait des collages ?
|
||||||
|
2018-08-02 12:45:39,949 :: INFO :: Macron_ reacting to Manu on fait des collages ?
|
||||||
|
2018-08-02 12:45:40,020 :: DEBUG :: Patou heard Tu m’appelles monsieur le président de la République, ou monsieur.
|
||||||
|
2018-08-02 12:45:40,021 :: DEBUG :: sel_ heard Tu m’appelles monsieur le président de la République, ou monsieur.
|
||||||
|
2018-08-02 12:46:12,091 :: DEBUG :: Patou heard parfait, maintenant un peu de sucre pour les réponses
|
||||||
|
2018-08-02 12:46:12,092 :: DEBUG :: Macron_ heard parfait, maintenant un peu de sucre pour les réponses
|
||||||
|
2018-08-02 12:46:12,093 :: DEBUG :: sel_ heard parfait, maintenant un peu de sucre pour les réponses
|
||||||
|
2018-08-02 13:34:28,694 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:34:28,694 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:34:28,695 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:34:28,696 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:34:28,697 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:34:28,697 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:34:29,882 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:34:29,882 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:34:30,150 :: INFO :: sel is connected
|
||||||
|
2018-08-02 13:34:30,152 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 13:34:30,156 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 13:34:30,999 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 13:34:32,071 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 13:34:32,088 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 13:34:56,009 :: DEBUG :: Patou heard sel 🤔
|
||||||
|
2018-08-02 13:34:56,011 :: DEBUG :: sel_ heard sel 🤔
|
||||||
|
2018-08-02 13:34:56,011 :: INFO :: sel_ reacting to sel 🤔
|
||||||
|
2018-08-02 13:34:56,012 :: DEBUG :: Macron_ heard sel 🤔
|
||||||
|
2018-08-02 13:34:56,085 :: DEBUG :: Macron_ heard klafyvel : J'ai vraiment hâte de rencontrer les N1As de l'année prochaine.
|
||||||
|
2018-08-02 13:34:56,086 :: DEBUG :: Patou heard klafyvel : J'ai vraiment hâte de rencontrer les N1As de l'année prochaine.
|
||||||
|
2018-08-02 13:41:46,583 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:41:46,584 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:41:46,585 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:41:46,585 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:41:46,586 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:41:46,587 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:41:47,743 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:41:47,743 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:42:55,998 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:42:55,998 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:43:29,672 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:43:29,672 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:43:41,504 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:43:41,504 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:43:54,043 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:43:54,044 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:46:29,128 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:46:29,128 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:46:39,634 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:46:39,634 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:46:39,722 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 13:46:39,726 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 13:46:39,731 :: INFO :: sel is connected
|
||||||
|
2018-08-02 13:46:41,131 :: INFO :: Macron_ joined Macron
|
||||||
|
2018-08-02 13:46:41,147 :: INFO :: Patou joined Patou
|
||||||
|
2018-08-02 13:46:41,168 :: INFO :: sel_ joined sel
|
||||||
|
2018-08-02 13:47:20,301 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:47:20,302 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:47:20,302 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:47:20,303 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:47:20,303 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:47:20,304 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:47:21,126 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:47:21,126 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:47:21,216 :: INFO :: sel is connected
|
||||||
|
2018-08-02 13:47:21,217 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 13:47:21,221 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 13:47:22,623 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 13:47:22,627 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 13:47:22,644 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 13:49:16,664 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:49:16,665 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:49:16,666 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:49:16,666 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:49:16,667 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:49:16,668 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:49:17,342 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:49:17,342 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:49:17,434 :: INFO :: sel is connected
|
||||||
|
2018-08-02 13:49:17,436 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 13:49:17,444 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 13:49:18,843 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 13:49:18,860 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 13:49:18,880 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 13:49:40,409 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:49:40,410 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:49:40,410 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:49:40,411 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:49:40,411 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:49:40,412 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:49:41,196 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:49:41,196 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:49:41,288 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 13:49:41,290 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 13:49:41,293 :: INFO :: sel is connected
|
||||||
|
2018-08-02 13:49:41,696 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 13:49:41,712 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 13:49:42,979 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 13:49:48,547 :: DEBUG :: Macron_ heard sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:49:48,548 :: DEBUG :: Patou heard sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:49:48,552 :: DEBUG :: sel_ heard sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:49:48,552 :: INFO :: sel_ reacting to sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:49:48,630 :: DEBUG :: Patou heard En l'an 2018, en plus d'être feignants, les Rézomen devinrent salés à cause de la fermeture du campus. C'est pourquoi un jeune Rézoman nommé Klafyvel m'a créé, afin d'avoir un salage automatique de {channel}. Depuis je hante le chan.
|
||||||
|
2018-08-02 13:49:48,630 :: DEBUG :: Patou heard klafyvel : J'ai vraiment hâte de rencontrer les N1As de l'année prochaine.
|
||||||
|
2018-08-02 13:49:48,631 :: DEBUG :: Macron_ heard En l'an 2018, en plus d'être feignants, les Rézomen devinrent salés à cause de la fermeture du campus. C'est pourquoi un jeune Rézoman nommé Klafyvel m'a créé, afin d'avoir un salage automatique de {channel}. Depuis je hante le chan.
|
||||||
|
2018-08-02 13:49:48,632 :: DEBUG :: Macron_ heard klafyvel : J'ai vraiment hâte de rencontrer les N1As de l'année prochaine.
|
||||||
|
2018-08-02 13:51:07,441 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:51:07,442 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:51:07,442 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:51:07,443 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:51:07,444 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:51:07,445 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:51:08,366 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:51:08,366 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:51:08,456 :: INFO :: sel is connected
|
||||||
|
2018-08-02 13:51:08,457 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 13:51:08,463 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 13:51:09,844 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 13:51:09,863 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 13:51:09,901 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 13:51:18,927 :: DEBUG :: Patou heard sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:51:18,929 :: DEBUG :: sel_ heard sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:51:18,929 :: INFO :: sel_ reacting to sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:51:18,930 :: DEBUG :: Macron_ heard sel, pourquoi es-tu là ?
|
||||||
|
2018-08-02 13:51:19,022 :: DEBUG :: Patou heard En l'an 2018, en plus d'être feignants, les Rézomen devinrent salés à cause de la fermeture du campus. C'est pourquoi un jeune Rézoman nommé Klafyvel m'a créé, afin d'avoir un salage automatique de #test. Depuis je hante le chan.
|
||||||
|
2018-08-02 13:51:19,022 :: DEBUG :: Macron_ heard En l'an 2018, en plus d'être feignants, les Rézomen devinrent salés à cause de la fermeture du campus. C'est pourquoi un jeune Rézoman nommé Klafyvel m'a créé, afin d'avoir un salage automatique de #test. Depuis je hante le chan.
|
||||||
|
2018-08-02 13:51:45,392 :: DEBUG :: sel_ heard Sel, quel est votre métier ?
|
||||||
|
2018-08-02 13:51:45,393 :: DEBUG :: Macron_ heard Sel, quel est votre métier ?
|
||||||
|
2018-08-02 13:51:45,394 :: DEBUG :: Patou heard Sel, quel est votre métier ?
|
||||||
|
2018-08-02 13:52:05,863 :: DEBUG :: sel_ heard ah oui la casse
|
||||||
|
2018-08-02 13:52:05,865 :: DEBUG :: Macron_ heard ah oui la casse
|
||||||
|
2018-08-02 13:52:05,865 :: DEBUG :: Patou heard ah oui la casse
|
||||||
|
2018-08-02 13:52:07,112 :: DEBUG :: sel_ heard sel devient insensible à la casse
|
||||||
|
2018-08-02 13:52:07,113 :: INFO :: sel_ reacting to sel devient insensible à la casse
|
||||||
|
2018-08-02 13:52:07,113 :: DEBUG :: Patou heard sel devient insensible à la casse
|
||||||
|
2018-08-02 13:52:07,114 :: DEBUG :: Macron_ heard sel devient insensible à la casse
|
||||||
|
2018-08-02 13:52:07,187 :: DEBUG :: Patou heard Guimoz : J'ai vraiment hâte de rencontrer les N1As de l'année prochaine.
|
||||||
|
2018-08-02 13:52:07,188 :: DEBUG :: Macron_ heard Guimoz : J'ai vraiment hâte de rencontrer les N1As de l'année prochaine.
|
||||||
|
2018-08-02 13:52:24,071 :: DEBUG :: sel_ heard sel, tu penses quoi de Manu ?
|
||||||
|
2018-08-02 13:52:24,072 :: INFO :: sel_ reacting to sel, tu penses quoi de Manu ?
|
||||||
|
2018-08-02 13:52:24,074 :: DEBUG :: Patou heard sel, tu penses quoi de Manu ?
|
||||||
|
2018-08-02 13:52:24,075 :: DEBUG :: Macron_ heard sel, tu penses quoi de Manu ?
|
||||||
|
2018-08-02 13:52:24,144 :: DEBUG :: Patou heard klafyvel : <Chibrac> je glande presque autant qu'un pelec
|
||||||
|
2018-08-02 13:52:24,145 :: DEBUG :: Macron_ heard klafyvel : <Chibrac> je glande presque autant qu'un pelec
|
||||||
|
2018-08-02 13:52:33,881 :: DEBUG :: sel_ heard ouais moyennement pertinent
|
||||||
|
2018-08-02 13:52:33,882 :: DEBUG :: Macron_ heard ouais moyennement pertinent
|
||||||
|
2018-08-02 13:52:33,883 :: DEBUG :: Patou heard ouais moyennement pertinent
|
||||||
|
2018-08-02 13:53:57,589 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:53:57,590 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:53:57,591 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:53:57,592 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:53:57,592 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:53:57,593 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:53:58,453 :: INFO :: Klafirc is running !
|
||||||
|
2018-08-02 13:53:58,453 :: INFO :: Loading configuration from bots.yaml
|
||||||
|
2018-08-02 13:53:58,546 :: INFO :: Patou is connected
|
||||||
|
2018-08-02 13:53:58,547 :: INFO :: Macron is connected
|
||||||
|
2018-08-02 13:53:58,555 :: INFO :: sel is connected
|
||||||
|
2018-08-02 13:53:59,964 :: INFO :: Patou joined #test
|
||||||
|
2018-08-02 13:53:59,985 :: INFO :: Macron_ joined #test
|
||||||
|
2018-08-02 13:53:59,999 :: INFO :: sel_ joined #test
|
||||||
|
2018-08-02 13:54:51,169 :: DEBUG :: Patou heard sel on va détruire le monde ?
|
||||||
|
2018-08-02 13:54:51,170 :: DEBUG :: Macron_ heard sel on va détruire le monde ?
|
||||||
|
2018-08-02 13:54:51,171 :: DEBUG :: sel_ heard sel on va détruire le monde ?
|
||||||
|
2018-08-02 13:54:51,172 :: INFO :: sel_ reacting to sel on va détruire le monde ?
|
||||||
|
2018-08-02 13:54:51,248 :: DEBUG :: Patou heard Manu on fait des collages ?
|
||||||
|
2018-08-02 13:54:51,248 :: DEBUG :: Macron_ heard Manu on fait des collages ?
|
||||||
|
2018-08-02 13:54:51,249 :: INFO :: Macron_ reacting to Manu on fait des collages ?
|
||||||
|
2018-08-02 13:54:51,319 :: DEBUG :: Patou heard Tu m’appelles monsieur le président de la République, ou monsieur.
|
||||||
|
2018-08-02 13:54:51,320 :: DEBUG :: sel_ heard Tu m’appelles monsieur le président de la République, ou monsieur.
|
||||||
|
2018-08-02 13:55:12,882 :: DEBUG :: Macron_ heard Macron : ça part
|
||||||
|
2018-08-02 13:55:12,883 :: INFO :: Macron_ reacting to Macron : ça part
|
||||||
|
2018-08-02 13:55:12,884 :: DEBUG :: Patou heard Macron : ça part
|
||||||
|
2018-08-02 13:55:12,885 :: DEBUG :: sel_ heard Macron : ça part
|
||||||
|
2018-08-02 13:55:12,957 :: DEBUG :: Patou heard klafyvel : PARCE QUE C'EST NOTRE PROJEEEET !
|
||||||
|
2018-08-02 13:55:12,958 :: DEBUG :: sel_ heard klafyvel : PARCE QUE C'EST NOTRE PROJEEEET !
|
||||||
|
2018-08-02 13:56:18,732 :: DEBUG :: sel_ heard paaarfait
|
||||||
|
2018-08-02 13:56:18,734 :: DEBUG :: Patou heard paaarfait
|
||||||
|
2018-08-02 13:56:18,735 :: DEBUG :: Macron_ heard paaarfait
|
||||||
|
2018-08-02 13:56:35,543 :: DEBUG :: Patou heard maintenant un petit setup d'installation, un service et c'est fini
|
||||||
|
2018-08-02 13:56:35,545 :: DEBUG :: Macron_ heard maintenant un petit setup d'installation, un service et c'est fini
|
||||||
|
2018-08-02 13:56:35,546 :: DEBUG :: sel_ heard maintenant un petit setup d'installation, un service et c'est fini
|
||||||
|
2018-08-02 13:56:37,145 :: INFO :: Patou is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:56:37,146 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:56:37,146 :: INFO :: sel_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:56:37,147 :: INFO :: Client connexion lost
|
||||||
|
2018-08-02 13:56:37,147 :: INFO :: Macron_ is disconnected : [Failure instance: Traceback (failure with no frames): <class 'twisted.internet.error.ConnectionLost'>: Connection to the other side was lost in a non-clean fashion: Connection lost.
|
||||||
|
]
|
||||||
|
2018-08-02 13:56:37,148 :: INFO :: Client connexion lost
|
38
klafirc/loader.py
Normal file
38
klafirc/loader.py
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
from .bot import Bot
|
||||||
|
from .settings import logger
|
||||||
|
|
||||||
|
|
||||||
|
class Loader:
|
||||||
|
def __init__(self, filename):
|
||||||
|
logger.info('Loading configuration from ' + filename)
|
||||||
|
with open(filename) as f:
|
||||||
|
self.dict = yaml.load(f)
|
||||||
|
self.bots = []
|
||||||
|
|
||||||
|
def load_bot_template(self, name, channel, serv, port):
|
||||||
|
template = self.dict['bots'][name]
|
||||||
|
b = Bot(nickname=name)
|
||||||
|
b.server = serv
|
||||||
|
b.channel = channel
|
||||||
|
b.port = port
|
||||||
|
for ping in template.get('on_ping', []):
|
||||||
|
b.add_ping(ping)
|
||||||
|
|
||||||
|
matches = template.get('on_match', [])
|
||||||
|
for match in matches:
|
||||||
|
b.add_reaction(match, matches[match])
|
||||||
|
|
||||||
|
return b
|
||||||
|
|
||||||
|
def load_bots(self):
|
||||||
|
for channel in self.dict['channels']:
|
||||||
|
name = channel['channel']
|
||||||
|
serv = channel['server']
|
||||||
|
port = channel.get('port', 6667)
|
||||||
|
bots_name = channel['bots']
|
||||||
|
|
||||||
|
for nickname in bots_name:
|
||||||
|
b = self.load_bot_template(nickname, name, serv, port)
|
||||||
|
self.bots.append(b)
|
21
klafirc/runner.py
Normal file
21
klafirc/runner.py
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
from twisted.internet import reactor
|
||||||
|
|
||||||
|
from .loader import Loader
|
||||||
|
from .irc import IRCBotFactory
|
||||||
|
from .settings import logger, BOT_FILE
|
||||||
|
|
||||||
|
class Runner:
|
||||||
|
def __init__(self):
|
||||||
|
self.loader = Loader(BOT_FILE)
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
self.loader.load_bots()
|
||||||
|
for bot in self.loader.bots:
|
||||||
|
bot_factory = IRCBotFactory(bot)
|
||||||
|
reactor.connectTCP(bot.server, bot.port, bot_factory)
|
||||||
|
reactor.run()
|
||||||
|
|
||||||
|
def run():
|
||||||
|
logger.info('Klafirc is running !')
|
||||||
|
runner = Runner()
|
||||||
|
runner.run()
|
24
klafirc/settings.py
Normal file
24
klafirc/settings.py
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
import logging
|
||||||
|
from logging.handlers import RotatingFileHandler
|
||||||
|
|
||||||
|
DEBUG = True
|
||||||
|
BOT_FILE = '/home/klafyvel/dev/klafirc/bots.yaml'
|
||||||
|
LOG_FILE = '/var/log/klafirc/klafirc.log'
|
||||||
|
|
||||||
|
logger = logging.getLogger()
|
||||||
|
|
||||||
|
if DEBUG:
|
||||||
|
logger.setLevel(logging.DEBUG)
|
||||||
|
else:
|
||||||
|
logger.setLevel(logging.INFO)
|
||||||
|
|
||||||
|
formatter = logging.Formatter('%(asctime)s :: %(levelname)s :: %(message)s')
|
||||||
|
file_handler = RotatingFileHandler(LOG_FILE, 'a', 1000000, 1)
|
||||||
|
file_handler.setLevel(logging.DEBUG)
|
||||||
|
file_handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(file_handler)
|
||||||
|
|
||||||
|
stream_handler = logging.StreamHandler()
|
||||||
|
stream_handler.setLevel(logging.DEBUG)
|
||||||
|
stream_handler.setFormatter(formatter)
|
||||||
|
logger.addHandler(stream_handler)
|
11
requirements.txt
Normal file
11
requirements.txt
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
attrs==18.1.0
|
||||||
|
Automat==0.7.0
|
||||||
|
constantly==15.1.0
|
||||||
|
hyperlink==18.0.0
|
||||||
|
idna==2.7
|
||||||
|
incremental==17.5.0
|
||||||
|
PyHamcrest==1.9.0
|
||||||
|
PyYAML==3.13
|
||||||
|
six==1.11.0
|
||||||
|
Twisted==18.7.0
|
||||||
|
zope.interface==4.5.0
|
Loading…
Reference in a new issue