From 3ec2b90e8ea83755df79b449cf9db54de12b2e65 Mon Sep 17 00:00:00 2001 From: Tabby <41929769+tabby-cat-nya@users.noreply.github.com> Date: Thu, 4 Dec 2025 02:09:49 +1100 Subject: [PATCH] started building a scam message checker --- Main.tscn | 9 ++++++++- TODO.md | 6 ++++++ addons/discord_gd/discord.gd | 4 ++++ checker/Checker.tscn | 3 +++ checker/checker.gd | 31 +++++++++++++++++++++++++++++++ checker/checker.gd.uid | 1 + main.gd | 8 ++++++-- 7 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 checker/Checker.tscn create mode 100644 checker/checker.gd create mode 100644 checker/checker.gd.uid diff --git a/Main.tscn b/Main.tscn index 227d678..69e33f9 100644 --- a/Main.tscn +++ b/Main.tscn @@ -1,6 +1,8 @@ -[gd_scene load_steps=2 format=3 uid="uid://cd60nfxe4lnq1"] +[gd_scene load_steps=4 format=3 uid="uid://cd60nfxe4lnq1"] [ext_resource type="Script" uid="uid://cus8nh0g3yyj2" path="res://main.gd" id="1_glv2v"] +[ext_resource type="PackedScene" uid="uid://i3rqbgerpgey" path="res://checker/Checker.tscn" id="2_r0du0"] +[ext_resource type="Script" uid="uid://8yiff3da5cxh" path="res://checker/checker.gd" id="3_cm0pq"] [node name="Main" type="Control"] layout_mode = 3 @@ -10,3 +12,8 @@ anchor_bottom = 1.0 grow_horizontal = 2 grow_vertical = 2 script = ExtResource("1_glv2v") + +[node name="Checker" parent="." instance=ExtResource("2_r0du0")] +script = ExtResource("3_cm0pq") + +[connection signal="message_created" from="." to="Checker" method="_on_main_message_created"] diff --git a/TODO.md b/TODO.md index 384b6a7..d56fb8c 100644 --- a/TODO.md +++ b/TODO.md @@ -27,5 +27,11 @@ - [x] spool list - [x] spool delete search result (removed embed) +## scam message checker +- [ ] need to modify the command to allow for arguments for how long the timeout should last for +- [ ] bunch of detecting if its a scam message or not +- [ ] update server version + + ### Possible furture development - job management diff --git a/addons/discord_gd/discord.gd b/addons/discord_gd/discord.gd index a529119..59dd61f 100644 --- a/addons/discord_gd/discord.gd +++ b/addons/discord_gd/discord.gd @@ -272,6 +272,10 @@ func unban_member(guild_id: String, user_id: String): var res = await _send_request('/guilds/%s/bans/%s' % [guild_id, user_id], {}, HTTPClient.METHOD_DELETE) return res +func timeout_member(guild_id: String, user_id: String, until : String): + var res = await _send_request('/guilds/%s/members/%s' % [guild_id, user_id], {'communication_disabled_until' = '2025-12-5T09:49:58.965896+00:00'}, HTTPClient.METHOD_PATCH) + return res + func permissions_for(user_id: String, channel_id: String): # Permissions for a user in a channel diff --git a/checker/Checker.tscn b/checker/Checker.tscn new file mode 100644 index 0000000..25a9885 --- /dev/null +++ b/checker/Checker.tscn @@ -0,0 +1,3 @@ +[gd_scene format=3 uid="uid://i3rqbgerpgey"] + +[node name="Checker" type="Node"] diff --git a/checker/checker.gd b/checker/checker.gd new file mode 100644 index 0000000..199ba53 --- /dev/null +++ b/checker/checker.gd @@ -0,0 +1,31 @@ +extends Node + + +# Called when the node enters the scene tree for the first time. +func _ready() -> void: + pass # Replace with function body. + + +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _process(delta: float) -> void: + pass + + +func _on_main_message_created(bot: DiscordBot, message: Message, channel: Dictionary) -> void: + ## analyse every message to detect if it is a scam message or not + # text = message.content + # images = message.attachments - its an array, so count the attachments + # server join date = message.member["joined_at"] + # could also keep track of how many messages the user has sent on the server and be more sensitive if its the first 5/10/20 or so + # message.author.id , message.author.username + # for any matches we find, we want to senda copy to the admin channel then delete the original copy and timeout the user + + #print(message) + print(message.guild_id) + if message.author.id == "616872480371376128": + # its fuzzy, lets try and time them out + var until = "2025-12-05T00:00:00Z" + bot.timeout_member(message.guild_id, message.author.id, until) + + + pass # Replace with function body. diff --git a/checker/checker.gd.uid b/checker/checker.gd.uid new file mode 100644 index 0000000..02a82f5 --- /dev/null +++ b/checker/checker.gd.uid @@ -0,0 +1 @@ +uid://8yiff3da5cxh diff --git a/main.gd b/main.gd index 4cceacf..6d6fb7c 100644 --- a/main.gd +++ b/main.gd @@ -6,6 +6,7 @@ signal interaction_create(world, bot, interaction, data) var interactions = {} var application_commands = {} +signal message_created(bot: DiscordBot, message: Message, channel: Dictionary) func _load_bot_token() -> String: # read from .env file DISORD_BOT_TOKEN @@ -30,7 +31,7 @@ func _ready() -> void: bot.TOKEN = token #bot.INTENTS = 4609 bot.bot_ready.connect(_on_bot_ready) - #bot.message_create.connect(_on_message_create) + bot.message_create.connect(_on_message_create) bot.interaction_create.connect(_on_interaction_create) bot.INTENTS = bot.INTENTS | (1 << 12) bot.login() @@ -63,7 +64,10 @@ func _on_bot_ready(bot: DiscordBot): _register_application_commands(bot) # everywhere -#func _on_message_create(bot: DiscordBot, message: Message, channel: Dictionary) -> void: +func _on_message_create(bot: DiscordBot, message: Message, channel: Dictionary) -> void: + #print("meow!") + message_created.emit(bot, message, channel) + #if message.author.bot or not message.content.begins_with(prefix): #return #