Added info event feature
The bot is now able to return information about a certain event to a room.
This commit is contained in:
parent
09dd17c9f2
commit
06868d67ce
@ -150,8 +150,7 @@ class Plugin:
|
|||||||
if room.display_name in mapping[1]:
|
if room.display_name in mapping[1]:
|
||||||
room.send_html(
|
room.send_html(
|
||||||
self.messages["new_event"].format(
|
self.messages["new_event"].format(
|
||||||
row[3].strftime("%d-%m-%Y"),
|
row[3].strftime("%d-%m-%Y om %H:%M"),
|
||||||
row[3].strftime("%H:%M"),
|
|
||||||
row[2],
|
row[2],
|
||||||
view_link,
|
view_link,
|
||||||
attend_link,
|
attend_link,
|
||||||
@ -217,9 +216,9 @@ class Plugin:
|
|||||||
|
|
||||||
html_message += "<li>"
|
html_message += "<li>"
|
||||||
html_message += self.messages['list_event_item'].format(
|
html_message += self.messages['list_event_item'].format(
|
||||||
row[3].strftime("%d-%m-%Y"),
|
row[3].strftime("%d-%m-%Y om %H:%M"),
|
||||||
row[3].strftime("%H:%M"),
|
|
||||||
row[2],
|
row[2],
|
||||||
|
row[0],
|
||||||
attend_link)
|
attend_link)
|
||||||
html_message += "</li>"
|
html_message += "</li>"
|
||||||
|
|
||||||
@ -232,14 +231,56 @@ class Plugin:
|
|||||||
mysql_db.close()
|
mysql_db.close()
|
||||||
|
|
||||||
def info_callback(self, room, event):
|
def info_callback(self, room, event):
|
||||||
room.send_text("Info")
|
id_event = False
|
||||||
|
|
||||||
def chat_callback(self, room, event):
|
for word in event['content']['body'].split():
|
||||||
room.send_text("Chat")
|
try:
|
||||||
|
id_event = int(word)
|
||||||
|
break
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if not id_event or id_event < 0:
|
||||||
|
room.send_html(self.messages['info_event_id_err'])
|
||||||
|
return
|
||||||
|
|
||||||
|
mysql_db = self.connect_database()
|
||||||
|
mysql_cursor = mysql_db.cursor()
|
||||||
|
|
||||||
|
select_sql = f"""SELECT dat_id, dat_headline, dat_description,
|
||||||
|
dat_begin, dat_end
|
||||||
|
FROM adm_dates
|
||||||
|
WHERE dat_id = {id_event}"""
|
||||||
|
|
||||||
|
mysql_cursor.execute(select_sql)
|
||||||
|
|
||||||
|
# Fetch events
|
||||||
|
row = mysql_cursor.fetchall()
|
||||||
|
|
||||||
|
date_url = "{}{}{}".format(
|
||||||
|
self.config['base_url_adm'],
|
||||||
|
"/adm_program/modules/dates/dates.php?id=",
|
||||||
|
row[0][0])
|
||||||
|
|
||||||
|
html_message = self.messages['info_event'].format(
|
||||||
|
date_url,
|
||||||
|
row[0][1],
|
||||||
|
row[0][3].strftime("%d-%m-%Y om %H:%M"),
|
||||||
|
row[0][4].strftime("%d-%m-%Y om %H:%M"),
|
||||||
|
row[0][2])
|
||||||
|
|
||||||
|
# Send message
|
||||||
|
room.send_html(html_message)
|
||||||
|
|
||||||
|
# Close DB connection
|
||||||
|
mysql_db.close()
|
||||||
|
|
||||||
def participants_callback(self, room, event):
|
def participants_callback(self, room, event):
|
||||||
room.send_text("Deelnemers")
|
room.send_text("Deelnemers")
|
||||||
|
|
||||||
|
def chat_callback(self, room, event):
|
||||||
|
room.send_text("Chat")
|
||||||
|
|
||||||
def help(self):
|
def help(self):
|
||||||
return open(HELP_LOCATION, mode="r").read()
|
return open(HELP_LOCATION, mode="r").read()
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
"new_event":
|
"new_event":
|
||||||
'''
|
'''
|
||||||
<strong>@room er is zojuist een nieuw evenement aangemaakt!
|
<strong>@room er is zojuist een nieuw evenement aangemaakt!
|
||||||
Op {} om {} zal "{}" plaatsvinden.</strong>
|
Op {} zal "{}" plaatsvinden.</strong>
|
||||||
|
|
||||||
<br /><br />
|
<br /><br />
|
||||||
|
|
||||||
@ -24,12 +24,31 @@
|
|||||||
|
|
||||||
"list_event_item":
|
"list_event_item":
|
||||||
'''
|
'''
|
||||||
{} om {}: <strong>{}</strong> (<a href='{}'>aanmelden</a>)
|
{}: <strong>{}</strong> (ID: {}, <a href='{}'>aanmelden</a>)
|
||||||
''',
|
''',
|
||||||
|
|
||||||
"list_event_num_err":
|
"list_event_num_err":
|
||||||
'''
|
'''
|
||||||
Let op: alleen de getallen [1,100] zijn toegestaan!
|
Let op: alleen de getallen [1,100] zijn toegestaan!
|
||||||
Ik pak de standaard waarde 10.
|
Ik pak de standaard waarde 10.
|
||||||
|
''',
|
||||||
|
|
||||||
|
"info_event_id_err":
|
||||||
|
'''
|
||||||
|
Let op: alleen natuurlijke getallen (0, 1, 2, 3, 4, ... voor de mensen
|
||||||
|
die HöMa 1 nog niet gehaald hebben 😉) zijn toegestaan. Vraag de lijst
|
||||||
|
van evenementen op, om het identificatienummer van het evenement dat
|
||||||
|
je zoekt te vinden.
|
||||||
|
''',
|
||||||
|
|
||||||
|
"info_event":
|
||||||
|
'''
|
||||||
|
Je hebt informatie opgevraagd over het evenement: "<a href="{}">{}</a>".
|
||||||
|
Het evenement begint op {} en eindigt op {}. De maker van het
|
||||||
|
evenement heeft deze beschrijving toegevoegd:
|
||||||
|
|
||||||
|
<br /><br />
|
||||||
|
|
||||||
|
<blockquote>{}</blockquote>
|
||||||
'''
|
'''
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user