Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- AddonInfo <- {
- "Name":"Bridge"
- "Summary":"Connects channels together"
- "Version":"0.01"
- "Author":"NovaSquirrel"
- };
- function IsActionMy(Text) {
- if(Text.len() < 2) return " ";
- if(Text.slice(0,2)=="'s") return "";
- return " ";
- }
- function EventString(T, P, C) {
- const IsAction = "* ";
- const IsNotice = "- ";
- switch(T) { // important: don't capitalize event names, they won't match here
- case "user change nick":
- return IsNotice+P.Nick+ " is now known as "+P.NewNick;
- case "user message":
- return "<"+P.Nick+"> "+P.Text;
- case "user action":
- return IsAction+P.Nick+IsActionMy(P.Text)+P.Text;
- case "channel ban+":
- if("Timeout" in P)
- return IsNotice+P.Nick+" has banned "+P.Target+" for "+P.Timeout+" minutes";
- else
- return IsNotice+P.Nick+" has banned "+P.Target;
- case "channel ban-":
- return IsNotice+P.Nick+" has unbanned "+P.Target;
- case "channel join":
- if("Host" in P)
- return IsNotice+P.Nick+" ("+P.Host+") has joined "+api.TabGetInfo(C, "Channel");
- else
- return IsNotice+P.Nick+" has joined "+api.TabGetInfo(C, "Channel");
- case "channel kick":
- if("Text" in P)
- return IsNotice+P.Nick+" has kicked "+P.Target+" ("+P.Text+")";
- else
- return IsNotice+P.Nick+" has kicked "+P.Target;
- case "channel part":
- if("Text" in P)
- return IsNotice+P.Nick+" has left ("+P.Text+")";
- else
- return IsNotice+P.Nick+" has left";
- case "channel status+":
- if("Nick" in P)
- return IsNotice+P.Nick+" gives \""+P.Status+"\" status to "+P.Target;
- else
- return IsNotice+"Someone gives \""+P.Status+"\" status to "+P.Target;
- case "channel status-":
- if("Nick" in P)
- return IsNotice+P.Nick+" removes \""+P.Status+"\" status from "+P.Target;
- else
- return IsNotice+"Someone removes \""+P.Status+"\" status from "+P.Target;
- case "channel mode+":
- return IsNotice+P.Nick+" sets modes "+P.Mode;
- case "channel mode-":
- return IsNotice+P.Nick+" removes modes "+P.Mode;
- default:
- return EventReturn.NORMAL;
- }
- }
- local Links = [];
- function TrimChannelId(Context) {
- local Split = split(Context, "/");
- local Channel = split(Split[1], ":");
- return Split[0]+"/"+Channel[0];
- }
- function ShowEvent(Type, Params, Context) {
- Context = TrimChannelId(Context);
- if(Links.find(Context) != null) {
- Params = api.DecodeJSON(Params);
- local Message = EventString(Type, Params, Context);
- if(typeof(Message) != "string")
- return EventReturn.NORMAL;
- print(Message);
- foreach(Channel in Links)
- if(Channel != Context)
- api.Command("say", Message, Channel);
- }
- return EventReturn.NORMAL;
- }
- function AddBridgeCmd(Type, Params, Context) {
- Context = TrimChannelId(Context);
- if(Links.find(Context) == null) {
- print("Added "+Context+" to linked channels");
- Links.append(Context);
- } else {
- print("Already linked");
- }
- return EventReturn.HANDLED;
- }
- foreach(Type in ["you *", "user *", "channel *"])
- api.AddEventHook(Type, ShowEvent, Priority.LOW, 0, 0, 0);
- api.AddCommandHook("addbridge", AddBridgeCmd, Priority.NORMAL, null, null);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement