Skip to content

Instantly share code, notes, and snippets.

View mseymour's full-sized avatar

Mark Seymour mseymour

View GitHub Profile
@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 <mark.seymour.ns@gmail.com>
def check_user(channel, user, ignored_members=["v"])
ignored_members ||= [] # If nil, assign an empty array.
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 / 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}!"
@mseymour
mseymour / happybirthdaysean.rb
Created March 17, 2012 19:38
Just something silly that I threw together.
# @author Mark Seymour (mark.seymour.ns@gmail.com)
require 'date'
class Person
attr_accessor :first_name
attr_accessor :last_name
attr_accessor :birthday
# @param [String] The person's first name
@mseymour
mseymour / IRC test 212PM 2011-12-28
Created December 28, 2011 17:59
Twitter plugin v6 for Cinch (>=1.2.0)
Observations from below: nil gets sent, so that overrides any defaults.
Search should be switched over to named params.
<@Azure> !tw
<@Aiko_> TWITTER: tweet_by_username - params: {:username=>nil, :nth_tweet=>nil}
<@Azure> !tw azuretan
<@Aiko_> TWITTER: tweet_by_username - params: {:username=>"azuretan", :nth_tweet=>nil}
<@Azure> !tw azuretan+10
<@Aiko_> TWITTER: tweet_by_username - params: {:username=>"azuretan", :nth_tweet=>"10"}
<@Azure> @
@mseymour
mseymour / cr_dj_info.yaml
Created December 27, 2011 01:25
DJ info from YAML (debugging version)
---
mli:
My site: http://insomniafanfics.weebly.com
Tumblr: http://mylittleinsomnia.tumblr.com
Facebook: http://www.facebook.com/profile.php?id=100001428581452
PonySquare: http://ponysquare.com/profile-2220/
Twitter: https://twitter.com/#!/DJINs0mnIAK
Skype: legit.sketchy
E-mail: insomnia@ponify.me
XboxLIVE Gamertag: ThatGuyEcho
@mseymour
mseymour / adminhandler.rb
Created November 6, 2011 06:04
Admin handler + automatic +vhoa of bot admins
# -*- coding: utf-8 -*-
require 'modules/helpers/table_format'
module Plugins
module Admin
class Handler
include Cinch::Plugin
set(
plugin_name: "admin",
@mseymour
mseymour / table_format.rb
Created October 23, 2011 20:33
ascii table generating class
# Should really make a note here:
# This class currently only accepts arrays of data that has separators, rather than being a two-dimensional array. This will be fixed at some point.
# It will also not take a single string, or other types of collections. This will also be fixed at some point (in that case, table headings would have to be revamped to allow key->value pairings.
# - Mark
# -*- coding: utf-8 -*-
require 'active_support/core_ext/object/blank'
module Helpers
# Formats a supplied array into a list or table.
@mseymour
mseymour / admin.rb
Created October 15, 2011 02:34
IRC bot admin singleton class - 2011-10-13 11:33PM ADT
require 'singleton'
require 'digest/sha2'
class Admin
include Singleton
attr_reader :masks
attr_accessor :password
def initialize
@mseymour
mseymour / remoteadmin.rb
Created September 25, 2011 18:47
RemoteAdmin - message relayer
require 'obj_ext/string'
module Plugins
class RemoteAdmin
include Cinch::Plugin
set help: "Relays certain messages to logged-in admins.", required_options: [:admins]
listen_to :notice
listen_to :private