public static bool SendMessageCustomToken(String Channel, String Message, String Token) { APICaller apic = new APICaller(Token); bool returned = false; Dictionary<String, dynamic> Params = new Dictionary<string, dynamic>(); if (Token.Equals("someone")) { Token = "xoxp-5007212458-11027941589-11025314452-ac4fcf3c3b"; } else if (Token.Equals("timo")) { Token = "xoxb-5134150563-iZKW7CIodzRbffqVmFmz6m2S"; } else if (Token.Equals("lily")) { Token = "xoxb-7444634401-UTU2IHZE2kULUWu70hgKV0FA"; } if (Channel.StartsWith("C") || Channel.StartsWith("D")) { Params.Add("channel", Channel); Params.Add("text", Message); Params.Add("as_user", "true"); Params.Add("token", Token); returned = apic.CallMethodCustomToken("chat.postMessage", Params).Result["ok"]; } Console.WriteLine("Posted message: " + Message + " to Channel: " + Channel + " with return code: " + returned); return returned; }
public SlackClient(String Token) { caller = new APICaller(Token); this.Token = Token; Dictionary<String, dynamic> General = new Dictionary<string, dynamic>(); try { General = caller.CallMethod("rtm.start", new Dictionary<string, dynamic>()).Result; this.myself = General["self"]; foreach (Dictionary<String, object> VARIABLE in General["channels"]) { if (VARIABLE != null) { Channels.Add(VARIABLE["name"].ToString(), VARIABLE); } } foreach (dynamic VARIABLE in General["users"]) { Users.Add(VARIABLE["name"], VARIABLE); } URL = General["url"]; } catch(Exception e) { Console.WriteLine(e.ToString()); Console.ReadLine(); } }