Skip to content

Commit e458940

Browse files
committed
First commit
0 parents  commit e458940

File tree

16 files changed

+1114
-0
lines changed

16 files changed

+1114
-0
lines changed

.gitignore

Lines changed: 174 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,174 @@
1+
## Ignore Visual Studio temporary files, build results, and
2+
## files generated by popular Visual Studio add-ons.
3+
4+
# User-specific files
5+
*.suo
6+
*.user
7+
*.sln.docstates
8+
9+
# Build results
10+
[Dd]ebug/
11+
[Dd]ebugPublic/
12+
[Rr]elease/
13+
x64/
14+
build/
15+
bld/
16+
[Bb]in/
17+
[Oo]bj/
18+
19+
# MSTest test Results
20+
[Tt]est[Rr]esult*/
21+
[Bb]uild[Ll]og.*
22+
23+
#NUNIT
24+
*.VisualState.xml
25+
TestResult.xml
26+
27+
# Build Results of an ATL Project
28+
[Dd]ebugPS/
29+
[Rr]eleasePS/
30+
dlldata.c
31+
32+
*_i.c
33+
*_p.c
34+
*_i.h
35+
*.ilk
36+
*.meta
37+
*.obj
38+
*.pch
39+
*.pdb
40+
*.pgc
41+
*.pgd
42+
*.rsp
43+
*.sbr
44+
*.tlb
45+
*.tli
46+
*.tlh
47+
*.tmp
48+
*.tmp_proj
49+
*.log
50+
*.vspscc
51+
*.vssscc
52+
.builds
53+
*.pidb
54+
*.svclog
55+
*.scc
56+
57+
# Chutzpah Test files
58+
_Chutzpah*
59+
60+
# Visual C++ cache files
61+
ipch/
62+
*.aps
63+
*.ncb
64+
*.opensdf
65+
*.sdf
66+
*.cachefile
67+
68+
# Visual Studio profiler
69+
*.psess
70+
*.vsp
71+
*.vspx
72+
73+
# TFS 2012 Local Workspace
74+
$tf/
75+
76+
# Guidance Automation Toolkit
77+
*.gpState
78+
79+
# ReSharper is a .NET coding add-in
80+
_ReSharper*/
81+
*.[Rr]e[Ss]harper
82+
*.DotSettings.user
83+
84+
# JustCode is a .NET coding addin-in
85+
.JustCode
86+
87+
# TeamCity is a build add-in
88+
_TeamCity*
89+
90+
# DotCover is a Code Coverage Tool
91+
*.dotCover
92+
93+
# NCrunch
94+
*.ncrunch*
95+
_NCrunch_*
96+
.*crunch*.local.xml
97+
98+
# MightyMoose
99+
*.mm.*
100+
AutoTest.Net/
101+
102+
# Web workbench (sass)
103+
.sass-cache/
104+
105+
# Installshield output folder
106+
[Ee]xpress/
107+
108+
# DocProject is a documentation generator add-in
109+
DocProject/buildhelp/
110+
DocProject/Help/*.HxT
111+
DocProject/Help/*.HxC
112+
DocProject/Help/*.hhc
113+
DocProject/Help/*.hhk
114+
DocProject/Help/*.hhp
115+
DocProject/Help/Html2
116+
DocProject/Help/html
117+
118+
# Click-Once directory
119+
publish/
120+
121+
# Publish Web Output
122+
*.[Pp]ublish.xml
123+
*.azurePubxml
124+
125+
# NuGet Packages Directory
126+
packages/
127+
## TODO: If the tool you use requires repositories.config uncomment the next line
128+
#!packages/repositories.config
129+
130+
# Enable "build/" folder in the NuGet Packages folder since NuGet packages use it for MSBuild targets
131+
# This line needs to be after the ignore of the build folder (and the packages folder if the line above has been uncommented)
132+
!packages/build/
133+
134+
# Windows Azure Build Output
135+
csx/
136+
*.build.csdef
137+
138+
# Windows Store app package directory
139+
AppPackages/
140+
141+
# Others
142+
sql/
143+
*.Cache
144+
ClientBin/
145+
[Ss]tyle[Cc]op.*
146+
~$*
147+
*~
148+
*.dbmdl
149+
*.dbproj.schemaview
150+
*.pfx
151+
*.publishsettings
152+
node_modules/
153+
154+
# RIA/Silverlight projects
155+
Generated_Code/
156+
157+
# Backup & report files from converting an old project file to a newer
158+
# Visual Studio version. Backup files are not needed, because we have git ;-)
159+
_UpgradeReport_Files/
160+
Backup*/
161+
UpgradeLog*.XML
162+
UpgradeLog*.htm
163+
164+
# SQL Server files
165+
*.mdf
166+
*.ldf
167+
168+
# Business Intelligence projects
169+
*.rdl.data
170+
*.bim.layout
171+
*.bim_*.settings
172+
173+
# Microsoft Fakes
174+
FakesAssemblies/

IrcBot.Title/IrcBot.Title.csproj

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
4+
<PropertyGroup>
5+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
6+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
7+
<ProjectGuid>{5EB8E03B-0B8E-4632-8D73-E75A9D14C232}</ProjectGuid>
8+
<OutputType>Library</OutputType>
9+
<AppDesignerFolder>Properties</AppDesignerFolder>
10+
<RootNamespace>IrcBot.Title</RootNamespace>
11+
<AssemblyName>IrcBot.Title</AssemblyName>
12+
<TargetFrameworkVersion>v4.0</TargetFrameworkVersion>
13+
<FileAlignment>512</FileAlignment>
14+
<TargetFrameworkProfile />
15+
</PropertyGroup>
16+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
17+
<DebugSymbols>true</DebugSymbols>
18+
<DebugType>full</DebugType>
19+
<Optimize>false</Optimize>
20+
<OutputPath>bin\Debug\</OutputPath>
21+
<DefineConstants>DEBUG;TRACE</DefineConstants>
22+
<ErrorReport>prompt</ErrorReport>
23+
<WarningLevel>4</WarningLevel>
24+
</PropertyGroup>
25+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
26+
<DebugType>pdbonly</DebugType>
27+
<Optimize>true</Optimize>
28+
<OutputPath>bin\Release\</OutputPath>
29+
<DefineConstants>TRACE</DefineConstants>
30+
<ErrorReport>prompt</ErrorReport>
31+
<WarningLevel>4</WarningLevel>
32+
</PropertyGroup>
33+
<ItemGroup>
34+
<Reference Include="HtmlAgilityPack, Version=1.4.6.0, Culture=neutral, PublicKeyToken=bd319b19eaf3b43a, processorArchitecture=MSIL">
35+
<SpecificVersion>False</SpecificVersion>
36+
<HintPath>..\packages\HtmlAgilityPack.1.4.6\lib\Net40\HtmlAgilityPack.dll</HintPath>
37+
</Reference>
38+
<Reference Include="Meebey.SmartIrc4net">
39+
<HintPath>..\..\..\..\..\src\SmartIrc4net\bin\debug\Meebey.SmartIrc4net.dll</HintPath>
40+
</Reference>
41+
<Reference Include="System" />
42+
<Reference Include="System.Core" />
43+
<Reference Include="System.Xml.Linq" />
44+
<Reference Include="System.Data.DataSetExtensions" />
45+
<Reference Include="Microsoft.CSharp" />
46+
<Reference Include="System.Data" />
47+
<Reference Include="System.Xml" />
48+
</ItemGroup>
49+
<ItemGroup>
50+
<Compile Include="Title.cs" />
51+
<Compile Include="Properties\AssemblyInfo.cs" />
52+
</ItemGroup>
53+
<ItemGroup>
54+
<ProjectReference Include="..\ircbot\IrcBot.csproj">
55+
<Project>{91060349-1648-41bb-bcef-0d6473e67438}</Project>
56+
<Name>IrcBot</Name>
57+
</ProjectReference>
58+
</ItemGroup>
59+
<ItemGroup>
60+
<None Include="packages.config" />
61+
</ItemGroup>
62+
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
63+
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
64+
Other similar extension points exist, see Microsoft.Common.targets.
65+
<Target Name="BeforeBuild">
66+
</Target>
67+
<Target Name="AfterBuild">
68+
</Target>
69+
-->
70+
</Project>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("IrcBot.Title")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("IrcBot.Title")]
13+
[assembly: AssemblyCopyright("Copyright © 2014")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// The following GUID is for the ID of the typelib if this project is exposed to COM
23+
[assembly: Guid("8850c46d-69c7-4578-8a22-e2d0e2c2aafd")]
24+
25+
// Version information for an assembly consists of the following four values:
26+
//
27+
// Major Version
28+
// Minor Version
29+
// Build Number
30+
// Revision
31+
//
32+
// You can specify all the values or you can default the Build and Revision Numbers
33+
// by using the '*' as shown below:
34+
// [assembly: AssemblyVersion("1.0.*")]
35+
[assembly: AssemblyVersion("1.0.0.0")]
36+
[assembly: AssemblyFileVersion("1.0.0.0")]

IrcBot.Title/Title.cs

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
using System;
2+
using System.Net;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
using HtmlAgilityPack;
8+
using Meebey.SmartIrc4net;
9+
using System.Text.RegularExpressions;
10+
11+
namespace IrcBot.Title
12+
{
13+
public class Title : IPlugin
14+
{
15+
// THANKS GRUBER
16+
static string crazy_regex = @"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'" + "\"" + ".,<>?«»“”‘’]))";
17+
18+
string IPlugin.Invoke(string source, string message, ref IrcClient client)
19+
{
20+
string toSend = ""; // Make csc happy
21+
// catch urls
22+
MatchCollection matches = Regex.Matches(message, crazy_regex);
23+
foreach (Match m in matches)
24+
{
25+
if (!(m.Value.StartsWith("http://") || m.Value.StartsWith("https://"))) continue; // boo unprefix
26+
27+
// Check if that's even an HTML file
28+
WebRequest wr = WebRequest.Create(m.Value);
29+
wr.Method = "HEAD";
30+
string type = wr.GetResponse().ContentType;
31+
// TODO: Support a whole bunch of wacky shit. img2aa anyone?
32+
// Go through the types. We StartWith because of encoding info.
33+
if (type.StartsWith("text/html"))
34+
{ // We could support the other wacky shit like XML
35+
toSend = GetHTMLGist(m.Value);
36+
}
37+
}
38+
return toSend != "" ? toSend : null;
39+
}
40+
41+
/// <summary>
42+
/// Gets the title and any other interesting doodads of an HTML document.
43+
/// </summary>
44+
/// <param name="url"></param>
45+
/// <returns>The title, maybe other stuff..</returns>
46+
static string GetHTMLGist(string url)
47+
{
48+
// TODO: Support things like YouTube playback length, etc
49+
HtmlAgilityPack.HtmlDocument hd = new HtmlAgilityPack.HtmlDocument();
50+
hd.LoadHtml(new WebClient().DownloadString(url));
51+
return hd.DocumentNode.SelectSingleNode("/html/head/title").InnerText;
52+
}
53+
}
54+
}

IrcBot.Title/packages.config

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="HtmlAgilityPack" version="1.4.6" targetFramework="net40" />
4+
</packages>

0 commit comments

Comments
 (0)