Example #1
0
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            var Instance = new Slack();
            string token="";
            bool success ;
            Instance.OnEvent += Instance_OnEvent;
            do
            {
                if (File.Exists("token.txt"))
                    token = File.ReadAllText("token.txt");
                if (String.IsNullOrWhiteSpace(token))
                {
                    Console.WriteLine("Please obtain a Token, and paste it below:");
                    token = Console.ReadLine();
                    File.WriteAllText("token.txt", token);

                }
                success = Instance.Init(token);
                if (!success)
                    File.WriteAllText("token.txt", "");
            } while (!success);
            Instance.Connect();
            while (Instance.Connecting || Instance.Connected)
                Thread.Sleep(0);
            Console.WriteLine("===Disconnected===");
            Console.ReadKey();
        }
Example #2
0
        private static string SubstituteMarkup(string p, Slack instance)
        {
            return Regex.Replace(p, @"<([@#])(.*?)>", (match) =>
            {
                switch (match.Groups[1].Value)
                {
                    case "#":
                        var chan = instance.GetChannel(match.Groups[2].Value);
                        if (chan == null)
                            break;
                        return "#" + chan.Name;
                    case "@":
                        var user = instance.GetUser(match.Groups[2].Value);
                        if (user == null)
                            break;
                        return "@" + user.Name;

                }
                return match.Groups[0].Value;
            });
        }
Example #3
0
 public SlackJsonConverter(Slack slack)
 {
     // TODO: Complete member initialization
     this.slack = slack;
 }
Example #4
0
 public SlackJsonConverter(Slack slack)
 {
     this.slack = slack;
 }
Example #5
0
 public SlackJsonConverter(Slack slack)
 {
     // TODO: Complete member initialization
     this.slack = slack;
 }