url

package
v0.0.0-...-0d01ef4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 17, 2015 License: BSD-1-Clause Imports: 13 Imported by: 0

README

URL

This plugin detects webpage urls embedded in incoming messages. It extracts the urls, fetches their contents from the web and finds the page title element. The title is then posted to the channel/user from wence the message came.

For example:

<someuser> http://www.youtube.com/watch?v=dQw4w9WgXcQ
<bot> someuser's link shows: Rick Astley - Never Gonna Give You Up - YouTube

It's configuration file can present a list of regular expression patterns. These patterns represent (partial) urls, which should be excluded from the lookup. For example, to ignore all links to imgur.com and those ending in file extensions for images and video:

[exclude]
url < \.imgur\.com
url < \.(jpe?g|png|gif|bmp|tga|tiff)$
url < \.(mpe?g|avi|mp[1-5])$

This plugin is capable of recognizing links to specific tweets, and fetches the full tweet text accordingly. For example:

             │17:02:43   +chimeracoder | https://twitter.com/chimeracoder/status/334355537095426048       │ 
             │17:02:44        gophrbot | chimeracoder's tweet shows: http://t.co/VfVXPJAefq is finally    │
             │                         | updated! Woohoo! #golang                                         │

To enable this functionality, you must set the following environment values to valid values:

export TWITTER_CONSUMER_KEY=""
export TWITTER_CONSUMER_SECRET=""

export TWITTER_ACCESS_TOKEN=""
export TWITTER_ACCESS_TOKEN_SECRET=""

If the values are missing or invalid, or if fetching the tweet text fails for any reason, the plugin fails gracefully by falling back on fetching the <title> attribute

Documentation

Overview

This plugin detects webpage urls embedded in incoming messages. It extracts the urls, fetches their contents from the web and finds the page title element. The title is then posted to the channel/user from wence the message came.

This plugin has no commands. It simply hooks into PRIVMSG inputs and scans them for URLs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(profile string) plugin.Plugin

Types

type Plugin

type Plugin struct {
	*plugin.Base
	// contains filtered or unexported fields
}

func (*Plugin) Load

func (p *Plugin) Load(c *proto.Client) (err error)

Init initializes the plugin. it loads configuration data and binds commands and protocol handlers.

type Repository

type Repository struct {
	ArchiveURL       string      `json:"archive_url"`
	AssigneesURL     string      `json:"assignees_url"`
	BlobsURL         string      `json:"blobs_url"`
	BranchesURL      string      `json:"branches_url"`
	CloneURL         string      `json:"clone_url"`
	CollaboratorsURL string      `json:"collaborators_url"`
	CommentsURL      string      `json:"comments_url"`
	CommitsURL       string      `json:"commits_url"`
	CompareURL       string      `json:"compare_url"`
	ContentsURL      string      `json:"contents_url"`
	ContributorsURL  string      `json:"contributors_url"`
	CreatedAt        string      `json:"created_at"`
	DefaultBranch    string      `json:"default_branch"`
	Description      string      `json:"description"`
	DownloadsURL     string      `json:"downloads_url"`
	EventsURL        string      `json:"events_url"`
	Fork             bool        `json:"fork"`
	Forks            float64     `json:"forks"`
	ForksCount       float64     `json:"forks_count"`
	ForksURL         string      `json:"forks_url"`
	FullName         string      `json:"full_name"`
	GitCommitsURL    string      `json:"git_commits_url"`
	GitRefsURL       string      `json:"git_refs_url"`
	GitTagsURL       string      `json:"git_tags_url"`
	GitURL           string      `json:"git_url"`
	HasDownloads     bool        `json:"has_downloads"`
	HasIssues        bool        `json:"has_issues"`
	HasWiki          bool        `json:"has_wiki"`
	Homepage         interface{} `json:"homepage"`
	HooksURL         string      `json:"hooks_url"`
	HtmlURL          string      `json:"html_url"`
	ID               float64     `json:"id"`
	IssueCommentURL  string      `json:"issue_comment_url"`
	IssueEventsURL   string      `json:"issue_events_url"`
	IssuesURL        string      `json:"issues_url"`
	KeysURL          string      `json:"keys_url"`
	LabelsURL        string      `json:"labels_url"`
	Language         string      `json:"language"`
	LanguagesURL     string      `json:"languages_url"`
	MasterBranch     string      `json:"master_branch"`
	MergesURL        string      `json:"merges_url"`
	MilestonesURL    string      `json:"milestones_url"`
	MirrorURL        interface{} `json:"mirror_url"`
	Name             string      `json:"name"`
	NetworkCount     float64     `json:"network_count"`
	NotificationsURL string      `json:"notifications_url"`
	OpenIssues       float64     `json:"open_issues"`
	OpenIssuesCount  float64     `json:"open_issues_count"`
	Owner            struct {
		AvatarURL         string  `json:"avatar_url"`
		EventsURL         string  `json:"events_url"`
		FollowersURL      string  `json:"followers_url"`
		FollowingURL      string  `json:"following_url"`
		GistsURL          string  `json:"gists_url"`
		GravatarID        string  `json:"gravatar_id"`
		HtmlURL           string  `json:"html_url"`
		ID                float64 `json:"id"`
		Login             string  `json:"login"`
		OrganizationsURL  string  `json:"organizations_url"`
		ReceivedEventsURL string  `json:"received_events_url"`
		ReposURL          string  `json:"repos_url"`
		SiteAdmin         bool    `json:"site_admin"`
		StarredURL        string  `json:"starred_url"`
		SubscriptionsURL  string  `json:"subscriptions_url"`
		Type              string  `json:"type"`
		URL               string  `json:"url"`
	} `json:"owner"`
	Private         bool    `json:"private"`
	PullsURL        string  `json:"pulls_url"`
	PushedAt        string  `json:"pushed_at"`
	Size            float64 `json:"size"`
	SshURL          string  `json:"ssh_url"`
	StargazersURL   string  `json:"stargazers_url"`
	StatusesURL     string  `json:"statuses_url"`
	SubscribersURL  string  `json:"subscribers_url"`
	SubscriptionURL string  `json:"subscription_url"`
	SvnURL          string  `json:"svn_url"`
	TagsURL         string  `json:"tags_url"`
	TeamsURL        string  `json:"teams_url"`
	TreesURL        string  `json:"trees_url"`
	UpdatedAt       string  `json:"updated_at"`
	URL             string  `json:"url"`
	Watchers        float64 `json:"watchers"`
	WatchersCount   float64 `json:"watchers_count"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL