aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--telegram/client.go18
-rw-r--r--telegram/commands.go25
-rw-r--r--telegram/connect.go2
-rw-r--r--telegram/utils.go6
-rw-r--r--xmpp/component.go6
-rw-r--r--xmpp/extensions/extensions.go12
-rw-r--r--xmpp/handlers.go4
7 files changed, 37 insertions, 36 deletions
diff --git a/telegram/client.go b/telegram/client.go
index 9a98be7..7c3d904 100644
--- a/telegram/client.go
+++ b/telegram/client.go
@@ -122,15 +122,15 @@ func NewClient(conf config.TelegramConfig, jid string, component *xmpp.Component
}
return &Client{
- parameters: &parameters,
- resource: resource,
- xmpp: component,
- jid: jid,
- Session: session,
- resources: make(map[string]bool),
- content: &conf.Content,
- cache: cache.NewCache(),
- options: options,
+ parameters: &parameters,
+ resource: resource,
+ xmpp: component,
+ jid: jid,
+ Session: session,
+ resources: make(map[string]bool),
+ content: &conf.Content,
+ cache: cache.NewCache(),
+ options: options,
DelayedStatuses: make(map[int64]*DelayedStatus),
locks: clientLocks{
chatMessageLocks: make(map[int64]*sync.Mutex),
diff --git a/telegram/commands.go b/telegram/commands.go
index 7f97a6c..44d9df8 100644
--- a/telegram/commands.go
+++ b/telegram/commands.go
@@ -17,6 +17,7 @@ import (
const notEnoughArguments string = "Not enough arguments"
const telegramNotInitialized string = "Telegram connection is not initialized yet"
const notOnline string = "Not online"
+
var permissionsAdmin = client.ChatMemberStatusAdministrator{
CanBeEdited: true,
CanChangeInfo: true,
@@ -82,8 +83,8 @@ var chatCommands = map[string]command{
}
var transportConfigurationOptions = map[string]configurationOption{
- "timezone": configurationOption{"<timezone>", "adjust timezone for Telegram user statuses (example: +02:00)"},
- "keeponline": configurationOption{"<bool>", "always keep telegram session online and rely on jabber offline messages (example: true)"},
+ "timezone": configurationOption{"<timezone>", "adjust timezone for Telegram user statuses (example: +02:00)"},
+ "keeponline": configurationOption{"<bool>", "always keep telegram session online and rely on jabber offline messages (example: true)"},
"rawmessages": configurationOption{"<bool>", "do not add additional info (message id, origin etc.) to incoming messages (example: true)"},
}
@@ -144,13 +145,13 @@ func parseCommand(cmdline string) (string, []string) {
return bodyFields[0][1:], bodyFields[1:]
}
-func rawCmdArguments(cmdline string, start uint8) (string) {
+func rawCmdArguments(cmdline string, start uint8) string {
var state uint
// /cmd ababa galamaga
// 01 2 3 45
- startState := uint(3 + 2 * start)
+ startState := uint(3 + 2*start)
for i, r := range cmdline {
- isOdd := state % 2 == 1
+ isOdd := state%2 == 1
isSpace := unicode.IsSpace(r)
if (!isOdd && !isSpace) || (isOdd && isSpace) {
state += 1
@@ -611,7 +612,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
ChatId: chatID,
MemberId: &client.MessageSenderUser{UserId: contact.Id},
- Status: &client.ChatMemberStatusRestricted{
+ Status: &client.ChatMemberStatusRestricted{
IsMember: true,
RestrictedUntilDate: c.formatBantime(hours),
Permissions: &permissionsReadonly,
@@ -634,7 +635,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
ChatId: chatID,
MemberId: &client.MessageSenderUser{UserId: contact.Id},
- Status: &client.ChatMemberStatusRestricted{
+ Status: &client.ChatMemberStatusRestricted{
IsMember: true,
RestrictedUntilDate: 0,
Permissions: &permissionsMember,
@@ -663,7 +664,7 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
- ChatId: chatID,
+ ChatId: chatID,
MemberId: &client.MessageSenderUser{UserId: contact.Id},
Status: &client.ChatMemberStatusBanned{
BannedUntilDate: c.formatBantime(hours),
@@ -684,9 +685,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
- ChatId: chatID,
+ ChatId: chatID,
MemberId: &client.MessageSenderUser{UserId: contact.Id},
- Status: &client.ChatMemberStatusMember{},
+ Status: &client.ChatMemberStatusMember{},
})
if err != nil {
return err.Error(), true
@@ -710,9 +711,9 @@ func (c *Client) ProcessChatCommand(chatID int64, cmdline string) (string, bool)
}
_, err = c.client.SetChatMemberStatus(&client.SetChatMemberStatusRequest{
- ChatId: chatID,
+ ChatId: chatID,
MemberId: &client.MessageSenderUser{UserId: contact.Id},
- Status: &status,
+ Status: &status,
})
if err != nil {
return err.Error(), true
diff --git a/telegram/connect.go b/telegram/connect.go
index 94154d8..a4dfa37 100644
--- a/telegram/connect.go
+++ b/telegram/connect.go
@@ -134,7 +134,7 @@ func (c *Client) Connect(resource string) error {
go func() {
_, err = c.client.GetChats(&client.GetChatsRequest{
- Limit: chatsLimit,
+ Limit: chatsLimit,
})
if err != nil {
log.Errorf("Could not retrieve chats: %v", err)
diff --git a/telegram/utils.go b/telegram/utils.go
index a0e8147..c816c24 100644
--- a/telegram/utils.go
+++ b/telegram/utils.go
@@ -212,7 +212,7 @@ func (c *Client) ProcessStatusUpdate(chatID int64, status string, show string, o
c.cache.SetStatus(chatID, show, status)
- newArgs := []args.V {
+ newArgs := []args.V{
gateway.SPFrom(strconv.FormatInt(chatID, 10)),
gateway.SPShow(show),
gateway.SPStatus(status),
@@ -331,7 +331,7 @@ func (c *Client) formatForward(fwd *client.MessageForwardInfo) string {
if originChat.AuthorSignature != "" {
signature = fmt.Sprintf(" (%s)", originChat.AuthorSignature)
}
- return c.formatContact(originChat.SenderChatId)+signature
+ return c.formatContact(originChat.SenderChatId) + signature
case client.TypeMessageForwardOriginHiddenUser:
originUser := fwd.Origin.(*client.MessageForwardOriginHiddenUser)
return originUser.SenderName
@@ -341,7 +341,7 @@ func (c *Client) formatForward(fwd *client.MessageForwardInfo) string {
if channel.AuthorSignature != "" {
signature = fmt.Sprintf(" (%s)", channel.AuthorSignature)
}
- return c.formatContact(channel.ChatId)+signature
+ return c.formatContact(channel.ChatId) + signature
case client.TypeMessageForwardOriginMessageImport:
originImport := fwd.Origin.(*client.MessageForwardOriginMessageImport)
return originImport.SenderName
diff --git a/xmpp/component.go b/xmpp/component.go
index e22b221..961761b 100644
--- a/xmpp/component.go
+++ b/xmpp/component.go
@@ -37,9 +37,9 @@ func NewComponent(conf config.XMPPConfig, tc config.TelegramConfig) (*xmpp.Strea
Address: conf.Host + ":" + conf.Port,
Domain: conf.Jid,
},
- Domain: conf.Jid,
- Secret: conf.Password,
- Name: "telegabber",
+ Domain: conf.Jid,
+ Secret: conf.Password,
+ Name: "telegabber",
}
router := xmpp.NewRouter()
diff --git a/xmpp/extensions/extensions.go b/xmpp/extensions/extensions.go
index ea00008..284dd91 100644
--- a/xmpp/extensions/extensions.go
+++ b/xmpp/extensions/extensions.go
@@ -26,12 +26,12 @@ type PresenceXVCardUpdatePhoto struct {
// IqVcardTemp is from XEP-0054
type IqVcardTemp struct {
- XMLName xml.Name `xml:"vcard-temp vCard"`
- Fn IqVcardFn
- Nickname IqVcardNickname
- N IqVcardN
- Tel IqVcardTel
- Photo IqVcardPhoto
+ XMLName xml.Name `xml:"vcard-temp vCard"`
+ Fn IqVcardFn
+ Nickname IqVcardNickname
+ N IqVcardN
+ Tel IqVcardTel
+ Photo IqVcardPhoto
ResultSet *stanza.ResultSet `xml:"set,omitempty"`
}
diff --git a/xmpp/handlers.go b/xmpp/handlers.go
index d14fd31..bb80bb0 100644
--- a/xmpp/handlers.go
+++ b/xmpp/handlers.go
@@ -305,8 +305,8 @@ func handleGetDiscoInfo(s xmpp.Sender, iq *stanza.IQ) {
answer, err := stanza.NewIQ(stanza.Attrs{
Type: stanza.IQTypeResult,
From: iq.To,
- To: iq.From,
- Id: iq.Id,
+ To: iq.From,
+ Id: iq.Id,
Lang: "en",
})
if err != nil {