From 5d145aebaf1fd87311141eafa82b5a4cbc6e23b5 Mon Sep 17 00:00:00 2001 From: Hugo Levy-Falk Date: Tue, 11 Feb 2020 17:07:24 +0000 Subject: [PATCH] Initial commit --- .gitignore | 1 + Dockerfile | 10 + Pipfile | 15 + Pipfile.lock | 305 ++++++++++++++++++ README.md | 3 + bots.yaml | 245 ++++++++++++++ etc/klafytg/bots.d/macron.toml | 19 ++ etc/klafytg/bots.d/patou.toml | 48 +++ etc/klafytg/bots.d/sel.toml | 48 +++ install.sh | 8 + klafirc.log | 202 ++++++++++++ klafirc.service | 14 + klafytg/__init__.py | 7 + klafytg/__main__.py | 3 + klafytg/bot.py | 133 ++++++++ klafytg/bots/__init__.py | 1 + .../bots/__pycache__/__init__.cpython-36.pyc | Bin 0 -> 171 bytes .../__pycache__/chuck_norris.cpython-36.pyc | Bin 0 -> 571 bytes klafytg/bots/chuck_norris.py | 14 + klafytg/irc.py | 61 ++++ klafytg/klafirc.log | 289 +++++++++++++++++ klafytg/runner.py | 12 + klafytg/settings.py | 29 ++ setup.py | 19 ++ 24 files changed, 1486 insertions(+) create mode 100644 .gitignore create mode 100644 Dockerfile create mode 100644 Pipfile create mode 100644 Pipfile.lock create mode 100644 README.md create mode 100644 bots.yaml create mode 100644 etc/klafytg/bots.d/macron.toml create mode 100644 etc/klafytg/bots.d/patou.toml create mode 100644 etc/klafytg/bots.d/sel.toml create mode 100644 install.sh create mode 100644 klafirc.log create mode 100644 klafirc.service create mode 100644 klafytg/__init__.py create mode 100644 klafytg/__main__.py create mode 100644 klafytg/bot.py create mode 100644 klafytg/bots/__init__.py create mode 100644 klafytg/bots/__pycache__/__init__.cpython-36.pyc create mode 100644 klafytg/bots/__pycache__/chuck_norris.cpython-36.pyc create mode 100644 klafytg/bots/chuck_norris.py create mode 100644 klafytg/irc.py create mode 100644 klafytg/klafirc.log create mode 100644 klafytg/runner.py create mode 100644 klafytg/settings.py create mode 100644 setup.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c49bd7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.env diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7733378 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,10 @@ +FROM python:3 +ENV PYTHONUNBUFFERED 1 +RUN mkdir /var/log/klafirc +RUN mkdir /etc/klafirc +RUN mkdir /klafirc +ADD . /klafirc +RUN cp /klafirc/bots.yaml /etc/klafirc +WORKDIR /klafirc +RUN pip install -r requirements.txt +CMD sleep 5; python -m klafirc diff --git a/Pipfile b/Pipfile new file mode 100644 index 0000000..828b593 --- /dev/null +++ b/Pipfile @@ -0,0 +1,15 @@ +[[source]] +name = "pypi" +url = "https://pypi.org/simple" +verify_ssl = true + +[dev-packages] + +[packages] +python-telegram-bot = "*" +toml = "*" +ipython = "*" +bpython = "*" + +[requires] +python_version = "3.6" diff --git a/Pipfile.lock b/Pipfile.lock new file mode 100644 index 0000000..bf13022 --- /dev/null +++ b/Pipfile.lock @@ -0,0 +1,305 @@ +{ + "_meta": { + "hash": { + "sha256": "0cefd20d811ec52fdd5347a47a7ac75dba2afb82d1982af83b983ab33611d7f2" + }, + "pipfile-spec": 6, + "requires": { + "python_version": "3.6" + }, + "sources": [ + { + "name": "pypi", + "url": "https://pypi.org/simple", + "verify_ssl": true + } + ] + }, + "default": { + "backcall": { + "hashes": [ + "sha256:38ecd85be2c1e78f77fd91700c76e14667dc21e2713b63876c0eb901196e01e4", + "sha256:bbbf4b1e5cd2bdb08f915895b51081c041bac22394fdfcfdfbe9f14b77c08bf2" + ], + "version": "==0.1.0" + }, + "blessings": { + "hashes": [ + "sha256:98e5854d805f50a5b58ac2333411b0482516a8210f23f43308baeb58d77c157d", + "sha256:b1fdd7e7a675295630f9ae71527a8ebc10bfefa236b3d6aa4932ee4462c17ba3", + "sha256:caad5211e7ba5afe04367cdd4cfc68fa886e2e08f6f35e76b7387d2109ccea6e" + ], + "version": "==1.7" + }, + "bpython": { + "hashes": [ + "sha256:56cc20dbe568c98c81de4990fddf5862c0d8d3ab0ad1cf7057988abc5f7686c2", + "sha256:c7c6de7309311fd607d6cb47ef7e2d6e065d0a299199d51220d57732850a3efa" + ], + "index": "pypi", + "version": "==0.18" + }, + "certifi": { + "hashes": [ + "sha256:017c25db2a153ce562900032d5bc68e9f191e44e9a0f762f373977de9df1fbb3", + "sha256:25b64c7da4cd7479594d035c08c2d809eb4aab3a26e5a990ea98cc450c320f1f" + ], + "version": "==2019.11.28" + }, + "cffi": { + "hashes": [ + "sha256:001bf3242a1bb04d985d63e138230802c6c8d4db3668fb545fb5005ddf5bb5ff", + "sha256:00789914be39dffba161cfc5be31b55775de5ba2235fe49aa28c148236c4e06b", + "sha256:028a579fc9aed3af38f4892bdcc7390508adabc30c6af4a6e4f611b0c680e6ac", + "sha256:14491a910663bf9f13ddf2bc8f60562d6bc5315c1f09c704937ef17293fb85b0", + "sha256:1cae98a7054b5c9391eb3249b86e0e99ab1e02bb0cc0575da191aedadbdf4384", + "sha256:2089ed025da3919d2e75a4d963d008330c96751127dd6f73c8dc0c65041b4c26", + "sha256:2d384f4a127a15ba701207f7639d94106693b6cd64173d6c8988e2c25f3ac2b6", + "sha256:337d448e5a725bba2d8293c48d9353fc68d0e9e4088d62a9571def317797522b", + "sha256:399aed636c7d3749bbed55bc907c3288cb43c65c4389964ad5ff849b6370603e", + "sha256:3b911c2dbd4f423b4c4fcca138cadde747abdb20d196c4a48708b8a2d32b16dd", + "sha256:3d311bcc4a41408cf5854f06ef2c5cab88f9fded37a3b95936c9879c1640d4c2", + "sha256:62ae9af2d069ea2698bf536dcfe1e4eed9090211dbaafeeedf5cb6c41b352f66", + "sha256:66e41db66b47d0d8672d8ed2708ba91b2f2524ece3dee48b5dfb36be8c2f21dc", + "sha256:675686925a9fb403edba0114db74e741d8181683dcf216be697d208857e04ca8", + "sha256:7e63cbcf2429a8dbfe48dcc2322d5f2220b77b2e17b7ba023d6166d84655da55", + "sha256:8a6c688fefb4e1cd56feb6c511984a6c4f7ec7d2a1ff31a10254f3c817054ae4", + "sha256:8c0ffc886aea5df6a1762d0019e9cb05f825d0eec1f520c51be9d198701daee5", + "sha256:95cd16d3dee553f882540c1ffe331d085c9e629499ceadfbda4d4fde635f4b7d", + "sha256:99f748a7e71ff382613b4e1acc0ac83bf7ad167fb3802e35e90d9763daba4d78", + "sha256:b8c78301cefcf5fd914aad35d3c04c2b21ce8629b5e4f4e45ae6812e461910fa", + "sha256:c420917b188a5582a56d8b93bdd8e0f6eca08c84ff623a4c16e809152cd35793", + "sha256:c43866529f2f06fe0edc6246eb4faa34f03fe88b64a0a9a942561c8e22f4b71f", + "sha256:cab50b8c2250b46fe738c77dbd25ce017d5e6fb35d3407606e7a4180656a5a6a", + "sha256:cef128cb4d5e0b3493f058f10ce32365972c554572ff821e175dbc6f8ff6924f", + "sha256:cf16e3cf6c0a5fdd9bc10c21687e19d29ad1fe863372b5543deaec1039581a30", + "sha256:e56c744aa6ff427a607763346e4170629caf7e48ead6921745986db3692f987f", + "sha256:e577934fc5f8779c554639376beeaa5657d54349096ef24abe8c74c5d9c117c3", + "sha256:f2b0fa0c01d8a0c7483afd9f31d7ecf2d71760ca24499c8697aeb5ca37dc090c" + ], + "version": "==1.14.0" + }, + "chardet": { + "hashes": [ + "sha256:84ab92ed1c4d4f16916e05906b6b75a6c0fb5db821cc65e70cbd64a3e2a5eaae", + "sha256:fc323ffcaeaed0e0a02bf4d117757b98aed530d9ed4531e3e15460124c106691" + ], + "version": "==3.0.4" + }, + "cryptography": { + "hashes": [ + "sha256:02079a6addc7b5140ba0825f542c0869ff4df9a69c360e339ecead5baefa843c", + "sha256:1df22371fbf2004c6f64e927668734070a8953362cd8370ddd336774d6743595", + "sha256:369d2346db5934345787451504853ad9d342d7f721ae82d098083e1f49a582ad", + "sha256:3cda1f0ed8747339bbdf71b9f38ca74c7b592f24f65cdb3ab3765e4b02871651", + "sha256:44ff04138935882fef7c686878e1c8fd80a723161ad6a98da31e14b7553170c2", + "sha256:4b1030728872c59687badcca1e225a9103440e467c17d6d1730ab3d2d64bfeff", + "sha256:58363dbd966afb4f89b3b11dfb8ff200058fbc3b947507675c19ceb46104b48d", + "sha256:6ec280fb24d27e3d97aa731e16207d58bd8ae94ef6eab97249a2afe4ba643d42", + "sha256:7270a6c29199adc1297776937a05b59720e8a782531f1f122f2eb8467f9aab4d", + "sha256:73fd30c57fa2d0a1d7a49c561c40c2f79c7d6c374cc7750e9ac7c99176f6428e", + "sha256:7f09806ed4fbea8f51585231ba742b58cbcfbfe823ea197d8c89a5e433c7e912", + "sha256:90df0cc93e1f8d2fba8365fb59a858f51a11a394d64dbf3ef844f783844cc793", + "sha256:971221ed40f058f5662a604bd1ae6e4521d84e6cad0b7b170564cc34169c8f13", + "sha256:a518c153a2b5ed6b8cc03f7ae79d5ffad7315ad4569b2d5333a13c38d64bd8d7", + "sha256:b0de590a8b0979649ebeef8bb9f54394d3a41f66c5584fff4220901739b6b2f0", + "sha256:b43f53f29816ba1db8525f006fa6f49292e9b029554b3eb56a189a70f2a40879", + "sha256:d31402aad60ed889c7e57934a03477b572a03af7794fa8fb1780f21ea8f6551f", + "sha256:de96157ec73458a7f14e3d26f17f8128c959084931e8997b9e655a39c8fde9f9", + "sha256:df6b4dca2e11865e6cfbfb708e800efb18370f5a46fd601d3755bc7f85b3a8a2", + "sha256:ecadccc7ba52193963c0475ac9f6fa28ac01e01349a2ca48509667ef41ffd2cf", + "sha256:fb81c17e0ebe3358486cd8cc3ad78adbae58af12fc2bf2bc0bb84e8090fa5ce8" + ], + "version": "==2.8" + }, + "curtsies": { + "hashes": [ + "sha256:9169d734323a1356e7563b1ca0bff3c5358c1b1dcce52506a9d4d8ab8a8f5604", + "sha256:b2c913a8113c4382e1a221679f2338139b112839deb16c00ee873e57a4b33bd4" + ], + "version": "==0.3.1" + }, + "decorator": { + "hashes": [ + "sha256:54c38050039232e1db4ad7375cfce6748d7b41c29e95a081c8a6d2c30364a2ce", + "sha256:5d19b92a3c8f7f101c8dd86afd86b0f061a8ce4540ab8cd401fa2542756bce6d" + ], + "version": "==4.4.1" + }, + "future": { + "hashes": [ + "sha256:b1bead90b70cf6ec3f0710ae53a525360fa360d306a86583adc6bf83a4db537d" + ], + "version": "==0.18.2" + }, + "greenlet": { + "hashes": [ + "sha256:000546ad01e6389e98626c1367be58efa613fa82a1be98b0c6fc24b563acc6d0", + "sha256:0d48200bc50cbf498716712129eef819b1729339e34c3ae71656964dac907c28", + "sha256:23d12eacffa9d0f290c0fe0c4e81ba6d5f3a5b7ac3c30a5eaf0126bf4deda5c8", + "sha256:37c9ba82bd82eb6a23c2e5acc03055c0e45697253b2393c9a50cef76a3985304", + "sha256:51155342eb4d6058a0ffcd98a798fe6ba21195517da97e15fca3db12ab201e6e", + "sha256:51503524dd6f152ab4ad1fbd168fc6c30b5795e8c70be4410a64940b3abb55c0", + "sha256:7457d685158522df483196b16ec648b28f8e847861adb01a55d41134e7734122", + "sha256:8041e2de00e745c0e05a502d6e6db310db7faa7c979b3a5877123548a4c0b214", + "sha256:81fcd96a275209ef117e9ec91f75c731fa18dcfd9ffaa1c0adbdaa3616a86043", + "sha256:853da4f9563d982e4121fed8c92eea1a4594a2299037b3034c3c898cb8e933d6", + "sha256:8b4572c334593d449113f9dc8d19b93b7b271bdbe90ba7509eb178923327b625", + "sha256:9416443e219356e3c31f1f918a91badf2e37acf297e2fa13d24d1cc2380f8fbc", + "sha256:9854f612e1b59ec66804931df5add3b2d5ef0067748ea29dc60f0efdcda9a638", + "sha256:99a26afdb82ea83a265137a398f570402aa1f2b5dfb4ac3300c026931817b163", + "sha256:a19bf883b3384957e4a4a13e6bd1ae3d85ae87f4beb5957e35b0be287f12f4e4", + "sha256:a9f145660588187ff835c55a7d2ddf6abfc570c2651c276d3d4be8a2766db490", + "sha256:ac57fcdcfb0b73bb3203b58a14501abb7e5ff9ea5e2edfa06bb03035f0cff248", + "sha256:bcb530089ff24f6458a81ac3fa699e8c00194208a724b644ecc68422e1111939", + "sha256:beeabe25c3b704f7d56b573f7d2ff88fc99f0138e43480cecdfcaa3b87fe4f87", + "sha256:d634a7ea1fc3380ff96f9e44d8d22f38418c1c381d5fac680b272d7d90883720", + "sha256:d97b0661e1aead761f0ded3b769044bb00ed5d33e1ec865e891a8b128bf7c656", + "sha256:e538b8dae561080b542b0f5af64d47ef859f22517f7eca617bb314e0e03fd7ef" + ], + "version": "==0.4.15" + }, + "idna": { + "hashes": [ + "sha256:c357b3f628cf53ae2c4c05627ecc484553142ca23264e593d327bcde5e9c3407", + "sha256:ea8b7f6188e6fa117537c3df7da9fc686d485087abf6ac197f9c46432f7e4a3c" + ], + "version": "==2.8" + }, + "ipython": { + "hashes": [ + "sha256:d9459e7237e2e5858738ff9c3e26504b79899b58a6d49e574d352493d80684c6", + "sha256:f6689108b1734501d3b59c84427259fd5ac5141afe2e846cfa8598eb811886c9" + ], + "index": "pypi", + "version": "==7.12.0" + }, + "ipython-genutils": { + "hashes": [ + "sha256:72dd37233799e619666c9f639a9da83c34013a73e8bbc79a7a6348d93c61fab8", + "sha256:eb2e116e75ecef9d4d228fdc66af54269afa26ab4463042e33785b887c628ba8" + ], + "version": "==0.2.0" + }, + "jedi": { + "hashes": [ + "sha256:b4f4052551025c6b0b0b193b29a6ff7bdb74c52450631206c262aef9f7159ad2", + "sha256:d5c871cb9360b414f981e7072c52c33258d598305280fef91c6cae34739d65d5" + ], + "version": "==0.16.0" + }, + "parso": { + "hashes": [ + "sha256:56b2105a80e9c4df49de85e125feb6be69f49920e121406f15e7acde6c9dfc57", + "sha256:951af01f61e6dccd04159042a0706a31ad437864ec6e25d0d7a96a9fbb9b0095" + ], + "version": "==0.6.1" + }, + "pexpect": { + "hashes": [ + "sha256:0b48a55dcb3c05f3329815901ea4fc1537514d6ba867a152b581d69ae3710937", + "sha256:fc65a43959d153d0114afe13997d439c22823a27cefceb5ff35c2178c6784c0c" + ], + "markers": "sys_platform != 'win32'", + "version": "==4.8.0" + }, + "pickleshare": { + "hashes": [ + "sha256:87683d47965c1da65cdacaf31c8441d12b8044cdec9aca500cd78fc2c683afca", + "sha256:9649af414d74d4df115d5d718f82acb59c9d418196b7b4290ed47a12ce62df56" + ], + "version": "==0.7.5" + }, + "prompt-toolkit": { + "hashes": [ + "sha256:a402e9bf468b63314e37460b68ba68243d55b2f8c4d0192f85a019af3945050e", + "sha256:c93e53af97f630f12f5f62a3274e79527936ed466f038953dfa379d4941f651a" + ], + "version": "==3.0.3" + }, + "ptyprocess": { + "hashes": [ + "sha256:923f299cc5ad920c68f2bc0bc98b75b9f838b93b599941a6b63ddbc2476394c0", + "sha256:d7cc528d76e76342423ca640335bd3633420dc1366f258cb31d05e865ef5ca1f" + ], + "version": "==0.6.0" + }, + "pycparser": { + "hashes": [ + "sha256:a988718abfad80b6b157acce7bf130a30876d27603738ac39f140993246b25b3" + ], + "version": "==2.19" + }, + "pygments": { + "hashes": [ + "sha256:2a3fe295e54a20164a9df49c75fa58526d3be48e14aceba6d6b1e8ac0bfd6f1b", + "sha256:98c8aa5a9f778fcd1026a17361ddaf7330d1b7c62ae97c3bb0ae73e0b9b6b0fe" + ], + "version": "==2.5.2" + }, + "python-telegram-bot": { + "hashes": [ + "sha256:0a97cbca638f949582b4ee326170d2f8d7f4bf559a4e511132bb2203623e04ad", + "sha256:d3cffd020af4094d07c11783f875e5c682072ba7f5bc21ce89ff0222f4e6d742" + ], + "index": "pypi", + "version": "==12.4.2" + }, + "requests": { + "hashes": [ + "sha256:11e007a8a2aa0323f5a921e9e6a2d7e4e67d9877e85773fba9ba6419025cbeb4", + "sha256:9cf5292fcd0f598c671cfc1e0d7d1a7f13bb8085e9a590f48c010551dc6c4b31" + ], + "version": "==2.22.0" + }, + "six": { + "hashes": [ + "sha256:236bdbdce46e6e6a3d61a337c0f8b763ca1e8717c03b369e87a7ec7ce1319c0a", + "sha256:8f3cd2e254d8f793e7f3d6d9df77b92252b52637291d0f0da013c76ea2724b6c" + ], + "version": "==1.14.0" + }, + "toml": { + "hashes": [ + "sha256:229f81c57791a41d65e399fc06bf0848bab550a9dfd5ed66df18ce5f05e73d5c", + "sha256:235682dd292d5899d361a811df37e04a8828a5b1da3115886b73cf81ebc9100e" + ], + "index": "pypi", + "version": "==0.10.0" + }, + "tornado": { + "hashes": [ + "sha256:349884248c36801afa19e342a77cc4458caca694b0eda633f5878e458a44cb2c", + "sha256:398e0d35e086ba38a0427c3b37f4337327231942e731edaa6e9fd1865bbd6f60", + "sha256:4e73ef678b1a859f0cb29e1d895526a20ea64b5ffd510a2307b5998c7df24281", + "sha256:559bce3d31484b665259f50cd94c5c28b961b09315ccd838f284687245f416e5", + "sha256:abbe53a39734ef4aba061fca54e30c6b4639d3e1f59653f0da37a0003de148c7", + "sha256:c845db36ba616912074c5b1ee897f8e0124df269468f25e4fe21fe72f6edd7a9", + "sha256:c9399267c926a4e7c418baa5cbe91c7d1cf362d505a1ef898fde44a07c9dd8a5" + ], + "version": "==6.0.3" + }, + "traitlets": { + "hashes": [ + "sha256:70b4c6a1d9019d7b4f6846832288f86998aa3b9207c6821f3578a6a6a467fe44", + "sha256:d023ee369ddd2763310e4c3eae1ff649689440d4ae59d7485eb4cfbbe3e359f7" + ], + "version": "==4.3.3" + }, + "urllib3": { + "hashes": [ + "sha256:2f3db8b19923a873b3e5256dc9c2dedfa883e33d87c690d9c7913e1f40673cdc", + "sha256:87716c2d2a7121198ebcb7ce7cccf6ce5e9ba539041cfbaeecfb641dc0bf6acc" + ], + "version": "==1.25.8" + }, + "wcwidth": { + "hashes": [ + "sha256:8fd29383f539be45b20bd4df0dc29c20ba48654a41e661925e612311e9f3c603", + "sha256:f28b3e8a6483e5d49e7f8949ac1a78314e740333ae305b4ba5defd3e74fb37a8" + ], + "version": "==0.1.8" + } + }, + "develop": {} +} diff --git a/README.md b/README.md new file mode 100644 index 0000000..e5e06ab --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# Klafirc + +Klafirc is a simple irc bot which react to matches and pings. diff --git a/bots.yaml b/bots.yaml new file mode 100644 index 0000000..2fdd8b5 --- /dev/null +++ b/bots.yaml @@ -0,0 +1,245 @@ +bots: + sel: + on_ping: + - "Arcas:`à viarezo ils font des caleçons.` Chibrac:`bah non au rezo, à viarezo ils ont pas de boules à couvrir`" + - "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" + - " Il faut vraiment être con pour acheter une imprimante Brother." + - " 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 ?" + - " je glande presque autant qu'un pelec" + - " choisi l'excuse du moment chez ton supelec : l'inté, la campagne, les partiels, les vacances" + - " ouais mais j'ai jamais vu de gens aussi efficaces que les pelec pour justifier pq ils peuvent pas faire un truc" + - " Chirac on connaît tous tes performances scolaires t'inquiète pas" + - "Un jour j'irais me frotter à #federez, pour voir du gros sel." + - " un prof de maths est généralement compétent en maths, alors que j’attends toujours de rencontrer un prof d’info qui est capable de mettre quelque chose en prod" + - " D'après le fameux théorème centralien je pense que j'ai droit donc j'ai le droit" + - " dtf vous arriverez pas au niveau de via qui découvre tous les ans des thunes placées sur des comptes random" + - " il faudrait faire un achivement : a réussi a désinstaller le virtualiseur du virtualiseur" + - " De toute facon il y a ceux qui ont réussi à conserver leur Coopé™ et ceux qui doivent s'exiler pour en retrouver une" + - " je rajoute du gros sel façon ViaRézo \n fais gaffe bientôt le steak va coder en node" + - " Je préfère parler de limitation de débit afin de prioriser les services critiques." + - " Le jour où @lebanni est engagé dans une entreprise,j'y enlève toutes mes actions." + - " Toute façon, les prezs rezo c'est souvent des pots de fleurs avec une clé root." + - "<@lebanni> Je suis un gros quetard" + - "La soeur du banni : Matthieu, tu peux m'aider sur mon exo de maths ? @lebanni : Flemme, mon temps vaut de l'argent" + - " Un JT c'est pas comme des nocturnes FedeRez, ça s'organise pas tout seul." + on_match: + 'détruire le monde' : "Manu on fait des collages ?" + 'imprimante' : "Je pense qu'on devrait reprendre la même imprimante Brother." + '{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 manque de reconnaissance se mettent à la page. Je pense qu'on devrait ajouter un bridge matrix \U0001f914" + 'telegram' : "{user} : tu devrais passer à irc." + 'irc.*matrix' : "{user} : tu devrais passer à matrix." + 'matrix.*irc' : "> {message}\nLes vrais font tourner matrix dans un tmux." + 'proxmox' : "proxmox c'est surfait, faut l'autoremove" + on_join: 'Unleash the salt' + Macron: + on_ping: + - "PARCE QUE C'EST NOTRE PROJEEEET !" + - "C'est de la poudre de perlimpinpin." + on_match: + 'tocard' : "Est-ce que je peux dire autocar ?" + 'Manu.*\?' : "Tu m’appelles monsieur le président de la République, ou monsieur." + 'aides sociales' : "Ça coûte un pognon dingue !" + min_time: 30 # in seconds + 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" + - "Renaud c'est un visionnaire, mais un visionnaire aveugle" + - "J'ai pas besoin de cirer des pompes ou sucer des bites. Ah je suis avec des élèves je te laisse" + - "Annie elle aurait bien aimé être à fond DANS John Cagnol" + - "Quand tu veux rouler vite et efficace, allongé c'est confortable" + - "J'aime bien Sexion d'assaut" + - "Si vous voulez pisser depuis le toit attendez que le directeur passe en-dessous" + - "Pour être handicapé mental, faut déjà avoir un cerveau" + - "Le prêtre a dit qu'il ne pouvait décemment pas prendre Gutzwiller : il est trop près de son Macintosh" + - "Il est très bon, mais il est très con" + - "On bute tout le monde et on recommence" + - "Je suis toujours un peu en avance de phase" + - "Stop. Tue toi." + - "La mort par convention mutuelle si je puis dire" + - "Lâche moi la souris" + - "On a une commande qui est 'casse-toi tu pue' et un autre qui dit 'casse-toi tu pompes les ressources'" + on_match: + "password" : "Ah facile pour avoir accès aux switches, id: root, mdp: switch" + "nvidia" : "Les cartes nvidia c'est de la merde" + Claudy: + on_ping: + - "Ou tu sors, ou j'te sors, hein, mais faudra prendre une décision." + - "Tu sais {user}, si j'suis toujours si bien accompagné, c'est pour mon argent hein, c'est pas pour mon odeur... Et ça ça fait mal" + - "Ou tu sors, ou j'te sors, hein, mais faudra prendre une décision." + - "Et à propos de vieille truie toi comment ça va ?" + - "Dis, on t'a jamais appris à manger la bouche fermée toi ? J'ai l'impression d'être à côté d'un camion poubelle qui travaille moi ici !" + - "Faut pas commencer à jouer avec mes couilles" + - "Minutes papillon, je termine" + - "Bouge pas, j'vais aller chercher l'poney." + - "C'est toi qui va décharger l'cochon ? T'es épais comme un câble de frein à main" + - "Je n'en peux plus, je suis au bout du rouleau. J'ai envie de rentrer, me foutre dans mes savates et terminé bonsoir" + - "Voilà ben j'me présente en deux mots. Je suis Claudy Focan, Monsieur Focan plus exactement, je suis directeur NCS Marketing Manager des abattoirs d'Anderlecht." + - "Ah, maman ? Claudy à l'appareil dis, je viens de m'faire carjacker ! Je dis, je viens de me faire carjacker ! On a volé l'auto ! Non j'ai rien su faire ! J'ai taché de courir derrière qu'est-ce que tu veux faire ?" + - "Écoute ma fille, si ça t’intéresse, t’as mon numéro qu’est là, si ça t’intéresse pas au revoir Monsieur bon weekend... qu’est ce que tu veux que j‘te dise moi ?" + - "En tout cas y t’ont pas loupée, j’sais pas si c’est un ch’val ou une truie là, t’as vu ta tronche ou quoi ? Peut aussi faire un bouquin sur Halloween s’tu veux hein !" + Chuck: + on_ping: + - "No, thanks." + on_ping_python: + - 'klafirc.bots.chuck_norris.on_ping' + Laouen: + on_match: + '[Cc]oop[eé]\s(?!(TM))' : 'On dit CoopéTM !' + on_join: 'La CoopéTM est ouverte' + min_time: 3 # in seconds + Grubigrub: + on_match: + '[Mm]icrosoft' : 'Corruption institutionnalisée !' + min_time: 3 # in seconds + Karadoc: + on_ping: + - "Le gras, c'est la vie" + - "Bien manger c'est important !" + - "L'agneau était daubé du cul !" + - "Eh oui mémé, t'es bien mouchée !" + - "Sans blague, y'a pas de la gourdasse ?" + - "Par exemple, vous prenez aujourd’hui. Vous comptez sept jours. Ça vous emmène dans une semaine. Et bien on sera exactement le même jour qu’aujourd’hui… À une vache près, hein… C’est pas une science exacte." + - "Les chicots, c'est sacré ! Parce que si j'les lave pas maintenant, dans dix ans, c'est tout à la soupe. Et l'mec qui me fera manger de la soupe il est pas né !" + - "Si ça peut m'éviter de chlinguer du cul, je peux bien me tremper une ou deux fois par an." + - "Ça y est… je vois trouble. C’est le manque de gras, je me dessèche." + - "On la politique de l'autruche, avant je comprenais pas. Mais maintenant que j'en ai vu une d'autruche, c'est bon ! Une politique qui court vite ! Une politique qui fait des gros oeufs, c'est tout !" + on_match: + '[Jj]uniper' : "C'est d'la merde" + '[Cc]routons?' : "Des p'tits croutons tout vieux genre pour les lapins ? Ouais j'savais pas c'que c'était, dans le doute j'les ai bouffés." + '[Ss]i[èe]ge' : "MAIS Y'EN A PAS DE SIÈGE PAUVRE CONNE !" + '[Ff]romages?' : "Oh le con ! Mais il est pas fini d'affiner !" + min_time: 3 # in seconds + Perceval: + on_ping: + - "C'est pas faux" + on_match: + "Le gras, c'est la vie" : "C'est pas faux" + "PROJEEEET" : "Toi, un jour, je te crâme ta famille, toi." + min_time: 3 # in seconds + OpenSuze: + on_ping: + - "Tu reprends de la soupe ?" + on_join: 'Bonjour les enfants !' + on_match: + "(Y|y|([Ii]l (n')?y)) en a plus" : "Y en a plus ? J'ai tout bu ?" + "[Ss]oupe" : "J'ai préparé une soupe avec une petite courge de 5kg." + min_time: 3 # in seconds + Souby: + on_match: + "[Cc]oop[eé]" : "{user} : mot interdit sur notre campus sans alcool !" + min_time: 3 # in seconds + Gutzwiller: + on_ping: + - "Les ordinateurs, c'est comme les galères romaines : moins il y a de RAM, et plus ça rame !" + - "Il pédale dans la choucroute !" + - "On a quand même de la chance, on vit beaucoup plus longtemps que nos ordinateurs." + - "Intel c’est pas le contraire de \"tel autre\" hein, c’est la marque." + - "Et depuis, je n'ai plus jamais utilisé de Macs." + - "\"Plug and Play\" pour moi c’est plutôt \"je plug et j’me plains.\"" + - "Soit ils on changé la route, soit il y a un bogue." + - "Vous avez besoin de ce cours… \"ce cours\" en en deux mots hein ! Pas \"secours\"!" + - "Machine de Mealy. [Prononcé \"Machine de Millet.\"]" + - "La myopie forte." + - "Au bout de trois vies, c’est *Game Over* ! [L’examen, le rattrapage et la commission.]" + - "J’ai tout validé à 18. Sauf l’électromagnétisme, j’ai validé à 4." + - "C’est parce que moi je vois les champs magnétiques, mais du coup je ne savais pas faire les démonstrations." + - "Je me suis pointé en retard parce que je réveillais mon copiaule." + - "Il y a plein de *Klein* autour de chez mes parents." + - "Ils sont sérieux les Alsaciens !" + - "C’est un bon conducteur, mais il consomme plus que son véhicule." + - "Et si jamais on pouvait mettre autre chose que des roues ?" + - "C’était une flaque de flotte, la Suisse : aquaplaning sur 300 bornes !" + - "Aujourd’hui, on fera des crêpes !" + - "Tiens, ça pourrait être mon repas de midi ça !" + - "Je mets de la farine, du lait puis des œufs… Ben je prépare des crêpes !" + - "On souhaite fabriquer un modem… pas le parti politique, hein !" + - "Schlumberger, ils font de la discrimination à l’envers : ils aiment beaucoup les étrangers et les femmes." + - "Pensez autrement." + - "Mon accent anglais, c’est comme le français, c’est approximatif." + - "Comme le disait un de mes profs : \"Et surtout… Essayez de me suivre !\"" + - "Des fois… c’est dur la vie d’artiste." + - "J’aime pas les pommes, je préfère les poires." + - "Ce jour-là, j’étais en pétard. Contre le foot. [Enterrement pendant la victoire de la France à la coupe du monde de 1998.]" + - "Et donc, j’ai toujours un stylo sur moi." + - "Vous connaissez la règle des trois \"pourquoi\" ? Pour avoir la vérité sur quelque chose, on pose la question, puis on demande trois fois \"pourquoi ?\"" + - "Vous risquez le décollement de la rétine." + - "N’essayez pas de faire voir la télé couleur à une vache !" + - "Les bras m’en tombent." + - "Vous savez comment on dit \"Il fait froid\" en japonais ? SAKAI !" + - "L’opérateur rouge c’est celui qui sait faire [SFR]. Mais aujourd’hui, il sait pas faire." + - "Les appareils photos numériques changent beaucoup plus vite que les humains. La preuve, j'suis là mon premier appareil photo numérique il est plus là." + - "Moi je suis vraiment sans mémoire." + - "Les vendeurs d'oscillos ont peur de moi." + - "Un filtre de Jean-Louis Gutzwiller, histoire de laisser mon nom à la postérité." + - "Ma maman, elle n'est pas de ce monde-là." + - "Et paf ! 3dB dans les dents !" + min_time: 3 # in seconds + Sciamanna: + on_ping: + - "Ça me désole quand munme." + - "Le monde va mal, vous savez. Faites HEC." + - "C'est pipoland m'voyez." + - "À Supélec, je ne sais pas comment ils fonctionnent." + - "C'est pas un Belge qui va révolutionner les grandes écoles, chacun sa merde." + - "Eh je suis pas un tueur. Enfin dans la vraie vie, si. D'ailleurs il y a eu un meurtre non élucidé près de chez moi, mais c'est pas moi." + - "C'est comme votre latence matinale, moi j'arrive avec mon sin(t) et je vous secoue harmoniquement." + - "Je vais essayer de vous aider, il va y avoir une sélection naturelle." + - "Si quelqu'un fait une thèse, il a 3 points de plus à l'exam'." + - "Si on me demande plus que le passé, je dis que le passé du passé c'est le passé." + - "C'est mal foutu parce que ce n'est pas moi qui l'ai fait mais des gens de Paris." + - "Marcher c'est compliqué." + - "Vous savez, j'ai mis un temps fou à comprendre qu'on avait cours ici." + on_match: + "[Pp]hotonique" : "C'est la science du XXIIe siècle." + min_time: 3 # in seconds + Houzelle: + on_ping: + - "C'est très simple." + - "C'est facile." + - "Effectivement." + - "Alors." + - "Donc." + - "Voilà." + - "Ok ?" + - "Hein." + - "D'accord ?" + - "Euh..." + - "Bon." + - "Bref." + - "D'accord ? Ok ? Voilà. Alors..." + min_time: 1 # in seconds + + rip_lorrabelle: + on_ping: + - "Not under my watch." + on_match: + "[Ll]orrabelle" : "@klafyvel: tocard" + +channels: + - server: irc.rezometz.org + port: 6667 + channel: "#bots" + bots: [sel, Macron, Patou, Claudy, Chuck, Laouen, Grubigrub, Karadoc, Perceval, OpenSuze, Gutzwiller, Sciamanna, Houzelle] + - server: irc.rezosup.org + port: 6667 + channel: "#centrale-supelec" + bots: [Souby, Chuck] + diff --git a/etc/klafytg/bots.d/macron.toml b/etc/klafytg/bots.d/macron.toml new file mode 100644 index 0000000..1d5c8db --- /dev/null +++ b/etc/klafytg/bots.d/macron.toml @@ -0,0 +1,19 @@ +[bot] +name = "Manu" +# Name of the environment variable to fetch +token = "MANUTOKEN" +# time between interventions in seconds +min_time = 30 +channels = [ + -311159479 +] +[ping] +quotes = [ + "PARCE QUE C'EST NOTRE PROJEEEET !", + "C'est de la poudre de perlimpinpin." +] +[match] +"tocard" = "Est-ce que je peux dire autocar ?" +"Manu.*\?" = "Tu m’appelles monsieur le président de la République, ou monsieur." +"aides sociales" = "Ça coûte un pognon dingue !" +[join] diff --git a/etc/klafytg/bots.d/patou.toml b/etc/klafytg/bots.d/patou.toml new file mode 100644 index 0000000..3d8a805 --- /dev/null +++ b/etc/klafytg/bots.d/patou.toml @@ -0,0 +1,48 @@ +[bot] +name = "sel" +# Name of the environment variable to fetch +token = "SELTOKEN" +# time between interventions in seconds +min_time = 30 +channels = [ + -311159479 +] +[ping] +quotes = [ + "Arcas:`à viarezo ils font des caleçons.` Chibrac:`bah non au rezo, à viarezo ils ont pas de boules à couvrir`", + "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 , é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", + " Il faut vraiment être con pour acheter une imprimante Brother.", + " 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 ?", + " je glande presque autant qu'un pelec", + " choisi l'excuse du moment chez ton supelec : l'inté, la campagne, les partiels, les vacances", + " ouais mais j'ai jamais vu de gens aussi efficaces que les pelec pour justifier pq ils peuvent pas faire un truc", + " Chirac on connaît tous tes performances scolaires t'inquiète pas", + "Un jour j'irais me frotter à #federez, pour voir du gros sel.", + " un prof de maths est généralement compétent en maths, alors que j’attends toujours de rencontrer un prof d’info qui est capable de mettre quelque chose en prod", + " D'après le fameux théorème centralien je pense que j'ai droit donc j'ai le droit", + " dtf vous arriverez pas au niveau de via qui découvre tous les ans des thunes placées sur des comptes random", + " il faudrait faire un achivement : a réussi a désinstaller le virtualiseur du virtualiseur", + " De toute facon il y a ceux qui ont réussi à conserver leur Coopé™ et ceux qui doivent s'exiler pour en retrouver une", + " je rajoute du gros sel façon ViaRézo \n fais gaffe bientôt le steak va coder en node", + " Je préfère parler de limitation de débit afin de prioriser les services critiques.", + " Le jour où @lebanni est engagé dans une entreprise,j'y enlève toutes mes actions.", + " Toute façon, les prezs rezo c'est souvent des pots de fleurs avec une clé root.", + "<@lebanni> Je suis un gros quetard", + "La soeur du banni : Matthieu, tu peux m'aider sur mon exo de maths ? @lebanni : Flemme, mon temps vaut de l'argent", + " Un JT c'est pas comme des nocturnes FedeRez, ça s'organise pas tout seul." +] +[match] +"détruire le monde" = "Manu on fait des collages ?" +"imprimante" = "Je pense qu'on devrait reprendre la même imprimante Brother." +"{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 manque de reconnaissance se mettent à la page. Je pense qu'on devrait ajouter un bridge matrix \U0001f914" +"telegram" = "{user} : tu devrais passer à irc." +"irc.*matrix" = "{user} : tu devrais passer à matrix." +"matrix.*irc" = "> {message}\nLes vrais font tourner matrix dans un tmux." +"proxmox" = "proxmox c'est surfait, faut l'autoremove" +[join] +quotes = ['Unleash the salt'] diff --git a/etc/klafytg/bots.d/sel.toml b/etc/klafytg/bots.d/sel.toml new file mode 100644 index 0000000..3d8a805 --- /dev/null +++ b/etc/klafytg/bots.d/sel.toml @@ -0,0 +1,48 @@ +[bot] +name = "sel" +# Name of the environment variable to fetch +token = "SELTOKEN" +# time between interventions in seconds +min_time = 30 +channels = [ + -311159479 +] +[ping] +quotes = [ + "Arcas:`à viarezo ils font des caleçons.` Chibrac:`bah non au rezo, à viarezo ils ont pas de boules à couvrir`", + "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 , é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", + " Il faut vraiment être con pour acheter une imprimante Brother.", + " 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 ?", + " je glande presque autant qu'un pelec", + " choisi l'excuse du moment chez ton supelec : l'inté, la campagne, les partiels, les vacances", + " ouais mais j'ai jamais vu de gens aussi efficaces que les pelec pour justifier pq ils peuvent pas faire un truc", + " Chirac on connaît tous tes performances scolaires t'inquiète pas", + "Un jour j'irais me frotter à #federez, pour voir du gros sel.", + " un prof de maths est généralement compétent en maths, alors que j’attends toujours de rencontrer un prof d’info qui est capable de mettre quelque chose en prod", + " D'après le fameux théorème centralien je pense que j'ai droit donc j'ai le droit", + " dtf vous arriverez pas au niveau de via qui découvre tous les ans des thunes placées sur des comptes random", + " il faudrait faire un achivement : a réussi a désinstaller le virtualiseur du virtualiseur", + " De toute facon il y a ceux qui ont réussi à conserver leur Coopé™ et ceux qui doivent s'exiler pour en retrouver une", + " je rajoute du gros sel façon ViaRézo \n fais gaffe bientôt le steak va coder en node", + " Je préfère parler de limitation de débit afin de prioriser les services critiques.", + " Le jour où @lebanni est engagé dans une entreprise,j'y enlève toutes mes actions.", + " Toute façon, les prezs rezo c'est souvent des pots de fleurs avec une clé root.", + "<@lebanni> Je suis un gros quetard", + "La soeur du banni : Matthieu, tu peux m'aider sur mon exo de maths ? @lebanni : Flemme, mon temps vaut de l'argent", + " Un JT c'est pas comme des nocturnes FedeRez, ça s'organise pas tout seul." +] +[match] +"détruire le monde" = "Manu on fait des collages ?" +"imprimante" = "Je pense qu'on devrait reprendre la même imprimante Brother." +"{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 manque de reconnaissance se mettent à la page. Je pense qu'on devrait ajouter un bridge matrix \U0001f914" +"telegram" = "{user} : tu devrais passer à irc." +"irc.*matrix" = "{user} : tu devrais passer à matrix." +"matrix.*irc" = "> {message}\nLes vrais font tourner matrix dans un tmux." +"proxmox" = "proxmox c'est surfait, faut l'autoremove" +[join] +quotes = ['Unleash the salt'] diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..4b0345d --- /dev/null +++ b/install.sh @@ -0,0 +1,8 @@ +apt-get install python3-pip +mkdir /var/log/klafirc +mkdir /etc/klafirc +cp -r . /etc/klafirc +cp klafirc.service /etc/systemd/system/ +systemctl enable klafirc.service +python3 setup.py install +systemctl start klafirc.service diff --git a/klafirc.log b/klafirc.log new file mode 100644 index 0000000..05d7004 --- /dev/null +++ b/klafirc.log @@ -0,0 +1,202 @@ +2019-04-21 23:07:31,343 :: INFO :: Klafirc is running ! +2019-04-21 23:07:31,343 :: INFO :: Loading configuration from ./bots.yaml +2019-04-21 23:07:31,576 :: INFO :: Souby is connected +2019-04-21 23:07:31,577 :: INFO :: Chuck is connected +2019-04-21 23:07:32,439 :: INFO :: Souby joined #centrale-supelec +2019-04-21 23:07:32,443 :: INFO :: Chuck joined #centrale-supelec +2019-04-21 23:08:03,352 :: INFO :: Chuck is disconnected : [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +] +2019-04-21 23:08:03,352 :: INFO :: Client connexion lost +2019-04-21 23:08:05,355 :: INFO :: Souby is disconnected : [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +] +2019-04-21 23:08:05,356 :: INFO :: Client connexion lost +2019-04-21 23:08:53,358 :: INFO :: Klafirc is running ! +2019-04-21 23:08:53,358 :: INFO :: Loading configuration from ./bots.yaml +2019-04-21 23:08:53,529 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : Connection was refused by other side: 111: Connection refused. +] +2019-04-21 23:08:53,530 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : Connection was refused by other side: 111: Connection refused. +] +2019-04-21 23:08:53,532 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback: : Can't stop reactor that isn't running. +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/log.py:86:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:122:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:85:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:627:_doReadOrWrite +--- --- +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:614:_doReadOrWrite +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:592:doConnect +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:494:failIfNotConnected +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:1146:connectionFailed +/home/klafyvel/dev/klafirc/klafirc/irc.py:53:clientConnectionFailed +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:630:stop +]. +] +2019-04-21 23:08:53,533 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : Connection was refused by other side: 111: Connection refused. +] +2019-04-21 23:08:53,534 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback: : Can't stop reactor that isn't running. +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/log.py:86:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:122:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:85:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:627:_doReadOrWrite +--- --- +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:614:_doReadOrWrite +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:592:doConnect +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:494:failIfNotConnected +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:1146:connectionFailed +/home/klafyvel/dev/klafirc/klafirc/irc.py:53:clientConnectionFailed +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:630:stop +]. +] +2019-04-21 23:08:53,534 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : Connection was refused by other side: 111: Connection refused. +] +2019-04-21 23:08:53,535 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback: : Can't stop reactor that isn't running. +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/log.py:86:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:122:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:85:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:627:_doReadOrWrite +--- --- +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:614:_doReadOrWrite +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:592:doConnect +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:494:failIfNotConnected +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:1146:connectionFailed +/home/klafyvel/dev/klafirc/klafirc/irc.py:53:clientConnectionFailed +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:630:stop +]. +] +2019-04-21 23:08:53,536 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : Connection was refused by other side: 111: Connection refused. +] +2019-04-21 23:08:53,536 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback: : Can't stop reactor that isn't running. +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/log.py:86:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:122:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/python/context.py:85:callWithContext +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:627:_doReadOrWrite +--- --- +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/posixbase.py:614:_doReadOrWrite +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:592:doConnect +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/tcp.py:494:failIfNotConnected +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:1146:connectionFailed +/home/klafyvel/dev/klafirc/klafirc/irc.py:53:clientConnectionFailed +/home/klafyvel/.local/share/virtualenvs/klafirc-EZk2W7hm/lib/python3.6/site-packages/twisted/internet/base.py:630:stop +]. +] +2019-04-21 23:08:53,537 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,539 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,539 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,540 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,541 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,541 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,542 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,542 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,543 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,544 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:08:53,544 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:11:59,899 :: INFO :: Klafirc is running ! +2019-04-21 23:11:59,900 :: INFO :: Loading configuration from ./bots.yaml +2019-04-21 23:12:27,094 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : Connection was refused by other side: 111: Connection refused. +] +2019-04-21 23:12:27,096 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,101 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,103 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,105 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,107 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,109 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,111 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,113 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,115 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,117 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,120 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,122 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,125 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,127 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:12:27,129 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,676 :: INFO :: Klafirc is running ! +2019-04-21 23:13:32,676 :: INFO :: Loading configuration from ./bots.yaml +2019-04-21 23:13:32,827 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : Connection was refused by other side: 111: Connection refused. +] +2019-04-21 23:13:32,829 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,833 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,834 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,835 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,836 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,837 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,838 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,839 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,840 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,841 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,842 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] +2019-04-21 23:13:32,842 :: INFO :: Connection failed : [Failure instance: Traceback (failure with no frames): : An error occurred while connecting: [Failure instance: Traceback (failure with no frames): : Connection to the other side was lost in a non-clean fashion: Connection lost. +]. +] diff --git a/klafirc.service b/klafirc.service new file mode 100644 index 0000000..a420a0b --- /dev/null +++ b/klafirc.service @@ -0,0 +1,14 @@ +[Unit] +Description=Klafyirc bots +After=network-online.target + +[Service] +Type=simple + +User=root +Group=root + +ExecStart=/usr/bin/python3 -m klafirc + +[Install] +WantedBy=multi-user.target diff --git a/klafytg/__init__.py b/klafytg/__init__.py new file mode 100644 index 0000000..0892ce8 --- /dev/null +++ b/klafytg/__init__.py @@ -0,0 +1,7 @@ +""" +A simple irc bot. See /etc/klafirc/bots.yaml to see which bots are runned. +""" + +from .bot import Bot + +__version__ = "0.1" diff --git a/klafytg/__main__.py b/klafytg/__main__.py new file mode 100644 index 0000000..7c15dec --- /dev/null +++ b/klafytg/__main__.py @@ -0,0 +1,3 @@ +from . import run + +run() diff --git a/klafytg/bot.py b/klafytg/bot.py new file mode 100644 index 0000000..b57b3b0 --- /dev/null +++ b/klafytg/bot.py @@ -0,0 +1,133 @@ +import re +import random +import importlib +import datetime +import logging +import os + +import toml +import telegram +from telegram.ext import MessageHandler, Filters +from telegram.ext import Updater +from telegram.ext import CommandHandler + + +class Bot: + def __init__(self, filename): + """Initialize a bot object + + Args: + filename: config file for the bot + """ + logging.info("Loading configuration from %s.", filename) + self.config = toml.load(filename) + self.name = self.config["bot"]['name'] + self.bot = telegram.Bot(os.environ[self.config["bot"]['token']]) + self.channels = {} + self.reactions = {} + for k in self.config["match"].keys(): + self.add_reaction(k, self.config["match"][k]) + + self.pings = [] + for quote in self.config["ping"]["quotes"]: + self.add_ping(quote) + + for channel in self.config["bot"]["channels"]: + self.channels[channel] = datetime.datetime(1,1,1) + + + self.updater = Updater(token=os.environ[self.config["bot"]["token"]], use_context=True) + self.dispatcher = self.updater.dispatcher + + self.quote_handler = CommandHandler('ping', self.on_ping) + self.dispatcher.add_handler(self.quote_handler) + + def start(self): + self.updater.start_polling() + + def stop(self): + self.updater.stop() + + def on_join(self): + pass + + def on_ping(self, update, context): + quote = random.choice(self.config["ping"]["quotes"]) + context.bot.send_message(chat_id=update.effective_chat.id, text=quote) + + 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. + """ + self.reactions[match] = reaction + + def add_python_reaction(self, match, reaction): + """ Add a Python callback to the reactions. + + Args: + match: The string which, if matched will trigger the answer. + reaction: The path to the callback + """ + self.add_reaction(match, self.fetch_callback(reaction)) + + def add_ping(self, reaction): + """Add a reaction to a ping""" + self.pings.append(reaction) + + def add_python_ping(self, reaction): + """Fetch a Python callable and add it to the pings""" + self.add_ping(self.fetch_callback(reaction)) + + def fetch_callback(self, path): + """Fetch a Python callable""" + s = path.split(".") + module, callback = ".".join(s[:-1]), s[-1] + module = importlib.import_module(module) + return getattr(module, callback) + + def get_reaction(self, username, 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. + """ + if (datetime.datetime.now() - self.last_time).total_seconds() < self.min_time: + return [] + + context = { + "channel": channel, + "name": self.name, + "user": username, + "message": message, + } + result = [] + for m in self.reactions.keys(): + search = m.search(message) + if search: + r = self.reactions[m] + if callable(r): + r = r(self, username, channel, message) + else: + r = r.format(**context) + result.append(r) + + if not result and self.ping_match.search(message): + r = random.choice(self.pings) + if callable(r): + r = r(self, username, channel, message) + else: + r = r.format(**context) + result.append(" : ".join([username, r])) + + if len(result) > 0: + self.last_time = datetime.datetime.now() + + return result diff --git a/klafytg/bots/__init__.py b/klafytg/bots/__init__.py new file mode 100644 index 0000000..a243a98 --- /dev/null +++ b/klafytg/bots/__init__.py @@ -0,0 +1 @@ +from . import chuck_norris diff --git a/klafytg/bots/__pycache__/__init__.cpython-36.pyc b/klafytg/bots/__pycache__/__init__.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..96a844c145e44a38956120ac9928bbfed8e1abbd GIT binary patch literal 171 zcmXr!<>h*^BsE%^fq~&M5W@izkmUfx#R5Pgg&~D8has0Sijk2ag(;XplldhhP*{`k z7Ef|UX>xXaUVc$gX0e|p(=CP~kj|A1MJzxHO#Cv|&&bbB)z8jJOsgzQ&CyRuEdz5h oi<04VQhrIXetdjpUS>&ryk0@&Ee@O9{FKt1R6CGG#X!se02Ep(Z~y=R literal 0 HcmV?d00001 diff --git a/klafytg/bots/__pycache__/chuck_norris.cpython-36.pyc b/klafytg/bots/__pycache__/chuck_norris.cpython-36.pyc new file mode 100644 index 0000000000000000000000000000000000000000..8da7df67fb04cd61f4256c107a07037104dd20cd GIT binary patch literal 571 zcmYjNv2NQi6eJ}oQk4eim~_(CYO#Q3C{PqZfdU=9WOE0BB^gVyL^^zw0SC$Cj{TAR z64y-mg-(5>gCYcY_Z}s_yW{2ASvmbtKhG&4Pvq4~u>OV{J|al6B9h8vq$?UZStT-+ z>^E7ZGLt9BOeWW)&hI{zKa>+)#VgCTG*czIS!^n8tnHz?;lfpTUdbLtzK5!Ji}D#2 z$WjCh3!RXl{v9{GM{s07)dPJXE*a8$GOz=Bxge;QF7G~c&TZjK)9`J-h+;>rMQ@tH zY!oy{BR<>laaMKa3#)Et1rB_=R?f2ljP}`RxCEaIqn*;Ork>hIV&9_4 zezV`Hv5{&Qo8F55{L46KqI~M-Cw! zUDn4xYvxlF@N5QU(PPK8R-?}+1;E!Tx;#ROw|#DOyY2P*EjAFIl2H2&5wquQD~)Jd kn__RX0KrQ9{Ax^yZR4!s>ty6Ss;h7TLI_3+TBHU02d4ju(*OVf literal 0 HcmV?d00001 diff --git a/klafytg/bots/chuck_norris.py b/klafytg/bots/chuck_norris.py new file mode 100644 index 0000000..28c673f --- /dev/null +++ b/klafytg/bots/chuck_norris.py @@ -0,0 +1,14 @@ +""" +Fetch a random chuck norris fact and dislays it. +""" +import requests +import json + + +def get_content(): + r = requests.get("https://api.chucknorris.io/jokes/random") + return json.loads(r.content)["value"] + + +def on_ping(bot, user, channel, message): + return get_content() diff --git a/klafytg/irc.py b/klafytg/irc.py new file mode 100644 index 0000000..d88c9e5 --- /dev/null +++ b/klafytg/irc.py @@ -0,0 +1,61 @@ +import time + +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) + if self.factory.bot.on_join is not None: + self.say(self.factory.channel, self.factory.bot.on_join) + + 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): + logger.info("Client connexion lost") + time.sleep(2) + connector.connect() + + def clientConnectionFailed(self, connector, reason): + logger.info("Connection failed : " + str(reason)) + reactor.stop() + + def buildProtocol(self, addr): + p = IRCBot() + p.factory = self + p.nickname = self.bot.nickname + return p diff --git a/klafytg/klafirc.log b/klafytg/klafirc.log new file mode 100644 index 0000000..7c1e004 --- /dev/null +++ b/klafytg/klafirc.log @@ -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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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): : 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 : je glande presque autant qu'un pelec +2018-08-02 13:52:24,145 :: DEBUG :: Macron_ heard klafyvel : 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): : 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): : 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): : 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): : 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): : 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): : 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 diff --git a/klafytg/runner.py b/klafytg/runner.py new file mode 100644 index 0000000..a51a793 --- /dev/null +++ b/klafytg/runner.py @@ -0,0 +1,12 @@ +from pathlib import Path + +from .settings import logger, BOT_FILE +from .bot import Bot + +def run(): + logger.info("Klafirc is running !") + folder = Path(BOT_FOLDER) + bots = [Bot(filename.resolve()) for filename in folder / "*.toml"] + for b in bots: + b.start() + return bots diff --git a/klafytg/settings.py b/klafytg/settings.py new file mode 100644 index 0000000..c426761 --- /dev/null +++ b/klafytg/settings.py @@ -0,0 +1,29 @@ +import logging +from logging.handlers import RotatingFileHandler + +DEBUG = True + +if not DEBUG: + BOT_FOLDER = "/etc/klafytg/bots.d" + LOG_FILE = "/var/log/klafirc/klafirc.log" +else: + BOT_FOLDER = "./etc/klafytg/bots.d" + LOG_FILE = "./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) diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..d480e4e --- /dev/null +++ b/setup.py @@ -0,0 +1,19 @@ +from setuptools import setup, find_packages + +setup( + name="Klafirc", + version="0.1", + long_description=open("README.md").read(), + url="http://gitlab.rezometz.org/klafyvel/klafirc", + author="klafyvel", + author_email="me@klafyvel.me", + include_package_data=True, + packages=find_packages(), + install_requires=open("requirements.txt").read().split("\n"), + classifier=[ + "Development Status :: 4 - Beta", + "Operating System :: POSIX :: Linux", + "Programming Language :: Python :: 3", + "Topic :: Utilities", + ], +)