Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
github.com/go-chat-bot/bot
IRC, Slack & Telegram bot written in Go using go-ircevent for IRC connectivity, nlopes/slack for Slack and Syfaro/telegram-bot-api for Telegram.
Please see the plugins repository for a complete list of plugins.
You can also write your own, it's really simple.
This project uses the new Go 1.11 modules if you have Go 1.11 installed, just clone the project and follow the instructions bellow, when you build Go will automatically download all dependencies.
To test the bot, use the debug console app.
go get github.com/go-chat-bot/bot
go build ./...
cd debug
go build
./debug
!help
to see the list of available commandsdebug/main.go
import listTo deploy your go-bot to Slack, you need to:
github.com/go-chat-bot/bot/slack
slack.Run(token)
Here is a full example reading the Slack token from the SLACK_TOKEN
env var:
package main
import (
"os"
"github.com/go-chat-bot/bot/slack"
_ "github.com/go-chat-bot/plugins/catfacts"
_ "github.com/go-chat-bot/plugins/catgif"
_ "github.com/go-chat-bot/plugins/chucknorris"
// Import all the commands you wish to use
)
func main() {
slack.Run(os.Getenv("SLACK_TOKEN"))
}
To deploy your own go-bot to IRC, you need to:
github.com/go-chat-bot/bot/irc
irc.Run(config)
Here is a full example:
package main
import (
"github.com/go-chat-bot/bot/irc"
_ "github.com/go-chat-bot/plugins/catfacts"
_ "github.com/go-chat-bot/plugins/catgif"
_ "github.com/go-chat-bot/plugins/chucknorris"
// Import all the commands you wish to use
"os"
"strings"
)
func main() {
irc.Run(&irc.Config{
Server: os.Getenv("IRC_SERVER"),
Channels: strings.Split(os.Getenv("IRC_CHANNELS"), ","),
User: os.Getenv("IRC_USER"),
Nick: os.Getenv("IRC_NICK"),
Password: os.Getenv("IRC_PASSWORD"),
UseTLS: true,
Debug: os.Getenv("DEBUG") != "",})
}
To join channels with passwords just put the password after the channel name separated by a space:
Channels: []string{"#mychannel mypassword", "#go-bot"}
To deploy your go-bot to Telegram, you need to:
github.com/go-chat-bot/bot/telegram
telegram.Run(token, debug)
Here is a full example reading the telegram token from the TELEGRAM_TOKEN
env var:
package main
import (
"os"
"github.com/go-chat-bot/bot/telegram"
_ "github.com/go-chat-bot/plugins/catfacts"
_ "github.com/go-chat-bot/plugins/catgif"
_ "github.com/go-chat-bot/plugins/chucknorris"
// Import all the commands you wish to use
)
func main() {
telegram.Run(os.Getenv("TELEGRAM_TOKEN"), os.Getenv("DEBUG") != "")
}
To deploy your go-bot to Rocket.chat, you need to:
github.com/go-chat-bot/bot/rocket
rocket.Run(config)
Here is a full example:
package main
import (
"os"
"github.com/go-chat-bot/bot/rocket"
_ "github.com/go-chat-bot/plugins/godoc"
_ "github.com/go-chat-bot/plugins/catfacts"
_ "github.com/go-chat-bot/plugins/catgif"
_ "github.com/go-chat-bot/plugins/chucknorris"
)
func main() {
config := &rocket.Config{
Server: os.Getenv("ROCKET_SERVER"),
Port: os.Getenv("ROCKET_PORT"),
User: os.Getenv("ROCKET_USER"),
Email: os.Getenv("ROCKET_EMAIL"),
Password: os.Getenv("ROCKET_PASSWORD"),
UseTLS: false,
Debug: os.Getenv("DEBUG") != "",
}
rocket.Run(config)
}
To deploy your go-bot to Google Chat (also known as Hangouts Chat, not plain Hangouts) you will first need to follow documentation to setup pub/sub project in Google Cloud. This will enable your bot to receive messages even when it is behind a firewall.
Condensed, the steps you will need to take are as follows:
Config.SubscriptionName should be unique for each environment or you'll not process messages correctly. If you encounter issues make sure your credentials are correct and permissions for topics/queues are set up correctly.
Config.WelcomeMessage is sent each time the bot joins a new room or private chat.
Full example is here:
package main
import (
"os"
"github.com/go-chat-bot/bot/google-chat"
_ "github.com/go-chat-bot/plugins/godoc"
_ "github.com/go-chat-bot/plugins/catfacts"
_ "github.com/go-chat-bot/plugins/catgif"
_ "github.com/go-chat-bot/plugins/chucknorris"
)
func main() {
googlechat.Run(&googlechat.Config{
PubSubProject: os.Getenv("HANGOUTS_PROJECT"),
TopicName: os.Getenv("HANGOUTS_TOPIC"),
SubscriptionName: os.Getenv("HANGOUTS_SUB"),
WelcomeMessage: os.Getenv("HANGOUTS_WELCOME"),
}
To see an example project on how to deploy your bot, please see my own configuration:
FAQs
Unknown package
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.