-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add event for when a gateway event is received from Discord
- Loading branch information
1 parent
03ba36f
commit 6b3af74
Showing
7 changed files
with
154 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
Copyright 2015 MCGalaxy | ||
Dual-licensed under the Educational Community License, Version 2.0 and | ||
the GNU General Public License, Version 3 (the "Licenses"); you may | ||
not use this file except in compliance with the Licenses. You may | ||
obtain a copy of the Licenses at | ||
https://opensource.org/license/ecl-2-0/ | ||
https://www.gnu.org/licenses/gpl-3.0.html | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the Licenses are distributed on an "AS IS" | ||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
or implied. See the Licenses for the specific language governing | ||
permissions and limitations under the Licenses. | ||
*/ | ||
using System; | ||
using MCGalaxy.Config; | ||
using MCGalaxy.Events; | ||
|
||
namespace MCGalaxy.Modules.Relay.Discord | ||
{ | ||
public delegate void OnSendingWhoEmbed(DiscordBot bot, RelayUser user, ref ChannelSendEmbed embed); | ||
/// <summary> Called when sending an embed response to a .who message from Discord </summary> | ||
public sealed class OnSendingWhoEmbedEvent : IEvent<OnSendingWhoEmbed> | ||
{ | ||
public static void Call(DiscordBot bot, RelayUser user, ref ChannelSendEmbed embed) { | ||
IEvent<OnSendingWhoEmbed>[] items = handlers.Items; | ||
for (int i = 0; i < items.Length; i++) | ||
{ | ||
try { | ||
items[i].method(bot, user, ref embed); | ||
} catch (Exception ex) { | ||
LogHandlerException(ex, items[i]); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public delegate void OnGatewayEventReceived(DiscordBot bot, string eventName, JsonObject data); | ||
/// <summary> Called when a gateway event has been received from Discord </summary> | ||
public sealed class OnGatewayEventReceivedEvent : IEvent<OnGatewayEventReceived> | ||
{ | ||
public static void Call(DiscordBot bot, string eventName, JsonObject data) { | ||
IEvent<OnGatewayEventReceived>[] items = handlers.Items; | ||
for (int i = 0; i < items.Length; i++) | ||
{ | ||
try { | ||
items[i].method(bot, eventName, data); | ||
} catch (Exception ex) { | ||
LogHandlerException(ex, items[i]); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/* | ||
Copyright 2011 MCForge | ||
Dual-licensed under the Educational Community License, Version 2.0 and | ||
the GNU General Public License, Version 3 (the "Licenses"); you may | ||
not use this file except in compliance with the Licenses. You may | ||
obtain a copy of the Licenses at | ||
https://opensource.org/license/ecl-2-0/ | ||
https://www.gnu.org/licenses/gpl-3.0.html | ||
Unless required by applicable law or agreed to in writing, | ||
software distributed under the Licenses are distributed on an "AS IS" | ||
BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
or implied. See the Licenses for the specific language governing | ||
permissions and limitations under the Licenses. | ||
*/ | ||
using System; | ||
using MCGalaxy.Events; | ||
|
||
namespace MCGalaxy.Modules.Relay | ||
{ | ||
public delegate void OnDirectMessage(RelayBot bot, string channel, RelayUser user, string message, ref bool cancel); | ||
/// <summary> Called when an external communication service user sends a message directly to the relay bot </summary> | ||
public sealed class OnDirectMessageEvent : IEvent<OnDirectMessage> | ||
{ | ||
public static void Call(RelayBot bot, string channel, RelayUser user, string message, ref bool cancel) { | ||
IEvent<OnDirectMessage>[] items = handlers.Items; | ||
for (int i = 0; i < items.Length; i++) | ||
{ | ||
try { | ||
items[i].method(bot, channel, user, message, ref cancel); | ||
} catch (Exception ex) { | ||
LogHandlerException(ex, items[i]); | ||
} | ||
} | ||
} | ||
} | ||
|
||
public delegate void OnChannelMessage(RelayBot bot, string channel, RelayUser user, string message, ref bool cancel); | ||
/// <summary> Called when an external communication service user sends a message to the given channel </summary> | ||
public sealed class OnChannelMessageEvent : IEvent<OnChannelMessage> | ||
{ | ||
public static void Call(RelayBot bot, string channel, RelayUser user, string message, ref bool cancel) { | ||
IEvent<OnChannelMessage>[] items = handlers.Items; | ||
for (int i = 0; i < items.Length; i++) | ||
{ | ||
try { | ||
items[i].method(bot, channel, user, message, ref cancel); | ||
} catch (Exception ex) { | ||
LogHandlerException(ex, items[i]); | ||
} | ||
} | ||
} | ||
} | ||
} |