From 6b1efee8e212a7c1c0fadffec547e663155a062a Mon Sep 17 00:00:00 2001 From: Fijxu Date: Mon, 19 Aug 2024 13:40:29 -0400 Subject: [PATCH] Init --- shard.yml | 9 ++++++++ spec/spec_helper.cr | 2 ++ spec/twitch-irc-crystal_spec.cr | 9 ++++++++ src/twitch-irc-crystal.cr | 38 +++++++++++++++++++++++++++++++++ 4 files changed, 58 insertions(+) create mode 100644 shard.yml create mode 100644 spec/spec_helper.cr create mode 100644 spec/twitch-irc-crystal_spec.cr create mode 100644 src/twitch-irc-crystal.cr diff --git a/shard.yml b/shard.yml new file mode 100644 index 0000000..9833c09 --- /dev/null +++ b/shard.yml @@ -0,0 +1,9 @@ +name: twitch-irc-crystal +version: 0.1.0 + +authors: + - Fijxu + +crystal: '>= 1.13.0' + +license: MIT diff --git a/spec/spec_helper.cr b/spec/spec_helper.cr new file mode 100644 index 0000000..844827d --- /dev/null +++ b/spec/spec_helper.cr @@ -0,0 +1,2 @@ +require "spec" +require "../src/twitch-irc-crystal" diff --git a/spec/twitch-irc-crystal_spec.cr b/spec/twitch-irc-crystal_spec.cr new file mode 100644 index 0000000..9e11415 --- /dev/null +++ b/spec/twitch-irc-crystal_spec.cr @@ -0,0 +1,9 @@ +require "./spec_helper" + +describe Twitch::Irc::Crystal do + # TODO: Write tests + + it "works" do + false.should eq(true) + end +end diff --git a/src/twitch-irc-crystal.cr b/src/twitch-irc-crystal.cr new file mode 100644 index 0000000..739fe32 --- /dev/null +++ b/src/twitch-irc-crystal.cr @@ -0,0 +1,38 @@ +require "socket" + +module TwitchIRC + struct Client + @ip_addr : String + @port : String + @ssl : Bool | Nil + @client : TCPSocket + def initialize(@ip_addr, @port, @ssl) + @client = TCPSocket.new(@ip_addr, @port) + end + + def listen + spawn do + loop do + puts @client.gets + end + end + sleep + end + + def send_raw(msg : String) + @client << "#{msg}" + end + + def send(msg : String) + @client << "#{msg}\n" + end + + def send_privmsg(msg : String, channel : String) + @client << "PRIVMSG ##{channel} :#{msg}\n" + end + + def capabilities + self.send("CAP REQ :twitch.tv/membership twitch.tv/tags twitch.tv/commands") + end + end +end