{"id":17370126,"url":"https://github.com/gianarb/go-irc","last_synced_at":"2025-04-15T03:32:08.488Z","repository":{"id":19987946,"uuid":"23255165","full_name":"gianarb/go-irc","owner":"gianarb","description":"Go IRC low level library","archived":false,"fork":false,"pushed_at":"2020-11-13T15:09:20.000Z","size":9,"stargazers_count":21,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-01T08:42:23.982Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://gianarb.it/blog/chatops-create-your-own-irc-bot-in-go","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gianarb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2014-08-23T12:20:49.000Z","updated_at":"2022-07-14T07:07:05.000Z","dependencies_parsed_at":"2022-07-23T04:32:17.499Z","dependency_job_id":null,"html_url":"https://github.com/gianarb/go-irc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Fgo-irc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Fgo-irc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Fgo-irc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gianarb%2Fgo-irc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gianarb","download_url":"https://codeload.github.com/gianarb/go-irc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223657852,"owners_count":17181024,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-16T00:23:38.370Z","updated_at":"2024-11-08T09:04:26.743Z","avatar_url":"https://github.com/gianarb.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"## go-irc\nLibrary to interact with IRC.\n\n### PACKAGE DOCUMENTATION\n```go\npackage irc\n```\n```go\ntype Bot struct {\n    // contains filtered or unexported fields\n}\n```\nImplement BotInterface \n```go\ntype BotInterface interface {\n    Connect(conn net.Conn, err error)\n    Send(string)\n}\n```\nBot struct contains : host, nickname, user, channel ...\n\n```go\nfunc NewBot(proxy string, server string, nick string, user string, channel string, pass string) *Bot\n```\nReturns new Bot\n\n\nBot Methods\n* ``` func (bot *Bot) Connect() (conn net.Conn, err error)``` : Connect bot to irc server\n* ``` func (bot *Bot) Send(command string) ``` : Send message to channel after connection\n\n```\ntype Message struct {\n    Draft string\n}\n```\nBest practice for managing simple update of lib\n\n### Use Case\n```go\npackage main\n\nimport (\n    \"bufio\"\n    \"fmt\"\n    irc \"go.gianarb.it/irc\"\n    parser \"gopkg.in/sorcix/irc.v2\"\n    \"log\"\n    \"net/textproto\"\n    \"time\"\n)\n\nfunc main() {\n    // don't forget to `go get \"gopkg.in/sorcix/irc.v2\"`\n    // and to run Tor\n    bot := irc.NewBot(\n        \"127.0.0.1:9050\",\n        \"freenodeok2gncmy.onion:6667\",\n        \"MySuperBot\",\n        \"MySuperBot\",\n        \"#go-nuts\",\n        \"\",\n    )\n    conn, _ := bot.Connect()\n    defer conn.Close()\n    verbose := false\n    reader := bufio.NewReader(conn)\n    tp := textproto.NewReader(reader)\n    for {\n        line, err := tp.ReadLine()\n        if err != nil {\n            log.Fatal(\"unable to connect to IRC server \", err)\n        }\n        message := parser.ParseMessage(line)\n        if verbose {\n            fmt.Printf(\"%v \\n\", message)\n        }\n\n        if message.Command == \"PING\" {\n            bot.Send(fmt.Sprint(\"PONG %d\", time.Now().UnixNano()))\n        }\n\n        if message.Command == \"PRIVMSG\" {\n            if message.Params[0] == bot.Nick {\n                // this private message is of the bot\n                msg := message.Params[1]\n                // fmt.Println(msg)\n                // Do Something with this msg\n            }\n        }\n    }\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianarb%2Fgo-irc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgianarb%2Fgo-irc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgianarb%2Fgo-irc/lists"}