-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
78 lines (70 loc) · 2.1 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from http import server
import discord
import traceback
from discord.ext import commands
import os
import time
import difflib
import notification_api as na
import sms_api as sa
from dotenv import load_dotenv
bot = commands.Bot(command_prefix=None)
load_dotenv()
phishing_a = []
precedent_dm = None
serverdm_a=[]
@bot.event
async def on_ready():
print('Online, for', str(bot.user))
sa.ACCOUNTID = str(bot.user)
na.run(na.Files.CONNECTED)
@bot.event
async def on_message(msg):
global precedent_dm, phishing_a,serverdm_a
msgcontent = msg.content
print(msgcontent)
# Physhing check
if '://' in msgcontent:
safe = ['steamcommunity.com','steampowered.com','discord.gg','discord.com','discord.new','discord.gift']
web=msgcontent.split('://')[1].split('/')[0]
r = difflib.get_close_matches(web, safe, 1)
if r[0] != web:
phishing_a.append(time.time())
res = 0
for t in phishing_a:
if t+10 > time.time():
res+=1
if res == 3:
sa.sendSMS(sa.PrebuiltMessages.PHISHING)
na.run(na.Files.SUSPICIOUS_TEXT)
res = 0
phishing_a=[]
serverdm_a=[]
return
# DM server all
if precedent_dm is None: precedent_dm = msg.channel.id
else:
if 'discord.gg/' in msgcontent:
if precedent_dm != msg.channel.id:
serverdm_a.append(time.time())
else:
serverdm_a = []
precedent_dm = msg.channel.id
res = 0
for t in serverdm_a:
if t+10 > time.time():
res+=1
if res == 3:
sa.sendSMS(sa.PrebuiltMessages.DM_ALL)
na.run(na.Files.SUSPICIOUS_TEXT)
res = 0
phishing_a=[]
serverdm_a=[]
return
try:
bot.run(os.environ.get('TOKEN'))
except:
print(traceback.format_exc())
print('CONNECTION LOST.')
sa.sendSMS(sa.PrebuiltMessages.CONNECTION_LOST)
na.run(na.Files.CONNECTION_LOST)