Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
software-project-WS25
Discord Team
Commits
5334bf2d
Commit
5334bf2d
authored
Nov 25, 2025
by
Dennis
Browse files
added server_id,channel_id,backlink
parent
69c9fb00
Changes
1
Show whitespace changes
Inline
Side-by-side
bot_history.py
View file @
5334bf2d
...
@@ -22,6 +22,7 @@ DATA_DIR = Path("ingest")
...
@@ -22,6 +22,7 @@ DATA_DIR = Path("ingest")
DATA_DIR
.
mkdir
(
exist_ok
=
True
)
DATA_DIR
.
mkdir
(
exist_ok
=
True
)
META_DIR
=
DATA_DIR
/
".meta"
META_DIR
=
DATA_DIR
/
".meta"
META_DIR
.
mkdir
(
exist_ok
=
True
)
META_DIR
.
mkdir
(
exist_ok
=
True
)
DISCORD_LINK
=
"https://discord.com/channels/"
URL_REGEX
=
r
'(https?://\S+)'
URL_REGEX
=
r
'(https?://\S+)'
...
@@ -64,13 +65,7 @@ async def on_ready():
...
@@ -64,13 +65,7 @@ async def on_ready():
with
open
(
meta_file
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
with
open
(
meta_file
,
'r'
,
encoding
=
'utf-8'
)
as
f
:
meta_data
=
json
.
load
(
f
)
meta_data
=
json
.
load
(
f
)
else
:
else
:
meta_data
=
{
meta_data
=
get_meta_data
(
message
)
"message_id"
:
str
(
message
.
id
),
"user_id"
:
str
(
message
.
author
.
id
),
"text"
:
message
.
content
,
"reactions_history"
:
[],
"links"
:
re
.
findall
(
URL_REGEX
,
message
.
content
)
}
save_text
(
message
.
content
,
message_file
)
save_text
(
message
.
content
,
message_file
)
# Ensure reactions_history exists
# Ensure reactions_history exists
...
@@ -100,17 +95,23 @@ async def on_message(message: discord.Message):
...
@@ -100,17 +95,23 @@ async def on_message(message: discord.Message):
file_name
=
f
"
{
message
.
id
}
_
{
ts_safe
}
"
file_name
=
f
"
{
message
.
id
}
_
{
ts_safe
}
"
meta_file
=
META_DIR
/
f
"
{
file_name
}
.txt.json"
meta_file
=
META_DIR
/
f
"
{
file_name
}
.txt.json"
message_file
=
DATA_DIR
/
f
"
{
file_name
}
.txt"
message_file
=
DATA_DIR
/
f
"
{
file_name
}
.txt"
meta_data
=
get_meta_data
(
message
)
save_text
(
message
.
content
,
message_file
)
await
save_json_file_async
(
meta_data
,
meta_file
)
print
(
f
'💬
{
message
.
author
}
said:
{
message
.
content
}
(saved to
{
message_file
}
)'
)
message_data
=
{
def
get_meta_data
(
message
:
discord
.
Message
):
return
{
"message_id"
:
str
(
message
.
id
),
"message_id"
:
str
(
message
.
id
),
"user_id"
:
str
(
message
.
author
.
id
),
"user_id"
:
str
(
message
.
author
.
id
),
"server_id"
:
str
(
message
.
guild
.
id
),
"channel_id"
:
str
(
message
.
channel
.
id
),
"backlink"
:
DISCORD_LINK
+
str
(
message
.
guild
.
id
)
+
"/"
+
str
(
message
.
channel
.
id
)
+
"/"
+
str
(
message
.
id
),
"text"
:
message
.
content
,
"text"
:
message
.
content
,
"reactions_history"
:
[],
"reactions_history"
:
[],
"links"
:
re
.
findall
(
URL_REGEX
,
message
.
content
)
"links"
:
re
.
findall
(
URL_REGEX
,
message
.
content
)
,
}
}
save_text
(
message
.
content
,
message_file
)
await
save_json_file_async
(
message_data
,
meta_file
)
print
(
f
'💬
{
message
.
author
}
said:
{
message
.
content
}
(saved to
{
message_file
}
)'
)
# === Reaction events ===
# === Reaction events ===
async
def
update_reaction_history
(
message_id
:
str
,
emoji
:
str
,
user_id
:
str
,
action
:
str
,
timestamp
:
str
):
async
def
update_reaction_history
(
message_id
:
str
,
emoji
:
str
,
user_id
:
str
,
action
:
str
,
timestamp
:
str
):
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment