Add gitignore

This commit is contained in:
Eragon 2022-03-09 14:14:58 +01:00
parent 8c46906cc2
commit 31e4efed44
Signed by: Eragon
GPG Key ID: 087126EBFC725006
3 changed files with 21 additions and 4 deletions

5
.gitignore vendored Normal file
View File

@ -0,0 +1,5 @@
cookies.py
sasl.py
users.py
__pycache__/

View File

@ -8,6 +8,7 @@ from irc import IRC
from shoutbox import Shoutbox
from cookies import cookies
from sasl import nick, password
from users import users
LOG_FORMAT = "%(asctime)s [%(levelname)s] <%(filename)s> %(funcName)s: %(message)s"
@ -18,9 +19,11 @@ channels = ["hs", "projets", "annonces"]
irc = IRC('irc.planet-casio.com', 6697)
shoutbox = Shoutbox(cookies)
@irc.on(lambda m: m.to[1:] in channels)
def handle_irc(m):
shoutbox.post(f"{m.author}: {m.text}", m.to[1:])
shoutbox.post(m.author, m.text, m.to[1:], users)
@shoutbox.on(lambda m: m.channel in channels and m.author != "IRC")
def handle_shoutbox(m):

View File

@ -48,9 +48,18 @@ class Shoutbox(object):
return callback
def post(self, msg, channel):
r.post("https://www.planet-casio.com/Fr/shoutbox/api/post",
data={"message": msg, "channel": channel}, cookies=self.cookies)
def post(self, user, msg, channel, users):
if any(user in t for t in users):
for i in users:
if i[1] == user:
r.post("https://www.planet-casio.com/Fr/shoutbox/api/post-as",
data={"user": i[0], "message": msg, "channel": channel},
cookies=self.cookies)
else:
r.post("https://www.planet-casio.com/Fr/shoutbox/api/post-as",
data={"user": "IRC", "message": f"{user} : {msg}", "channel": channel},
cookies=self.cookies)
class SBMessage(object):
def __init__(self, raw, channel):