Skip to content

Instantly share code, notes, and snippets.

@chiepomme
Created February 21, 2014 23:25
Show Gist options
  • Save chiepomme/9145787 to your computer and use it in GitHub Desktop.
Save chiepomme/9145787 to your computer and use it in GitHub Desktop.
using SKYPE4COMLib;
using System.Net;
using System.Text.RegularExpressions;
using System.Threading;
namespace mikobot
{
class Program
{
static Skype Skype;
const string Topic = "みこぺろりすと専用";
static void Main(string[] args)
{
Skype = new Skype();
Skype.MessageStatus += OnMessageReceived;
while (true) Thread.Sleep(1000);
}
static void OnMessageReceived(ChatMessage message, TChatMessageStatus status)
{
if (message.Chat.Topic != Topic || message.Sender.Handle == Skype.CurrentUserHandle) return;
var chat = message.Chat;
var text = message.Body;
Match match;
if ((match = Regex.Match(text, @"https?://[\w/:%#\$&\?\(\)~\.=\+\-]+")).Success)
{
var url = match.Groups[0].Value;
var html = new WebClient().DownloadString(url);
var htmlMatch = Regex.Match(html, "<title>(.+?)</title>", RegexOptions.IgnoreCase);
if (!htmlMatch.Success) return;
chat.SendMessage(string.Format("|◕ω◕`)。o(そのURLは {0} だよ!)", htmlMatch.Groups[1].Value));
}
else if (Regex.IsMatch(text, "みこみこ通話して"))
{
Skype.PlaceCall(chat.Name);
chat.SendMessage("|◕ω◕`) いまからかけるね!");
}
else if (Regex.IsMatch(text, "おやすみ"))
chat.SendMessage(string.Format("|◕ω◕`) {0}さんおやすみなさい!", message.Sender.FullName));
else if (Regex.IsMatch(text, "おはよ"))
chat.SendMessage(string.Format("|◕ω◕`) {0}さんおはよう!", message.Sender.FullName));
else if (Regex.IsMatch(text, "みこみこだいすき"))
chat.SendMessage(string.Format("|◕ω◕`)。o({0}さん、なでなでしてくれないかなぁ・・・)", message.Sender.FullName));
else if (Regex.IsMatch(text, "みこみこ"))
chat.SendMessage("|◕ω◕`) なあに?");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment