Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Platform Agnostic Commands #1997

Draft
wants to merge 6 commits into
base: master
Choose a base branch
from
Draft
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ping dm
(might not work for whatsapp if jid contains Agent and Device)
yousefmansy1 committed Mar 15, 2023
commit cd08d586c5d9cdcd55ca133f8456e8ead7d3ecb6
7 changes: 4 additions & 3 deletions bridge/config/config.go
Original file line number Diff line number Diff line change
@@ -179,9 +179,10 @@ type Protocol struct {
}

type ChannelOptions struct {
Key string // irc, xmpp
WebhookURL string // discord
Topic string // zulip
Key string // irc, xmpp
WebhookURL string // discord
Topic string // zulip
WelcomeMessage string // all
}

type Bridge struct {
21 changes: 20 additions & 1 deletion gateway/command.go
Original file line number Diff line number Diff line change
@@ -27,8 +27,11 @@ func (r *Router) handleCommand(msg *config.Message) bool {

r.replyCmd(msg, help)
case "!ping":
r.logger.Debug("!pong:")
r.logger.Debug("!pong")
r.replyCmd(msg, "pong!")
case "!pingdm":
r.logger.Debug("!pongdm")
r.replyDM(msg, "pong!")
default:
return false
}
@@ -52,6 +55,22 @@ func (r *Router) replyCmd(msg *config.Message, str string) {
srcBridge.Send(reply)
}

func (r *Router) replyDM(msg *config.Message, str string) {
srcBridge := r.getBridge(msg.Account)

reply := config.Message{
Text: str,
Channel: msg.UserID,
Account: msg.Account,
Username: "",
UserID: "",
Protocol: msg.Protocol,
Gateway: msg.Gateway,
}

srcBridge.Send(reply)
}

func (r *Router) handleOptOutCmd(msg *config.Message, newStaus OptOutStatus) {
err := r.setOptOutStatus(msg.UserID, newStaus)