]> gitweb.pimeys.fr Git - scripts-20-100.git/blobdiff - spambot/spambot.py
C'était pour spammer pour avoir les cotiz post-pot
[scripts-20-100.git] / spambot / spambot.py
diff --git a/spambot/spambot.py b/spambot/spambot.py
new file mode 100755 (executable)
index 0000000..1a782aa
--- /dev/null
@@ -0,0 +1,78 @@
+#!/usr/bin/env python
+# -*- encoding: utf-8 -*-
+
+# Pour envoyer des mails en masses à plein de gens, parce que y'en a marre à la fin
+
+import os
+import email
+import sys
+
+DEBUG = False
+if "--debug" in sys.argv:
+    DEBUG = True
+
+QUIET = False
+if "--quiet" in sys.argv:
+    QUIET = True
+
+def sendmail(to, subject, body, froms=[u"20-100's spambot <legallic@crans.org>"], cc=[]):
+    if isinstance(to, unicode) or isinstance(to, str):
+        to = [to]
+    if isinstance(cc, unicode) or isinstance(cc, str):
+        cc = [cc]
+    if isinstance(froms, unicode) or isinstance(froms, str):
+        froms = [froms]
+    if DEBUG:
+        cc, to = [], [u"Default target for testing spambot <legallic@crans.org>"]
+    headers = u"From: %s\nTo: %s\n" % (", ".join(froms), ", ".join(to))
+    if cc:
+        headers += u"Cc: %s\n" % (", ".join(cc))
+    headers += u"Subject: %s\n" % email.Header.make_header([(subject, "utf8")]).encode()
+    headers += u"Content-Type: text/plain; charset=UTF-8\n"
+    mail = headers + "\n" + body
+    mailer = os.popen("/usr/sbin/sendmail -t", "w")
+    mailer.write(mail.encode("utf-8") + "\n.")
+    mailer.close()
+
+
+def spam_quelu():
+    if not QUIET:
+        print "Spamming quelu about WiFi profile."
+    sendmail("pellissier@crans.org", "Profil Wifi", u"Au fait, tu devais pas me filer un profil Wifi ?\n\n-- \n20-100, qui s'est enfin codé son spambot")
+
+
+
+def spam_acoeur(qui, combien):
+    if not QUIET:
+        print "Spamming %s about Bus/Pot A♡" % qui
+    body = u"""Plop,
+
+Petit mail pour te rappeler que, tous calculs confondus, pour le bus et/ou le pot A♡, tu dois encore %s€.
+Ce serait cool que tu me fasses un virement.
+
+Si tu préfères par virement note ou par espèces (bof), envoie-moi un mail.
+
+Si tu as déjà remboursé et que tu reçois ce mail, préviens-moi, j'ai du merder quelque part…
+
+-- 
+20-100, trésorier des A♡""" % combien
+    sendmail(qui, u"[Bus et/ou Pot A♡] Remboursement", body)
+
+def get_acoeurs():
+    l = open("acoeurlist.txt").readlines()
+    l = [i.strip() for i in l if not i.strip().startswith("#") and i.strip() != ""]
+    return [i.split(" ") for i in l]
+
+def spam_acoeurs():
+    liste = get_acoeurs()
+    for (qui, combien) in liste:
+        spam_acoeur(qui, combien)
+
+
+def spam_29C3():
+    return
+
+todolist = [spam_quelu] #, spam_acoeurs]#, spam_29C3]
+if __name__ == "__main__":
+    for action in todolist:
+        action()