Moving config to secret.txt
This commit is contained in:
parent
787ab55942
commit
13f7c88ed8
4 changed files with 42 additions and 26 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
secret.txt
|
|
@ -1,4 +1,5 @@
|
||||||
version: '2.0'
|
version: '3.0'
|
||||||
services:
|
services:
|
||||||
assemblybot:
|
assemblybot:
|
||||||
build: .
|
build: .
|
||||||
|
env_file: secret.txt
|
||||||
|
|
|
@ -34,40 +34,34 @@
|
||||||
#
|
#
|
||||||
#
|
#
|
||||||
|
|
||||||
import sys, requests, datetime, smtplib
|
import sys, requests, datetime, smtplib, os, re
|
||||||
from email.mime.text import MIMEText
|
from email.mime.text import MIMEText
|
||||||
from email.utils import formatdate
|
from email.utils import formatdate
|
||||||
|
|
||||||
# Redmine config
|
# Redmine config
|
||||||
redmine_url = 'https://tickets.zom.bi'
|
redmine_url = os.getenv('REDMINE_URL')
|
||||||
redmine_api_key = ''
|
redmine_api_key = os.getenv('REDMINE_API_KEY')
|
||||||
|
|
||||||
## Mediawiki config
|
## Mediawiki config
|
||||||
mediawiki_url = 'https://w.zom.bi'
|
mediawiki_url = os.getenv('MEDIAWIKI_URL')
|
||||||
# should be Bot credentials, that can be created on Special:BotPasswords
|
# should be Bot credentials, that can be created on Special:BotPasswords
|
||||||
mediawiki_username = 'Assemblybot@assemblybot'
|
mediawiki_username = os.getenv('MEDIAWIKI_USERNAME')
|
||||||
mediawiki_botpassword=''
|
mediawiki_botpassword=os.getenv('MEDIAWIKI_BOTPASSWORD')
|
||||||
|
smtp_recipients = re.split(' ',os.getenv('SMTP_RECIPIENTS'))
|
||||||
# smtp config
|
# smtp config
|
||||||
smtp_host = 'mail.zom.bi'
|
smtp_host = os.getenv('SMTP_HOST')
|
||||||
smtp_port = 465
|
smtp_port = os.getenv('SMTP_PORT')
|
||||||
smtp_from = 'assembly_noreply@zom.bi'
|
smtp_from = os.getenv('SMTP_FROM')
|
||||||
smtp_recipients = [['']]
|
smtp_user = os.getenv('SMTP_USER')
|
||||||
smtp_user = 'assemblybot'
|
smtp_password = os.getenv('SMTP_PASSWORD')
|
||||||
smtp_password = ''
|
mail_subject = os.getenv('MAIL_SUBJECT')
|
||||||
mail_subject = '☣ The undead assemble'
|
mail_header = os.getenv('MAIL_HEADER')
|
||||||
mail_header = "Greetings fellow undead,\nthere are some open \
|
mail_footer = os.getenv('MAIL_FOOTER')
|
||||||
issues that require a decision from an assembly. You'll find a list \
|
|
||||||
of said issues at the end of this mail. If you wonna know more about \
|
|
||||||
those topics, please head to our issue tracker at https://tickets.zom.bi\
|
|
||||||
\n----\n\n\n"
|
|
||||||
mail_footer = "\n----\n beep, boop. I'm a bot.\n If you wonna\
|
|
||||||
complain about me, write a mail to cpp or create a ticket at https://tickets.zom.bi"
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
|
||||||
assembly_date = str(datetime.date.today() +\
|
assembly_date = str(datetime.date.today() +\
|
||||||
datetime.timedelta((6-datetime.date.today().weekday()) % 7))
|
datetime.timedelta((datetime.date.today().weekday()) % 7))
|
||||||
requires_assembly = redmine_get_requires_assembly_id()
|
requires_assembly = redmine_get_requires_assembly_id()
|
||||||
log(1,"Assembly topics:\n")
|
log(1,"Assembly topics:\n")
|
||||||
issues = redmine_get_issues(requires_assembly)
|
issues = redmine_get_issues(requires_assembly)
|
||||||
|
@ -95,17 +89,17 @@ def main(args):
|
||||||
if '--no-mail' in args:
|
if '--no-mail' in args:
|
||||||
log(1,"'--no-mail' argument given, so no mails have been sent.")
|
log(1,"'--no-mail' argument given, so no mails have been sent.")
|
||||||
else:
|
else:
|
||||||
smtp_send()
|
smtp_send(mediawiki_page['content'])
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
def smtp_send()
|
def smtp_send(content):
|
||||||
smtp_server = smtplib.SMTP_SSL(host=smtp_host,port=smtp_port)
|
smtp_server = smtplib.SMTP_SSL(host=smtp_host,port=smtp_port)
|
||||||
if loglevel == 2:
|
if loglevel == 2:
|
||||||
smtp_server.set_debuglevel(1)
|
smtp_server.set_debuglevel(1)
|
||||||
smtp_server.connect(host=smtp_host)
|
smtp_server.connect(host=smtp_host)
|
||||||
smtp_server.login(user=smtp_user,password=smtp_password)
|
smtp_server.login(user=smtp_user,password=smtp_password)
|
||||||
mail_message = MIMEText(mail_header + \
|
mail_message = MIMEText(mail_header + \
|
||||||
mediawiki_page['content'] + mail_footer)
|
content + mail_footer)
|
||||||
mail_message['Subject'] = mail_subject
|
mail_message['Subject'] = mail_subject
|
||||||
mail_message['From'] = smtp_from
|
mail_message['From'] = smtp_from
|
||||||
mail_message['Date'] = formatdate()
|
mail_message['Date'] = formatdate()
|
||||||
|
|
20
secret.txt.example
Normal file
20
secret.txt.example
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
# Redmine config
|
||||||
|
REDMINE_URL=https://tickets.example.com
|
||||||
|
REDMINE_API_KEY=1337
|
||||||
|
|
||||||
|
## Mediawiki config
|
||||||
|
MEDIAWIKI_URL=https://wiki.example.com
|
||||||
|
# should be Bot credentials, that can be created on Special:BotPasswords
|
||||||
|
MEDIAWIKI_USERNAME=Assemblybot@assemblybot
|
||||||
|
MEDIAWIKI_BOTPASSWORD=1337
|
||||||
|
|
||||||
|
# smtp config
|
||||||
|
SMTP_HOST=mail.example.com
|
||||||
|
SMTP_PORT=465
|
||||||
|
SMTP_FROM=assembly_noreply@example.com
|
||||||
|
SMTP_USER=assemblybot
|
||||||
|
SMTP_PASSWORD=1337
|
||||||
|
SMTP_RECIPIENTS=john.doe@example.com max.mustermann@example.com
|
||||||
|
MAIL_SUBJECT=Put subject here
|
||||||
|
MAIL_HEADER=This text comes before the tickets
|
||||||
|
MAIL_FOOTER=This text comes after the tickets
|
Loading…
Reference in a new issue