]> jfr.im git - irc/rizon/acid.git/blob - acid/src/main/java/net/rizon/acid/core/AcidUser.java
6b66d1a41c54f447f9ca1a627825ff53545509bb
[irc/rizon/acid.git] / acid / src / main / java / net / rizon / acid / core / AcidUser.java
1 package net.rizon.acid.core;
2
3 import net.rizon.acid.plugins.Plugin;
4 import java.util.List;
5 import net.rizon.acid.conf.Client;
6
7 public class AcidUser extends User
8 {
9 public Plugin pkg;
10 public Client client;
11
12 public AcidUser(final String nick, final String user, final String host, final String vhost, final String name, final String modes)
13 {
14 super(nick, user, host, vhost, name, AcidCore.me, AcidCore.getTS(), AcidCore.getTS(), modes, User.generateUID(), "255.255.255.255");
15 }
16
17 public AcidUser(Plugin pkg, Client c)
18 {
19 super(c.nick, c.user, c.host, c.vhost, c.name, AcidCore.me, AcidCore.getTS(), AcidCore.getTS(), c.modes, User.generateUID(), "255.255.255.255");
20 this.pkg = pkg;
21 this.client = c;
22
23 if (client != null && client.channels != null)
24 for (String ch : client.channels)
25 this.joinChan(Acidictive.conf.getChannelNamed(ch));
26 }
27
28 public void introduce()
29 {
30 Protocol.uid(this);
31
32 if (this.getNSPass() != null && !this.getNSPass().isEmpty())
33 Protocol.privmsg(this.getUID(), "NickServ@services.rizon.net", "IDENTIFY " + this.getNSPass()); // XXX
34
35 for (Channel chan : this.getChannels())
36 Protocol.join(this, chan);
37 }
38
39 public void joinChan(final String channel)
40 {
41 Channel chan = Channel.findChannel(channel);
42 if (chan != null && this.isOnChan(chan))
43 return;
44
45 if (chan == null)
46 {
47 chan = new Channel(channel, AcidCore.getTS());
48 chan.setMode('n'); chan.setMode('t');
49 }
50 if (!AcidCore.me.isBursting())
51 Protocol.join(this, chan);
52 chan.addUser(this, "");
53 this.addChan(chan);
54 }
55
56 public void partChan(Channel chan)
57 {
58 if (!this.isOnChan(chan))
59 return;
60
61 Protocol.part(this, chan.getName());
62 chan.removeUser(this);
63 this.remChan(chan);
64 }
65
66 public void quit(final String reason)
67 {
68 Protocol.quit(this, reason);
69 this.onQuit();
70 }
71
72 public final String getNSPass()
73 {
74 if (client != null)
75 return client.nspass;
76 else
77 return null;
78 }
79
80 public net.rizon.acid.conf.Command findConfCommand(String name, String channel)
81 {
82 if (client != null && this.client.commands != null)
83 for (net.rizon.acid.conf.Command c : this.client.commands)
84 if (c.name.equalsIgnoreCase(name) && (channel == null || c.allowsChannel(channel)))
85 return c;
86 return null;
87 }
88
89 public List<net.rizon.acid.conf.Command> getConfCommands()
90 {
91 return this.client.commands;
92 }
93 }