Skip to content

Instantly share code, notes, and snippets.

View mseymour's full-sized avatar

Mark Seymour mseymour

View GitHub Profile
@mseymour
mseymour / hello.rb
Created May 9, 2012 03:18
Basic "!hello" plugin
module Cinch
module Plugins
class HelloBot
include Cinch::Plugin
set(:plugin_name => "Hello Bot", :help => 'Responds on "!hello"')
match "hello"
def execute(m)
m.reply "Hello #{m.user.nick}, my name is #{@bot.nick}!"
module Cinch
module Helpers
def check_user(channel, user, ignored_members=["v"])
ignored_members ||= [] # If nil, assign an empty array.
users = Channel(channel).users # All users from supplied channel
modes = @bot.irc.isupport["PREFIX"].keys - ignored_members #
modes.any? {|mode| users[user].include?(mode)}
end
end
end
@mseymour
mseymour / check_user.rb
Created August 25, 2012 16:40
Cinch Helper: check_user
module Cinch
module Helpers
# Checks a user's access in the specified channel.
# @param channel [Channel, String] A Channel object or string that is the name of the channel. (i.e. #chat)
# @param user [User] A User object
# @param ignored_members [Array<String>] An array of modes that this method will ignore
# @return [Boolean] Returns True if the user has any channel modes other than the ignored modechars
# @author Mark Seymour/Azure <[email protected]>
def check_user(channel, user, ignored_members=["v"])
ignored_members ||= [] # If nil, assign an empty array.
@mseymour
mseymour / irc.rb
Last active December 10, 2015 10:38
A very very very basic IRCbot.
require 'socket'
require 'logger'
require 'logger/colors'
require 'thread'
Thread.abort_on_exception = true
class IRC
attr_reader :nick, :user, :gecos
attr_reader :server, :port
attr_reader :socket, :logger, :capabilities, :isupport, :casemapping
@mseymour
mseymour / plugin_layout_ideas.rb
Created January 12, 2013 08:44
Trying to come up with plugin layout ideas for my own IRC framework... I am too biased right now, so everything is very similar to Cinch.
module Sussex
module Plugins
# This is just a class for laying out possible plugin ideas.
# I have been using Cinch for about a year and a half now, so I am quite
# biased in terms of plugin design for something like this...
# Note that I also use an include for including methods/etc. into the plugin
# There are probably other ways of doing this as well.
class MyPlugin
include Sussex::Plugin
[2013-05-19 16:15:14] requirements_osx_brew_libs_install
requirements_osx_brew_libs_install ()
{
brew unlink "$@" && brew install "$@" || {
typeset ret=$?;
rvm_warn "There were package installation errors, make sure to read the log.
Check Homebrew requirements https://github.com/mxcl/homebrew/wiki/Installation";
case "$_system_version" in
10.6)
rvm_warn "On OSX 10.6 instead of command line tools install:
@mseymour
mseymour / away error
Created June 20, 2013 23:14
Cinch - exception on receiving an AWAY command from another client
[2013/06/20 20:09:51.410] >> :[email protected] PRIVMSG #celestiaradio :I just can't remember what.
[2013/06/20 20:09:51.411] !! [New thread] For #<Cinch::Handler @event=:channel pattern=#<Cinch::Pattern:0x00000002c6e100 @prefix=nil, @pattern=//, @suffix=nil>>: #<Thread:0x007f142ca1f698> -- 1 in total.
[2013/06/20 20:09:51.416] !! [New thread] For #<Cinch::Handler @event=:channel pattern=#<Cinch::Pattern:0x00000002d273d0 @prefix=nil, @pattern=//, @suffix=nil>>: #<Thread:0x007f142ca1eef0> -- 1 in total.
[2013/06/20 20:09:51.416] !! [New thread] For #<Cinch::Handler @event=:channel pattern=#<Cinch::Pattern:0x00000001df4430 @prefix=nil, @pattern=//, @suffix=nil>>: #<Thread:0x007f142ca1d938> -- 1 in total.
[2013/06/20 20:09:51.416] !! [New thread] For #<Cinch::Handler @event=:channel pattern=#<Cinch::Pattern:0x00000001e5c030 @prefix=nil, @pattern=//, @suffix=nil>>: #<Thread:0x007f142ca1d438> -- 1 in total.
[2013/06/20 20:09:51.416] !! [New thread] For #<Cinch::Handler @event=:message patte
@mseymour
mseymour / Cog.scpt
Created August 19, 2013 21:50
A Textual plugin script that gets the currently playing song from Cog, and scrapes the UI for the current position to calculate time remaining.
-- Copyright © 2013 Mark Seymour ([email protected])
on textualcmd()
tell application "System Events"
tell application "System Events" to set isRunning to exists (processes where name is "Cog")
set curpos to value of static text of group 2 of tool bar 1 of window of application process "Cog"
end tell
set listening to "/me np: "
@mseymour
mseymour / presidents.json
Last active December 24, 2015 03:29
a JSON file that describes an HTML form for submission.
{
"title": "Regional Presidents Report",
"report_type": "club",
"form": [
{
"title": "Identification",
"items": [
{ "type": "text", "label": "Full Name" },
{ "type": "email", "label": "Email" },
{ "type": "text", "label": "Club" },
@mseymour
mseymour / BannerImageExtension.php
Created November 11, 2013 02:30
BannerImageExtension, for creating background banners on various pages.
<?php
class BannerImageExtension extends Extension {
public function ArtDirectionImage($width, $height) {
return $this->getFormattedImage('ArtDirectionImage', $width, $height);
}
public function generateArtDirectionImage(Image_Backend $backend, $width, $height) {
$backend->set_backend('ImagickBackend');
print 'SS3.1: BannerImageExtension backend: '.$backend->get_backend();