forked from lug/matterbridge
		
	Remove WebhookURL support (discord)
This commit is contained in:
		| @@ -43,14 +43,7 @@ func New(cfg *bridge.Config) bridge.Bridger { | |||||||
| 	b.nickMemberMap = make(map[string]*discordgo.Member) | 	b.nickMemberMap = make(map[string]*discordgo.Member) | ||||||
| 	b.channelInfoMap = make(map[string]*config.ChannelInfo) | 	b.channelInfoMap = make(map[string]*config.ChannelInfo) | ||||||
|  |  | ||||||
| 	// If WebhookURL is set to anything, we assume preference for autoWebhooks | 	b.useAutoWebhooks = b.GetBool("AutoWebhooks") | ||||||
| 	// |  | ||||||
| 	// Legacy note: WebhookURL used to have an actual webhook URL that we would edit, |  | ||||||
| 	// but we stopped doing that due to Discord making rate limits more aggressive. |  | ||||||
| 	// |  | ||||||
| 	// We're keeping the same setting for now, and we will late deprecate this setting |  | ||||||
| 	// in favour of a new setting, something like "AutoWebhooks=true" |  | ||||||
| 	b.useAutoWebhooks = b.GetString("WebhookURL") != "" |  | ||||||
| 	if b.useAutoWebhooks { | 	if b.useAutoWebhooks { | ||||||
| 		b.Log.Debug("Using automatic webhooks") | 		b.Log.Debug("Using automatic webhooks") | ||||||
| 	} | 	} | ||||||
| @@ -147,6 +140,19 @@ func (b *Bdiscord) Connect() error { | |||||||
| 		return err | 		return err | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|  | 	// Legacy note: WebhookURL used to have an actual webhook URL that we would edit, | ||||||
|  | 	// but we stopped doing that due to Discord making rate limits more aggressive. | ||||||
|  | 	// | ||||||
|  | 	// Even older: the same WebhookURL used to be used by every channel, which is usually unexpected. | ||||||
|  | 	// This is no longer possible. | ||||||
|  | 	if b.GetString("WebhookURL") != "" { | ||||||
|  | 		message := "The global WebhookURL setting has been removed. " | ||||||
|  | 		message += "You can get similar \"webhook editing\" behaviour by replacing this line with `AutoWebhooks=true`. " | ||||||
|  | 		message += "If you rely on the old-OLD (non-editing) behaviour, can move the WebhookURL to specific channel sections." | ||||||
|  | 		b.Log.Errorln(message) | ||||||
|  | 		return fmt.Errorf("use of removed WebhookURL setting") | ||||||
|  | 	} | ||||||
|  |  | ||||||
| 	// Initialise webhook management | 	// Initialise webhook management | ||||||
| 	b.transmitter = transmitter.New(b.c, b.guildID, "matterbridge", b.useAutoWebhooks) | 	b.transmitter = transmitter.New(b.c, b.guildID, "matterbridge", b.useAutoWebhooks) | ||||||
| 	b.transmitter.Log = b.Log | 	b.transmitter.Log = b.Log | ||||||
|   | |||||||
| @@ -111,7 +111,7 @@ func (t *Transmitter) HasWebhook(id string) bool { | |||||||
| } | } | ||||||
|  |  | ||||||
| // AddWebhook allows you to register a channel's webhook with the transmitter. | // AddWebhook allows you to register a channel's webhook with the transmitter. | ||||||
| func (t *Transmitter) AddWebhook(channelID string, webhook *discordgo.Webhook) (replaced bool) { | func (t *Transmitter) AddWebhook(channelID string, webhook *discordgo.Webhook) bool { | ||||||
| 	t.Log.Debugf("Manually added webhook %#v to channel %#v", webhook.ID, channelID) | 	t.Log.Debugf("Manually added webhook %#v to channel %#v", webhook.ID, channelID) | ||||||
| 	t.mutex.Lock() | 	t.mutex.Lock() | ||||||
| 	defer t.mutex.Unlock() | 	defer t.mutex.Unlock() | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Qais Patankar
					Qais Patankar