started building a scam message checker

This commit is contained in:
Tabby 2025-12-04 02:09:49 +11:00
parent 0ae75441c9
commit 3ec2b90e8e
7 changed files with 59 additions and 3 deletions

View file

@ -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"]

View file

@ -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

View file

@ -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

3
checker/Checker.tscn Normal file
View file

@ -0,0 +1,3 @@
[gd_scene format=3 uid="uid://i3rqbgerpgey"]
[node name="Checker" type="Node"]

31
checker/checker.gd Normal file
View file

@ -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.

1
checker/checker.gd.uid Normal file
View file

@ -0,0 +1 @@
uid://8yiff3da5cxh

View file

@ -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
#