Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
B
bridge thing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
random asynchronous nightmare distributor
bridge thing
Commits
dd9dead6
Commit
dd9dead6
authored
Jan 4, 2022
by
Ophestra
Browse files
Options
Downloads
Patches
Plain Diff
parse using mode "MarkdownV2", properly escape strings
parent
6ecaf724
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
discord.go
+3
-2
3 additions, 2 deletions
discord.go
go.sum
+0
-2
0 additions, 2 deletions
go.sum
telegram.go
+0
-1
0 additions, 1 deletion
telegram.go
with
3 additions
and
5 deletions
discord.go
+
3
−
2
View file @
dd9dead6
...
@@ -119,7 +119,6 @@ func discordHandleCreate(session *discordgo.Session, create *discordgo.MessageCr
...
@@ -119,7 +119,6 @@ func discordHandleCreate(session *discordgo.Session, create *discordgo.MessageCr
}
}
msg
:=
tgbotapi
.
NewMessage
(
int64
(
tc
.
ID
),
""
)
msg
:=
tgbotapi
.
NewMessage
(
int64
(
tc
.
ID
),
""
)
msg
.
ParseMode
=
"Markdown"
if
create
.
Message
.
Content
==
""
&&
len
(
create
.
Message
.
Attachments
)
==
0
{
if
create
.
Message
.
Content
==
""
&&
len
(
create
.
Message
.
Attachments
)
==
0
{
// FIXME: implement stickers after library supports it
// FIXME: implement stickers after library supports it
...
@@ -149,6 +148,9 @@ func discordHandleCreate(session *discordgo.Session, create *discordgo.MessageCr
...
@@ -149,6 +148,9 @@ func discordHandleCreate(session *discordgo.Session, create *discordgo.MessageCr
msg
.
Text
+=
fmt
.
Sprintf
(
"
\n
[Attachment %v](%s)"
,
i
,
attachment
.
URL
)
msg
.
Text
+=
fmt
.
Sprintf
(
"
\n
[Attachment %v](%s)"
,
i
,
attachment
.
URL
)
}
}
msg
.
ParseMode
=
"MarkdownV2"
msg
.
Text
=
strings
.
ReplaceAll
(
msg
.
Text
,
">"
,
"
\\
>"
)
if
m
,
err
:=
botAPI
.
Send
(
msg
);
err
!=
nil
{
if
m
,
err
:=
botAPI
.
Send
(
msg
);
err
!=
nil
{
log
.
Printf
(
"error relaying message %s, %s"
,
create
.
Message
.
ID
,
err
)
log
.
Printf
(
"error relaying message %s, %s"
,
create
.
Message
.
ID
,
err
)
return
return
...
@@ -192,7 +194,6 @@ func discordHandleUpdate(session *discordgo.Session, update *discordgo.MessageUp
...
@@ -192,7 +194,6 @@ func discordHandleUpdate(session *discordgo.Session, update *discordgo.MessageUp
}
}
edit
:=
tgbotapi
.
NewEditMessageText
(
int64
(
tc
.
ID
),
tid
,
discordMakeHeader
(
update
.
Message
.
Author
)
+
update
.
Message
.
Content
)
edit
:=
tgbotapi
.
NewEditMessageText
(
int64
(
tc
.
ID
),
tid
,
discordMakeHeader
(
update
.
Message
.
Author
)
+
update
.
Message
.
Content
)
edit
.
ParseMode
=
"Markdown"
if
_
,
err
:=
botAPI
.
Send
(
edit
);
err
!=
nil
{
if
_
,
err
:=
botAPI
.
Send
(
edit
);
err
!=
nil
{
log
.
Printf
(
"error relaying edit on message %s: %s"
,
update
.
Message
.
ID
,
err
)
log
.
Printf
(
"error relaying edit on message %s: %s"
,
update
.
Message
.
ID
,
err
)
return
return
...
...
This diff is collapsed.
Click to expand it.
go.sum
+
0
−
2
View file @
dd9dead6
...
@@ -4,8 +4,6 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
...
@@ -4,8 +4,6 @@ github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8
github.com/davecgh/go-spew
v1.1.0/go.mod h1:
J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew
v1.1.0/go.mod h1:
J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/go-telegram-bot-api/telegram-bot-api
v4.6.4+incompatible h1:
2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
github.com/go-telegram-bot-api/telegram-bot-api
v4.6.4+incompatible h1:
2cauKuaELYAEARXRkq2LrJ0yDDv1rW7+wrTEdVL3uaU=
github.com/go-telegram-bot-api/telegram-bot-api
v4.6.4+incompatible/go.mod h1:
qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
github.com/go-telegram-bot-api/telegram-bot-api
v4.6.4+incompatible/go.mod h1:
qf9acutJ8cwBUhm1bqgz6Bei9/C/c93FPDljKWwsOgM=
github.com/go-telegram-bot-api/telegram-bot-api/v5
v5.0.0-rc1 h1:
Mr8jIV7wDfLw5Fw6BPupm0aduTFdLjhI3wFuIIZKvO4=
github.com/go-telegram-bot-api/telegram-bot-api/v5
v5.0.0-rc1/go.mod h1:
2s/IzRcxCszyNh760IjJiqoYHTnifk8ZeNYL33z8Pww=
github.com/gorilla/websocket
v1.4.0 h1:
WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket
v1.4.0 h1:
WDFjx/TMzVgy9VdMMQi2K2Emtwi2QcUQsztZ/zLaH/Q=
github.com/gorilla/websocket
v1.4.0/go.mod h1:
E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/gorilla/websocket
v1.4.0/go.mod h1:
E7qHFY5m1UJ88s3WnNqhKjPHQ0heANvMoAMk2YaljkQ=
github.com/pelletier/go-toml/v2
v2.0.0-beta.3 h1:
PNCTU4naEJ8mKal97P3A2qDU74QRQGlv4FXiL1XDqi4=
github.com/pelletier/go-toml/v2
v2.0.0-beta.3 h1:
PNCTU4naEJ8mKal97P3A2qDU74QRQGlv4FXiL1XDqi4=
...
...
This diff is collapsed.
Click to expand it.
telegram.go
+
0
−
1
View file @
dd9dead6
...
@@ -392,7 +392,6 @@ func telegramCommand(update tgbotapi.Update) {
...
@@ -392,7 +392,6 @@ func telegramCommand(update tgbotapi.Update) {
switch
update
.
Message
.
Command
()
{
switch
update
.
Message
.
Command
()
{
case
"start"
:
case
"start"
:
if
update
.
Message
.
Chat
.
ID
==
int64
(
update
.
Message
.
From
.
ID
)
{
if
update
.
Message
.
Chat
.
ID
==
int64
(
update
.
Message
.
From
.
ID
)
{
message
.
ParseMode
=
"Markdown"
message
.
Text
=
"Thanks for using BridgeThing!
\n
"
+
message
.
Text
=
"Thanks for using BridgeThing!
\n
"
+
"To find the ID of a Telegram chat, use /id
\n
"
+
"To find the ID of a Telegram chat, use /id
\n
"
+
"To get the invite URL, use /invite
\n
"
+
"To get the invite URL, use /invite
\n
"
+
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment