Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Ash
Discord Bot
Commits
36b8c373
Commit
36b8c373
authored
Aug 10, 2019
by
Tom Almeida
Browse files
Let's actually stop people from doing dodgy things with cowsay
parent
36b4d635
Changes
1
Show whitespace changes
Inline
Side-by-side
src/main.rs
View file @
36b8c373
...
...
@@ -74,8 +74,7 @@ impl EventHandler for Handler {
}
_
=>
{}
}
}
if
msg
.content
.starts_with
(
"!move"
)
{
}
else
if
msg
.content
.starts_with
(
"!move"
)
{
let
mut
iter
=
msg
.content
.chars
();
iter
.by_ref
()
.nth
(
5
);
let
topic
=
iter
.as_str
();
...
...
@@ -93,8 +92,7 @@ impl EventHandler for Handler {
if
let
Err
(
why
)
=
msg
.channel_id
.say
(
&
ctx
.http
,
"I hope you're not having a motion. You may have wanted to !move something instead."
)
{
println!
(
"Error sending message: {:?}"
,
why
);
}
}
if
msg
.content
.starts_with
(
"!poll"
)
{
}
else
if
msg
.content
.starts_with
(
"!poll"
)
{
let
mut
iter
=
msg
.content
.chars
();
iter
.by_ref
()
.nth
(
5
);
let
topic
=
iter
.as_str
();
...
...
@@ -163,11 +161,13 @@ impl EventHandler for Handler {
println!
(
"Error deleting motion prompt: {:?}"
,
why
);
}
}
else
if
msg
.content
.starts_with
(
"!cowsay"
)
{
let
mut
iter
=
msg
.content
.chars
();
iter
.by_ref
()
.nth
(
7
);
let
text
=
iter
.as_str
();
let
mut
text
=
msg
.content
.split_at
(
7
)
.1
.to_owned
();
text
.escape_default
();
// Guess what buddy! You definitely are passing a string to cowsay
text
.insert
(
0
,
'\''
);
text
.insert
(
text
.len
(),
'\''
);
let
output
=
std
::
process
::
Command
::
new
(
"cowsay"
)
.arg
(
text
.escape_default
()
)
.arg
(
text
)
.output
()
.expect
(
"failed to execute cowsay"
);
let
mut
message
=
MessageBuilder
::
new
();
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment