This repository was archived by the owner on May 25, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed
Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 1+ import discord
2+ from discord .ext import commands
3+
4+ from .cog import RiftGun
5+
6+
7+ class OneWayRiftGun (RiftGun ):
8+ """The rift gun, but one-way instead."""
9+
10+ @commands .Cog .listener (name = "on_message" )
11+ async def message (self , message : discord .Message ):
12+ context : commands .Context = await self .bot .get_context (message )
13+ if message .author == self .bot .user :
14+ return # only ignore the current bot to prevent loops.
15+ elif context .valid :
16+ return
17+
18+ sources = {}
19+ targets = {}
20+ sid = message .channel .id
21+
22+ for target , source in self .data .items ():
23+ sources [int (source ["source" ])] = int (target )
24+ targets [int (target )] = int (source ["source" ])
25+
26+ if sid in targets .keys ():
27+ channel = self .bot .get_channel (targets [sid ])
28+ attachments = [a .to_file () for a in message .attachments ]
29+ await channel .send (f"**{ message .author } :** { message .clean_content } " [:2000 ],
30+ embed = message .embeds [0 ] if message .embeds else None ,
31+ files = attachments or None )
32+
33+
34+ def setup (bot : commands .Bot ):
35+ if bot .get_cog ("RiftGun" ):
36+ bot .unload_extension ("riftgun" )
37+ bot .add_cog (OneWayRiftGun (bot ))
You can’t perform that action at this time.
0 commit comments