aboutsummaryrefslogtreecommitdiff
path: root/telegram
diff options
context:
space:
mode:
authorBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-08 23:25:58 +0300
committerBohdan Horbeshko <bodqhrohro@gmail.com>2022-02-08 23:25:58 +0300
commitec49d5d4124fec31d605d9242a3c21f183250902 (patch)
tree7a9a80f55101b40ee0f6f6923855f75d46bc9f28 /telegram
parentfe7346a530c8ac985f2a4a9edeeecc134f320a2f (diff)
gofmt
Diffstat (limited to 'telegram')
-rw-r--r--telegram/client.go18
-rw-r--r--telegram/commands.go25
-rw-r--r--telegram/connect.go2
-rw-r--r--telegram/utils.go6
4 files changed, 26 insertions, 25 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