AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   IRC Relay for SourceMod 2.5.0 (https://forums.alliedmods.net/showthread.php?t=67017)

Olly 02-13-2008 18:01

IRC Relay for SourceMod 2.5.0
 
1 Attachment(s)
IRC Relay v2.5.0
by InterWave Studios

This is a follow-up from my last IRC Relay (1.0) which had lots of bugs, was bloated, and was slow to run on your server.

IRC Relay 2.0.0 was re-written COMPLETELY from scratch using the newest SourceMod stuff, unlike the old version which showed 100's of deprecation warnings.

The main idea behind this version is 'modularization'. This version has a much better library set of natives that can be called from ANY plugin on the game-server. Doing this I could split up each part of IRC Relay into multiple plugins, so now if you dont need/want a function, you can simply unload the plugin, and IRC Relay will keep working, but without that 'module'

Anyway, lets get on with it.

Features
  • Message the whole server, or individual players in your source server from IRC
  • Ability to authenticate with IRC services
  • Player listings
  • Detailed player info
  • Server information
  • Run Rcon commands from IRC
  • Kick & Ban players from IRC
  • Support for multiple IRC relay's in the same channel
  • Define-able relay "groups" for executing commands on multiple servers at once
  • Multiple channel support (UNLIMITED CHANNELS!!)
  • Brand new user permission system (kinda like ChanServ) a user gets added with a specific level (0-300) and depending on what level you set the command for, they can run it or not.
  • MUCH better flood protection, all data sent to the IRC server goes into a message queue, and dispatches the messages after a duration you specify. (I have spammed the shit out of it, and cant get it to 'Excess Flood' :)
  • Baconator module for all of your BACON needs!
  • Steam Community converter, converts Steam Community URL's to SteamID's and vice-versa
  • Ability to have all server chat relayed to your IRC channel(s)
Requirements
Server CVars
  • irc_server
    • The IRC server to connect to
  • irc_port
    • The IRC server port to connect to (def: 6667)
  • irc_password
    • The IRC server password
  • irc_nickname
    • The relay's nickname (make sure its unique on the network)
  • irc_trigger
    • The bot's trigger
  • irc_trigger_groups
    • This is a space seperated list of 'groups' like "eu css" the bot will respond to eu and css triggers (used for multiple servers)
  • irc_debug
    • If this is 1 IRC data will be sent to the server console (recomended it stays as 0, unless you have a problem)
  • irc_message_relaytype
    • The type of channel to send /irc messages from in-game to
      • 1 = Public Channels
      • 2 = Private Channels
      • 3 = Both types
  • irc_color
    • Having this set to 1 will enable colours in IRC (includes calls from any external plugins using the library)
    • If your IRC channel has +c mode set, then you MUST set this to 0, or some messages will fail to send
  • irc_auth_string
    • The service auth string
    • GameSurge: AUTHSERV AUTH %s %s
    • QuakeNet: PRIVMSG [email protected] :auth %s %s
  • irc_auth_username
    • The username to send to the IRC services to auth
  • irc_auth_password
    • The password to send to auth with
  • irc_chat_relaytype
    • The type of channel to send chat messages from in-game to
      • 0 = Off
      • 1 = Public Channels
      • 2 = Private Channels
      • 3 = Both types
  • irc_xs_* (Multiple CVars)
    • This is the user-level required to run the command specified in the cvar name (Read the config file for more info)
ChangeLog
  • 2.0.0
    • Initial Release :D
  • 2.0.1
    • Made IRC Relay work with sfPlayer's socket extension, as its more stable, and has more features (That is now required, instead of mine)
    • Fixed OnRelayPm/OnRelayMessage only triggering if the trigger was used (should be fired for any message)
    • Added IRC_ReplyMsg native which will reply to same destination that the triggering message was sent from
    • Added IRC_ReplyNotice native which is same as above, but a notice (duh)
    • Added IRC_Action native so you can send ./me commands to IRC
    • Added a die command, this is hardcoded to only allow level 300 to 'kill' the relay (for obvious reasons)
    • Merged irc-access.sp into irc-relay-core.smx (seperate sources) but should solve problems with late-loading because each plugin relyed on the other one to start ><
    • Added a new module (Steam-Community) which will convert steamid's to steam community URL's, and URL's to SteamID's (2 new commands, steam [community url], and profile [steamid]
    • Fixed some minor bugs with the queue, and added better error handling
    • Added a new essential module - Bacon module, with a new added command 'baconize' - Use for all your porky needs
    • Added new command (act) to make the relay perform an action (/me) same syntax as say
    • Added new cvar irc_xs_act to set the required access level to run the act command
    • Added OnWhoisHost forward, that will be called once the relay recieves a reply from a WHOIS command sent to the server, use IRC_GetWhoisHost() to get the host value retrieved
    • Added IRC_GetWhoisHost Read above -^
    • Added IRC_Whois native which will check the hostname of nickname supplied
    • Fixed missing confirmation when adding a new user to the relay
  • 2.1.0
    • Added chat relay for all in-game chat to be shown in IRC
    • Added ability to specify the location (and prefix) of KV config files
    • Reversed output of !players command. Now shows unconnected/spectators last
    • You can now sm plugins reload irc-relay-core to reload the whole thing. Each core plugin will also be reloaded automatically by the core plugin once it is finished loading.
  • 2.5.0
    • Again a complete rewrite, while retaining most of its functionality.
    • Replaced user permission system with access modes. It now checks for a user's channel access (founder/superop/op/halfop/voice) and allows them to run the command or not.
  • 2.5.0 - Version 2
    • Removed all separate plugins into one ircrelay-modules.smx file
    • New Permissions system
Thanks to http://www.steamfriends.com for the servers for me to test on :D

You can grab the download over here:
http://code.google.com/p/sm-ircrelay/

Bugs, requests and stuff can be done over here:
http://tracker.iwcommunity.net/projects/ircrelay

Olly 02-13-2008 18:05

Re: IRC Relay (v2.0.0)
 
Installation
  1. Download the package from the post above (obviously :D)
  2. Upload the contents of the zip file to your game folder (cstrike, dod, tf, etc)
  3. Open the addons/sourcemod/configs/ircrelay/channels.txt and edit the channels, to match your channel configuration
  4. Open cfg/sourcemod/ircrelay.cfg and change the settings
  5. Open cfg/server.cfg and add the following: exec sourcemod/ircrelay.cfg
  6. Open addons/sourcemod/configs/databases.cfg and add the settings described in the section below (Editing Database Config)
  7. Change the map on your server, this doesnt like being late-loaded because of all of the modules (ill ask bail if there is a way round this)
  8. in the server console, run the following command
    1. irc_addroot <rcon-password> <username> <password>
    2. Ofcourse replacing <..> with the real data (The only reason RCON password is required, is so that only the root admin can run this, and not anyone with lower access who has access to the relay's RCON command. It is not saved anywhere, its just used as a comparrison.
The relay should now join your channel (no +k or +i) i am still working on how to make them join these channels.

If your relay's dont join your channels, then change irc_debug 1 in your config file, and then change the map on the server again, the IRC data will now be shown in the server console, if you dont know why its not joining, then paste the IRC data and your problem in this topic, and ill look at it.


Editing Database Config
This assumes that your databases.cfg is the same as it is when you install SourceMod for the first time.

Your config should look like (or something like) this:
Code:

"Databases"
{
    "driver_default"        "mysql"
   
    "default"
    {
        "driver"            "default"
        "host"                "localhost"
        "database"            "someddb"
        "user"                "root"
        "pass"                ""
        //"timeout"            "0"
        //"port"            "0"
    }
   
    "storage-local"
    {
        "driver"            "sqlite"
        "database"            "sourcemod-local"
    }
}

Before you change anything, you should decide if you want to use mySQL or SQLite. If you are planning on using this relay on multiple servers, then having an external mySQL server will enable you to link the user logins to th bot, and maintain only one userlist for the user permissions.
If you only have one server, then you can use SQLite which will be stored on your game-server.


You will need to add the following below the 'default' section, but before the 'storage-local' section.

mySQL
Code:

"irc_relay"
    {
        "driver"            "mysql"
        "host"            "your.sql.server"
        "database"      "your_database"
        "user"            "username"
        "pass"            "password"
        //"timeout"            "30"
    }

SQLite
Code:

"irc_relay"
    {
        "driver"            "sqlite"
        "database"            "irc_relay"
    }



NOTE: if using mySQL the user must have permissions to CREATE TABLE. And the user should have access to the db from a remote location


Olly 02-13-2008 18:07

Re: IRC Relay (v2.0.0)
 
Useage
This relay works slightly different from 1.0.


Command Syntax
The command syntax for all of the relays is:

![trigger].command ARG1 ARG2 ...

For example, if you gave your relay the irc_name of css1, and wanted to send a message to everyone in the server, then you would run:

!css1.msg HI

If you added your relay to a trigger group, then you can run the same command on all relay's in the group by typing this in your channel:

[email protected] HI

(All groups must be prefixed with an @ symbol)

All commands can be run by PM'ing the relay too, but you must leave off the ! and trigger, so

msg HI


Commands
a - This command checks your access level on a specific relay bot, use like: !css.a

adduser <username> <password> <access level 1-300> - This is used to add users to the access userlist: use like: !css.adduser gaben hihi 200

auth <username> <password> - This is used to authenticate to the bot, and gain your access level after you leave IRC. Obviously this should be sent in a PM to the relay like: /query RELAYNAME auth gaben hihi

users - Lists the users and levels that are added to the relay database

kick <playername | partial name> - This will kick a player from your gameserver

ban <playername | partial name> <time> - This will ban a player from your server for the time specified

rcon <command> - This will run the command specified on the gameserver

say [#channel] <message> - This will make the relay say a message in the current channel, or the channel specified (#channel is optional)

reload - This will reload any sourcemod plugin on the server, usefull for if there is any bug-fixes from irc-relay, then you can upload the new plugin, and reload it, and the relay will never need to leave IRC

version - obviously the version of the relay

players - Gives a list of all of the players on the server, and the teams that they are on

playerinfo <playername | partial name> - This will give some information about the player specified

msg <message>- Will send the specified message to the gameserver

page <playername | partial name> <message> - will send the specified message to the user specified

gameinfo - Lists some information about the server

join <#channel> - makes the relay join the specified channel

part <#channel> - makes the relay leave the specified channel

die - Will kill the relay instantly, instead of unloading wating for the name to timeout

baconize - ;)

steam <SteamCommunity URL> - Converts a steam community URL into a Steam ID

profile <SteamID> - Converts a steamid into a community URL

commands - a list of all of the commands

setchat <0|1> - Enable/Disable relay of chat messages to IRC



Olly 02-13-2008 18:08

Re: IRC Relay (v2.0.0)
 
Library Natives
v2.0.0 works by all of the seperate modules using the library natives here. And they will also work from any external plugin, you just need to include the irc-relay.inc file, which is in the download in the first post.

Forwards
OnIrcConnected
Code:

/*********************************************************
 *  Called when the bot is fully connected, and ready to
 *  send commands and stuff to the server.
 *
 * @noreturn       
 *********************************************************/
forward OnIrcConnected();

Does what it says on the tin, when the bot is connected, and ready to run commands on the server, this will be called in your plugin


OnRelayPm
Code:

/*********************************************************
 *  Called when someone sends a PM to the relay
 *
 * @noreturn       
 *********************************************************/
forward OnRelayPm();

OnRelayNotice
Code:

/*********************************************************
 *  Called when someone sends a NOTICE to the relay
 *
 * @noreturn       
 *********************************************************/
forward OnRelayNotice();

OnRelayMessage
Code:

*********************************************************
 *  Called when someone sends a normal to the relay
 *
 * @noreturn       
 *********************************************************/
forward OnRelayMessage();

OnUserQuit
Code:

/*********************************************************
 *  Called when someone quits from the IRC server
 *
 * @noreturn       
 *********************************************************/
forward OnUserQuit();

OnWhoisHost
Code:

/*********************************************************
 *  Called after we receive a reply for host from a WHOIS command
 *
 * @noreturn       
 *********************************************************/
forward OnWhoisHost();

Natives to get information about a forward, or command call
IRC_GetMsgSender
Code:

/*********************************************************
 *  Gets the nickname of the user who sent the message.
 *
 * @param  String:buffer    The buffer to save the sender nickname into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetMsgSender(String:buffer[], size);

This, and following natives can be called from any command callback, or forward to get information of the person who triggered the command, or forward


IRC_GetSenderHost
Code:

/*********************************************************
 *  Gets the host of the user who sent the message. (ident@host)
 *
 * @param  String:buffer    The buffer to save the senders host into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetSenderHost(String:buffer[], size);

IRC_GetMsgDestination
Code:

/*********************************************************
 *  Gets destination of the message, so we can send a message back to where it came from
 *
 * @param  String:buffer    The buffer to save the destination into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetMsgDestination(String:buffer[], size);

The buffer will be set to the location any return message should be sent, so if the user called a command through a PM with the relay, then the buffer will contain the user's nickname, if it was called from a channel, then it will contain the channel name


IRC_GetMessage
Code:

/*********************************************************
 *  Gets the message, that was sent with the server response
 *
 * @param  String:buffer    The buffer to save the message into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetMessage(String:buffer[], size);

Gets the message text that was sent, PM, or Channel Mssage


IRC_RegisterCommand
Code:

/*********************************************************
 *  Allows you to register your own irc command, and have
 *  it callback to a function in your plugin when it gets called
 *
 * @param    String:name[]          The name of the command to register
 * @param    function        The callback function in your plugin
 * @param    minAccess        The min access level a user needs to use the command (0 for disable)
 * @noreturn       
 *********************************************************/
functag IRC_Tag_CommandCallback public(argc);
native IRC_RegisterCommand(const String:name[], IRC_Tag_CommandCallback:function, const minAccess);

One of the main natives in the plugin. This will allow you to register your own command name (or add an extra action on an existing command). Once someone calls this function, then the callback specified will be called. Users must have a userlevel that = or > than the minAccess param, or the callback wont be run



IRC_ReplyMsg
Code:

/*********************************************************
 *  This will simply send a message to the same place that the triggering
 *  command/message was sent from.
 *
 * @param    String:message[]    The message to send out.
 * @param    any:...            Formatter stuffs
 * @noreturn       
 *********************************************************/
native IRC_ReplyMsg(const String:message[], any:...);



IRC_ReplyNotice
Code:

/*********************************************************
 *  This will send a notice back to the origin of the triggering message
 *
 * @param    String:message[]    The message to send out.
 * @param    any:...            Formatter stuffs
 * @noreturn       
 *********************************************************/
native IRC_ReplyNotice(const String:message[], any:...);



IRC_Action
Code:

/*********************************************************
 *  This will show an 'action' in the specified channel, like /me [message]
 *
 * @param    String:destination[]      Can either be a channel name (#olly)
 *                    Or a nickname to send a PM
 * @param    String:message[]    The message to send out.
 * @param    any:...            Formatter stuffs
 * @noreturn       
 *********************************************************/
native IRC_Action(const String:destination[], const String:message[], any:...);


IRC_GetWhoisHost()
Code:

/*********************************************************
 *  Gets the hostname of the nickname that you whois'd this should be used inside the OnWhoisHost forward
 *
 *  NOTE: If the specified nickname does not exist when the whois command was issued, then the host string will be left blank
 *
 * @param  String:buffer    The buffer to save the host into
 * @param  size            The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetWhoisHost(String:buffer[], size);



IRC_SendRaw
Code:

/*********************************************************
 *  This native will allow external plugins to send RAW
 *  data to the server
 *
 * @param    String:command[]      The raw data to
 *                    send to the IRC
 *                    server.
 * @param    any:...            Formatting stuff
 * @noreturn       
 *********************************************************/
native IRC_SendRaw(const String:data[], any:...);

IRC_PrivMsg
Code:

/*********************************************************
 *  This will send a simple message to a user (pm) or
 *  to a channel
 *
 * @param    String:destination[]      Can either be a channel name (#olly)
 *                    Or a nickname to send a PM
 * @param    String:message[]    The message to send out.
 * @param    any:...            Formatter stuffs
 * @noreturn       
 *********************************************************/
native IRC_PrivMsg(const String:destination[], const String:message[], any:...);

IRC_Notice
Code:

/*********************************************************
 *  This will send a simple notice to a user (pm) or
 *  to a channel
 *
 * @param    String:destination[]      Can either be a channel name (#olly)
 *                    Or a nickname to send a PM
 * @param    String:message[]    The message to send out.
 * @param    any:...            Formatter stuffs
 * @noreturn       
 *********************************************************/
native IRC_Notice(const String:destination[], const String:message[], any:...);

IRC_Broadcast
Code:

/*********************************************************
 *  This will send a message to all of the channels of the type specified
 *
 * @param    ChannelType:ctype      The type of channel to send the message to
 * @param    String:message[]    The message to send out.
 * @param    any:...            Formatter stuffs
 * @noreturn       
 *********************************************************/
native IRC_Broadcast(ChannelType:ctype, const String:message[], any:...);

IRC_GetRelayNickName
Code:

/*********************************************************
 *  This will get the current nickname of the relay
 *
 * @param output    The buffer to store the name
 * @param size        The length of the buffer
 *********************************************************/
native IRC_GetRelayNickName(const String:output[], const size);

IRC_IsReady
Code:

/*********************************************************
 *  This will check if the core is correctly connected, and ready
 *
 * @return bool    True if the core is connected, and ready for commands       
 *********************************************************/
native IRC_IsReady();

IRC_GetCmdArgc
Code:

/*********************************************************
 *  Count the arguments sent along with our message
 *
 * @return count of arguments   
 *********************************************************/
native IRC_GetCmdArgc();

IRC_GetCmdArgv
Code:

/*********************************************************
 *  Get the argument number specified
 *
 * @param  num        The arguemnt number to store
 * @param  String:arg    The buffer to save the argument in
 * @param  size        The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetCmdArgv(num, String:arg[], size);

IRC_GetCmdArgString
Code:

/*********************************************************
 *  Will concatonate arguments starting at the specified argument
 *  and create a string. This is usefull for lazy people who
 *  dont put stuff in " "'s
 *
 * @param  String:arg    The buffer to save the argument in
 * @param  size        The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetCmdArgString(String:output[], size);

IRC_GetColourName | IRC_GetColorName
Code:

/*********************************************************
 *  Will return an IRC coloured version of the clients name
 *
 * @param  client    The client index to get name for
 * @param  String:arg    The buffer to save the argument in
 * @param  size        The size of the buffer
 * @noreturn
 *********************************************************/
native IRC_GetColorName(client, String:output[], size);
stock IRC_GetColourName(client, String:output[], size) // Needs support for the REAL spelling of colour ;)
{
    IRC_GetColorName(client, output, size);
}

FindPlayerName
Code:

/*****************************************************************
 * FindPlayerName
 *
 * @breif Find the userid from name or partial name
 * @params String:name name of the player to search for
 * @return -1 on not found
 *          -2 on multiple matches
 *          id User id of the player
 *****************************************************************/
stock FindPlayerName(const String:name[]);


FlyingMongoose 02-13-2008 19:35

Re: IRC Relay (v2.0.0)
 
First reply! w00t! To point out, I'll be pushing to release ATAC's next version, it has a whole bunch of IRC relay functionality built into the next version. Good work though Olly. Hmmm, how about nickserv support?

/NickServ IDENTIFY <password>

I know one community who operates on a network which utilizes nickserv.

sslice 02-13-2008 19:36

Re: IRC Relay (v2.0.0)
 
Nice release! :)

DontWannaName 02-13-2008 20:12

Re: IRC Relay (v2.0.0)
 
Thats a big readme lol!

PrefeX 02-13-2008 22:36

Re: IRC Relay (v2.0.0)
 
finally :p
been waiting on this for a long time now... thanks olly :)

Twelve-60 02-13-2008 22:37

Re: IRC Relay (v2.0.0)
 
wow wd :)

- Twelve-60

Extreme_One 02-14-2008 08:02

Re: IRC Relay (v2.0.0)
 
W00T :D

Looking forward to trying this.


All times are GMT -4. The time now is 10:28.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.