Add telegram bot
This commit is contained in:
+8
-1
@@ -12,6 +12,7 @@ from webapp.models import PresetKaehmyRole, CustomKaehmyRole
|
||||
from webapp.models import OhlhafvChallenge, KaehmyForm
|
||||
from webapp.forms import OhlhafvForm, KaehmyForm_Form, KaehmyCommentForm
|
||||
from webapp.tables import OhlhafvTable
|
||||
from webapp.telegram_bot import kaehmy_handler
|
||||
|
||||
from django.core.mail import send_mail
|
||||
from django.conf import settings
|
||||
@@ -146,15 +147,21 @@ def kaehmy_submit(request, *args, **kwargs):
|
||||
custom_role.save()
|
||||
application.custom_roles.add(custom_role)
|
||||
|
||||
url = 'https://sika.sahkoinsinoorikilta.fi/kaehmy'
|
||||
|
||||
email = form.cleaned_data.get('email', '')
|
||||
name = form.cleaned_data.get('name', 'Anonymous')
|
||||
subject = 'Arwokas kirjattu kirje mahdolliselle tulewalle kiltahenkilölle'
|
||||
body = ('Moikka {}!\r\n\r\nHienoa, että kilta kiinnostaa! Kaehmysi on vastaanotettu.\r\n'
|
||||
'Mahdollisista kommenteista tulee ilmoitus sähköpostitse.\r\n\r\n'
|
||||
'Käy katsomassa kaehmytilanne osoitteessa http://sika.sahkoinsinoorikilta.fi/kaehmy').format(name)
|
||||
'Käy katsomassa kaehmytilanne osoitteessa {}').format(name, url)
|
||||
|
||||
send_email(email, subject, body)
|
||||
logging.debug('Sent kaehmy email to recipient <{}>'.format(email))
|
||||
|
||||
kaehmy_handler.announce(url, name)
|
||||
logging.debug('Sent kaehmy announcement to telegram.')
|
||||
|
||||
else:
|
||||
context = {
|
||||
'errors': form.errors
|
||||
|
||||
Reference in New Issue
Block a user