コード例 #1
0
    void sendMessage(string message)
    {
        var data = new PostMessageData
        {
            token      = _token,
            channel    = _channel,
            text       = message,
            parse      = string.Empty,
            link_names = string.Empty,
            username   = string.Empty,
            icon_url   = string.Empty,
            icon_emoji = string.Empty
        };

        var routine = SlackAPI.PostMessage(data);

        StartCoroutine(routine);

        //var wsdata = new wsPostMessageData
        //{
        //    id = "1",
        //    type = "message",
        //    channel = "D4WNU3BK7", //@haruka  "C4WNTPLQM", //random
        //    text = message
        //};

        //WebSocketConnectionViaSlack.instance.ws.Send(JsonUtility.ToJson(wsdata));
    }
コード例 #2
0
        void UploadToSlack(string fileName, byte[] bytes)
        {
            var data = new SlackAPI.UploadData {
                token           = slackApiToken,
                filename        = fileName,
                filedata        = bytes,
                title           = "VRStudies-VRxNet",
                initial_comment = "VR空間で記念撮影!! - " + System.DateTime.Now.ToString("yyyy/MM/dd-HH:mm:ss"),
                channels        = "#general",
            };

            var routine = SlackAPI.Upload(data);

            StartCoroutine(routine);
        }
コード例 #3
0
    void getMessage()
    {
        var data = new GetMessageData
        {
            token     = _token,
            channel   = _channel,
            latest    = _latest,
            oldest    = _oldest,
            inclusive = _inclusive,
            count     = _count,
            unreads   = _unreads
        };

        var routine = SlackAPI.getMessage(data, showGetMessage, showErrorMessage);

        StartCoroutine(routine);
    }
コード例 #4
0
ファイル: SlackMember.cs プロジェクト: Luigifan/Luigibot
        public SlackMember(SlackAPI.User user)
        {
            Name = user.name;
            ID = user.id;

            RealName = user.profile.real_name;
            FirstName = user.profile.first_name;
            LastName = user.profile.last_name;

            if (user.is_admin) {
                if (user.is_owner)
                    Role = SlackRole.Owner;
                else
                    Role = SlackRole.Admin;
            } else if (user.IsSlackBot)
                Role = SlackRole.Bot;
            else
                Role = SlackRole.User;
        }
コード例 #5
0
        public BackgroundAlertService(
            SlackAPI slackAPI,
            IUserTimesRepository userPreferences,
            CredentialsRepository credentials,
            ISubscriberRepository subscriberRepository,
            MonthlyDataRepository monthlyDataRepository,
            UserRecordService userRecordService)
        {
            this.slackAPI              = slackAPI;
            this.userPreferences       = userPreferences;
            this.subscriberRepository  = subscriberRepository;
            this.monthlyDataRepository = monthlyDataRepository;
            this.userRecordService     = userRecordService;
            this.credentials           = credentials;
            currentTime = Utilities.CalculateSeconds(DateTime.Now);

            var time = DateTime.Now;

            firstOfMonth = time.Day == Constants.reportDay ? new DateTimeOffset(Utilities.NextReportDate(time)).ToUnixTimeSeconds() : new DateTimeOffset(Utilities.NextReportDate(time.AddMonths(1))).ToUnixTimeSeconds();
        }
コード例 #6
0
ファイル: SlackAPIRunner.cs プロジェクト: Pheema/UnitySandBox
    IEnumerator UploadRT()
    {
        yield return(new WaitForEndOfFrame());

        var uploadData = new UploadData
        {
            token           = token,
            channel         = channel,
            title           = "RenderTextureのアップロードテスト",
            filename        = "screenShot.png",
            initial_comment = "hoge"
        };

        Graphics.Blit(null, m_rtLarge);
        Graphics.Blit(m_rtLarge, m_rtSmall);
        var routine = SlackAPI.UploadRenderTexture(m_rtSmall, uploadData);

        StartCoroutine(routine);
        Debug.Log("Uploaded");
    }
コード例 #7
0
    IEnumerator CaptureAndUpload()
    {
        this.fileName   = DateTime.Now.ToString("yyyyMMddHHmmss");
        this.backupPath = backupDirPath + "/" + fileName + ".png";

        uploadData = new UploadData {
            token           = this.slackToken,
            title           = "Screenshot from Unity",
            initial_comment = this.slackComment,
            filename        = fileName,
            channels        = this.slackChannel
        };

#if UNITY_2017
        ScreenCapture.CaptureScreenshot(backupPath);
#else
        Application.CaptureScreenshot(backupPath);
#endif
        Debug.Log("[Capture to Slack] Export scrennshot at " + backupPath);

        while (true)
        {
            if (System.IO.File.Exists(backupPath))
            {
                break;
            }
            else
            {
                yield return(new WaitForSeconds(0.5f));
            }
        }

        screenshot = new Texture2D(1, 1);
        byte[] bytes;
        bytes = System.IO.File.ReadAllBytes(backupPath);
        screenshot.LoadImage(bytes);

        uploadData.screenShot = screenshot;

        yield return(EditorCoroutines.EditorCoroutines.StartCoroutine(SlackAPI.UploadScreenShot(uploadData, this.OnSuccess, this.OnError), this));
    }
コード例 #8
0
    void getConnection(string _token)
    {
        var routine = SlackAPI.getWebSocketURL(_token, connectionSuccess, connectionFailed);

        StartCoroutine(routine);
    }
コード例 #9
0
ファイル: ChatInterface.cs プロジェクト: seanfuture/Slack
        void AddMessage(SlackAPI.Message entry)
        {
            if (entry.user == null || entry.text == null) return;

            User u = adapter.GetUserInfo(entry.user);
            string username = u != null ? u.name : "Unknown";

            if (lastMessage != null && lastMessage.OwnerUsername.Equals(username) && entry.ts.Subtract(lastMessage.lastTimeStamp) < TimeSpan.FromMinutes(5))
                lastMessage.AppendMessage(entry.text, entry.ts);
            else
            {
                int lastY = 0;
                if (lastMessage != null) lastY = lastMessage.Bottom;

                lastMessage = new MessageEntry(this, username, adapter.GetUserImage(entry.user), entry.text, entry.ts, messages, timestamps);
                lastMessage.Location = new Point(0, lastY + 10);
                lastMessage.Width = chatContent.Size.Width-16; //TODO: Replace this with anchors and widths in the child panel.
                chatContent.Controls.Add(lastMessage);
            }

            chatContent.AutoScrollPosition = new Point(lastMessage.Left, chatContent.DisplayRectangle.Height);
        }
コード例 #10
0
ファイル: SlackChannel.cs プロジェクト: Luigifan/Luigibot
 public SlackChannel(SlackAPI.Channel channel)
 {
     RawChannel = channel;
     Name = channel.name;
     ID = channel.id;
 }
コード例 #11
0
 public void BlockScene()
 {
     OnSceneBlockedBy(TrelloAPI.Instance.UserName);
     TrelloAPI.Instance.CheckItemOn(checkItemId, Name + " - " + owner, true);
     SlackAPI.SendMessage("Scene " + Name + " blocked at branch " + branchName + " by " + owner);
 }
コード例 #12
0
 public void FreeScene()
 {
     TrelloAPI.Instance.CheckItemOn(checkItemId, Name, false);
     SlackAPI.SendMessage("Scene " + Name + " freed at branch " + branchName + " by " + owner);
     OnSceneFreed();
 }