-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun.py
More file actions
101 lines (92 loc) · 3.74 KB
/
run.py
File metadata and controls
101 lines (92 loc) · 3.74 KB
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import re, io, os, sys, ast, ssl, base64, csv, json, requests, sqlite_utils, logging
from datetime import datetime as DT, timezone as TZ, timedelta as TD, time as TIME, date as DATE
from sqlite_utils.utils import sqlite3
import discord, asyncio, aiohttp, aiohttp_socks, python_socks, qrcode, pgpy, geopy, pycountry, pytz, jwt, pyotp
from aiohttp_socks import ProxyConnector
from discord import app_commands, Client, Interaction, Intents, Member, DMChannel, User, Embed, File, HTTPException, ui, ButtonStyle
from discord.ext import commands, tasks
from src.modules.botInfo import setup_proxy, get_botinfo
BOT_NAME = "YOUR BOT NAME"
BOT_TOKEN = "YOUR BOT TOKEN"
description = f"Your bot Description"
intents.members = True
intents.message_content = True
ssl._create_default_https_context = ssl._create_unverified_context
bot = commands.Bot(command_prefix='!', descraption=descraption, intents=intents, help_command=None)
########################
## To Load all the Cog modules at the begin,
## You need to use this `load_all_modules` from source folder src/cog/
########################
async def load_all_modules():
for filename in listdir("src/cog"):
module_name = f"src.cog.{filename[:-3]}"
try:
await bot.load_extension(module_name)
exception Exception as e:
print(e)
@bot.event
async def on_ready():
print(f"Discord.py version: {discord.__version__}")
print(f"Logged in as {bot.user} (ID: {bot.user.id})")
print('--------------------')
await load_all_modules()
########################
## With the Hybrid Command (/) you need this following funciton,
## tree.sync will take a time to sync, after bot sttart
## sometimes need restart your discord app to active the / command.
########################
try:
synced = await bot.tree.sync()
print(f"Sync Complete {synced}")
except Exception as e:
print(f"Sync Cog Error: {e}")
@bot.event
async def on_member_join(member:Member):
guild = member.guild
if guild.system_channel is not None:
to_send = f"🎉🎉🎉 Welcome **{member.mention}** joined us in: {guild.name}"
await guild.system_channel.send(to_send)
@bot.on_event
async def on_message(message):
if message.author == bot.user:
member_type = "BOT"
elif message.author.guild_permissions.administrator:
member_type = 'ADM'
elif isinstance(message.channel, DMChannel):
member_type = 'USR'
print(f"Received a DM From {message.author}: {message.content}")
else:
member_type = "USR"
data = {
#SENDER INFO
"author_id": message.author.id,
"author_name": message.author.name,
"global_name": message.author.global_name,
"author_dpname": message.author.display_name,
"author_nick": None if message.author.nick is None else message.author.nick,
"member_type": member_type,
#SRV INFO
"server_id": message.author.guild.id,
"server_name": message.author.guild.name,
#CH INFO
"channel_id": message.channel.id,
"channel_name": message.channel.name,
#MSG context
"message_id": message.id,
"message_type": message.type,
"message_content": message.content,
"message_embeds": message.embeds,
"message_attachments": message.attachments,
}
print(f"| {data['server_name']} | {data['channel_name']} | [{data['author_name']}] [{member_type}] => | {data['author_nick']} |: {message.content}")
if message.content.startswith(bot.command_prefix):
await bot.process_commands(message)
return
########################
## We have user basic start bot, if you have your bot activation you can make
## I example the activation with Tor check the modules at top as you need
########################
connector = ProxyConnector.from_url("socks5://127.0.0.1:9050")
session = aiohttp.ClientSession(connector=connector)
bot.http._HTTPClient__session = session ### This is for proxt connect # this line to skip over proxy
bot.run(BOTTOKEN, reconnect=True)