/f6688b53223fe76fb0
Created 7 months ago...
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 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
import discord
import aiohttp
import lxml.html
from lxml import html
from discord import reaction
from discord.ext.commands import bot
from discord.ext import commands, tasks
intents = discord.Intents.default()
intents.message_content = True
client = discord.Client(intents=intents)
bot = commands.Bot(command_prefix='!', intents=intents)
@client.event
async def on_ready() -> None:
print(f'{client.user} is now running!')
@client.event
async def on_message(message):
if str(message.channel) == "💵-bank-robber-nemesis":
if '<@&1218616329775616090>' not in message.content:
await message.delete()
if str(message.channel) == "🍯-hive-outpost-nemesis":
if '<@&1218616489268084846>' not in message.content:
await message.delete()
if str(message.channel) == "🔴-nemesis-reports":
if "<@&1218617131176955904>" not in message.content:
if "<@&1246779271230521355>" not in message.content:
await message.delete()
if str(message.channel) == "🟡-archfoe-reports":
if '<@&1218617209807573063>' not in message.content:
await message.delete()
if str(message.channel) == "🟢-bane-reports":
if '<@&1218617277692383303>' not in message.content:
await message.delete()
if str(message.channel) == "🐴-rare-bestiary":
if '<@&1245487719207927871>' not in message.content:
await message.delete()
if str(message.channel) == "🧙-ferumbras":
if '<@&1220310657413550150>' not in message.content:
await message.delete()
if str(message.channel) == "🔥-morgaroth":
if '<@&1220310824485126186>' not in message.content:
await message.delete()
if str(message.channel) == "💙-ghazbaran":
if '<@&1220310734173634621>' not in message.content:
await message.delete()
if str(message.channel) == "💔-orshabaal":
if '<@&1220310886825332776>' not in message.content:
await message.delete()
if str(message.channel) == "💜-morshabaal":
if '<@&1220310940080279622>' not in message.content:
await message.delete()
if str(message.channel) == "💚-abomination":
if '<@&1220311008653082696>' not in message.content:
await message.delete()
if (message.content.startswith('<@&1218617131176955904>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
if (message.content.startswith('<@&1246779271230521355>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
if (message.content.startswith('<@&1218616329775616090>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
if (message.content.startswith('<@&1218616489268084846>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
if (message.content.startswith('<@&1218617209807573063>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
if (message.content.startswith('<@&1218617277692383303>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
if (message.content.startswith('<@&1245487719207927871>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
if (message.content.startswith('<@&1220311008653082696>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
await message.add_reaction('🌐')
if (message.content.startswith('<@&1220310940080279622>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
await message.add_reaction('🌐')
if (message.content.startswith('<@&1220310886825332776>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
await message.add_reaction('🌐')
if (message.content.startswith('<@&1220310734173634621>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
await message.add_reaction('🌐')
if (message.content.startswith('<@&1220310824485126186>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
await message.add_reaction('🌐')
if (message.content.startswith('<@&1220310657413550150>')):
await message.add_reaction('🦵')
await message.add_reaction('👍')
await message.add_reaction('🌐')
if (message.content.startswith('!today')):
async with aiohttp.ClientSession() as session:
async with session.get(f'some site here') as r:
channel = client.get_channel(1245022140156088421) # replace with channel_id
if r.status == 200:
text = await r.text()
tr = html.fromstring(text)
# buyers = tr.xpath("tbody/tr/td/a/text()")
tables = tr.xpath("//table")
table = tr.xpath("//table")[0]
answer = "**TEXT**\n" if len(tables) >=2 else "TEXT\n"
for row in table.xpath(".//tbody//tr"):
cells = [cell.text_content() for cell in row.xpath(".//td")]
answer += f"{cells[0]}: {cells[1]}\n"
if len(tables) > 1:
table2 = tr.xpath("//table")[1]
answer += "TEXT\n"
for row in table2.xpath(".//tbody//tr"):
cells = [cell.text_content() for cell in row.xpath(".//td")]
answer += f"{cells[0]}: {cells[1]}\n"
await channel.send(answer)
else:
await channel.send("failed")
@client.event
async def on_reaction_add(reaction, user):
if client.user == user:
return # Ignore whatever the bot reacts to ; this event is triggered when the bot reacts as well
if user != reaction.message.author and reaction.emoji not in ('🦵','👍'):
await reaction.remove(user) # remove emoji if the reactor is not the author and emoji not in whitelisted emojis
if user == reaction.message.author:
await reaction.message.add_reaction(reaction.emoji) # bot reacts with same emoji that the author reacts with
if user == reaction.message.author and reaction.emoji in ('☠'):
await reaction.message.channel.create_thread(reaction.message.channel)