corrade-vassal – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | vero | 1 | using OpenMetaverse; |
2 | using System; |
||
3 | |||
4 | namespace IRCGateway |
||
5 | { |
||
6 | class Program |
||
7 | { |
||
8 | static GridClient _Client; |
||
9 | static LoginParams _ClientLogin; |
||
10 | static IRCClient _IRC; |
||
11 | static string _AutoJoinChannel; |
||
12 | static UUID _MasterID; |
||
13 | |||
14 | static void Main(string[] args) |
||
15 | { |
||
16 | int ircPort; |
||
17 | |||
18 | if (args.Length < 7 || !UUID.TryParse(args[3], out _MasterID) || !int.TryParse(args[5], out ircPort) || args[6].IndexOf('#') == -1) |
||
19 | Console.WriteLine("Usage: ircgateway.exe <firstName> <lastName> <password> <masterUUID> <ircHost> <ircPort> <#channel>"); |
||
20 | |||
21 | else |
||
22 | { |
||
23 | _Client = new GridClient(); |
||
24 | _Client.Network.LoginProgress += Network_OnLogin; |
||
25 | _Client.Self.ChatFromSimulator += Self_ChatFromSimulator; |
||
26 | _Client.Self.IM += Self_IM; |
||
27 | _ClientLogin = _Client.Network.DefaultLoginParams(args[0], args[1], args[2], "", "IRCGateway"); |
||
28 | |||
29 | _AutoJoinChannel = args[6]; |
||
30 | _IRC = new IRCClient(args[4], ircPort, "SLGateway", "Second Life Gateway"); |
||
31 | _IRC.OnConnected += new IRCClient.ConnectCallback(_IRC_OnConnected); |
||
32 | _IRC.OnMessage += new IRCClient.MessageCallback(_IRC_OnMessage); |
||
33 | |||
34 | _IRC.Connect(); |
||
35 | |||
36 | string read = Console.ReadLine(); |
||
37 | while (read != null) read = Console.ReadLine(); |
||
38 | } |
||
39 | } |
||
40 | |||
41 | static void Self_IM(object sender, InstantMessageEventArgs e) |
||
42 | { |
||
43 | if (e.IM.Dialog == InstantMessageDialog.RequestTeleport) |
||
44 | { |
||
45 | if (e.IM.FromAgentID == _MasterID) |
||
46 | { |
||
47 | _Client.Self.TeleportLureRespond(e.IM.FromAgentID, e.IM.IMSessionID, true); |
||
48 | } |
||
49 | } |
||
50 | } |
||
51 | |||
52 | static void Self_ChatFromSimulator(object sender, ChatEventArgs e) |
||
53 | { |
||
54 | if (e.FromName != _Client.Self.Name && e.Type == ChatType.Normal && e.AudibleLevel == ChatAudibleLevel.Fully) |
||
55 | { |
||
56 | string str = "<" + e.FromName + "> " + e.Message; |
||
57 | _IRC.SendMessage(_AutoJoinChannel, str); |
||
58 | Console.WriteLine("[SL->IRC] " + str); |
||
59 | } |
||
60 | } |
||
61 | |||
62 | static void _IRC_OnConnected() |
||
63 | { |
||
64 | _IRC.JoinChannel(_AutoJoinChannel); |
||
65 | _Client.Network.BeginLogin(_ClientLogin); |
||
66 | } |
||
67 | |||
68 | static void _IRC_OnMessage(string target, string name, string address, string message) |
||
69 | { |
||
70 | if (target == _AutoJoinChannel) |
||
71 | { |
||
72 | string str = "<" + name + "> " + message; |
||
73 | _Client.Self.Chat(str, 0, ChatType.Normal); |
||
74 | Console.WriteLine("[IRC->SL] " + str); |
||
75 | } |
||
76 | } |
||
77 | |||
78 | static void Network_OnLogin(object sender, LoginProgressEventArgs e) |
||
79 | { |
||
80 | _IRC.SendMessage(_AutoJoinChannel, e.Message); |
||
81 | } |
||
82 | } |
||
83 | } |