[{"data":1,"prerenderedAt":691},["ShallowReactive",2],{"i-lucide:menu":3,"i-lucide:arrow-up-right":8,"i-lucide:moon":10,"i-lucide:sun":12,"i-lucide:rss":14,"i-simple-icons:github":16,"i-simple-icons:linkedin":18,"post-\u002F2010\u002Fautomaatne-sotsialiseerimine":21,"surround-\u002F2010\u002Fautomaatne-sotsialiseerimine":72,"i-lucide:arrow-left":81,"i-lucide:arrow-right":83,"gist-2656981":85},{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":7},0,24,false,"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M4 5h16M4 12h16M4 19h16\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":9},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M7 7h10v10M7 17L17 7\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":11},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M20.985 12.486a9 9 0 1 1-9.473-9.472c.405-.022.617.46.402.803a6 6 0 0 0 8.268 8.268c.344-.215.825-.004.803.401\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":13},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Ccircle cx=\"12\" cy=\"12\" r=\"4\"\u002F>\u003Cpath d=\"M12 2v2m0 16v2M4.93 4.93l1.41 1.41m11.32 11.32l1.41 1.41M2 12h2m16 0h2M6.34 17.66l-1.41 1.41M19.07 4.93l-1.41 1.41\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":15},"\u003Cg fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\">\u003Cpath d=\"M4 11a9 9 0 0 1 9 9M4 4a16 16 0 0 1 16 16\"\u002F>\u003Ccircle cx=\"5\" cy=\"19\" r=\"1\"\u002F>\u003C\u002Fg>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":17},"\u003Cpath fill=\"currentColor\" d=\"M12 .297c-6.63 0-12 5.373-12 12c0 5.303 3.438 9.8 8.205 11.385c.6.113.82-.258.82-.577c0-.285-.01-1.04-.015-2.04c-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729c1.205.084 1.838 1.236 1.838 1.236c1.07 1.835 2.809 1.305 3.495.998c.108-.776.417-1.305.76-1.605c-2.665-.3-5.466-1.332-5.466-5.93c0-1.31.465-2.38 1.235-3.22c-.135-.303-.54-1.523.105-3.176c0 0 1.005-.322 3.3 1.23c.96-.267 1.98-.399 3-.405c1.02.006 2.04.138 3 .405c2.28-1.552 3.285-1.23 3.285-1.23c.645 1.653.24 2.873.12 3.176c.765.84 1.23 1.91 1.23 3.22c0 4.61-2.805 5.625-5.475 5.92c.42.36.81 1.096.81 2.22c0 1.606-.015 2.896-.015 3.286c0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":19,"hidden":20},"\u003Cpath fill=\"currentColor\" d=\"M20.447 20.452h-3.554v-5.569c0-1.328-.027-3.037-1.852-3.037c-1.853 0-2.136 1.445-2.136 2.939v5.667H9.351V9h3.414v1.561h.046c.477-.9 1.637-1.85 3.37-1.85c3.601 0 4.267 2.37 4.267 5.455v6.286zM5.337 7.433a2.06 2.06 0 0 1-2.063-2.065a2.064 2.064 0 1 1 2.063 2.065m1.782 13.019H3.555V9h3.564zM22.225 0H1.771C.792 0 0 .774 0 1.729v20.542C0 23.227.792 24 1.771 24h20.451C23.2 24 24 23.227 24 22.271V1.729C24 .774 23.2 0 22.222 0z\"\u002F>",true,{"id":22,"title":23,"body":24,"category":56,"comments":57,"date":58,"description":30,"excerpt":57,"extension":59,"image":57,"meta":60,"navigation":20,"path":61,"readingTime":62,"seo":63,"stem":64,"subtitle":57,"tags":65,"wordCount":70,"__hash__":71},"posts\u002F2010\u002Fautomaatne-sotsialiseerimine.md","Automaatne sotsialiseerimine",{"type":25,"value":26,"toc":52},"minimark",[27,31,34,42,45,48],[28,29,30],"p",{},"Otsustasin kirjutada programmijupi, mis minu eest \"viisakalt\" MSN-is juttu räägiks.",[28,32,33],{},"Kasutasin Ubuntut, Pidgin'it ja Python'it. Pidgini plussiks on mitme protokolli toetus ja dBus, mis asja võimalikuks teeb.",[28,35,36,37,41],{},"Tekstide genereerimisega aitas ",[38,39,40],"code",{},"solvangud.ee",", sealt sai vastused tekstifaili salvestatud. Uue sõnumi saabudes valib Python tekstifailist sobiva vastuse (tegin isegi veidi semi-semantilist võrdlemist lähtetekstiga) ning vastab minu nimel.",[28,43,44],{},"Idee: kasutada tekstifaili asemel suvalist lähtekoodifaili. Kood pole põhjalikult testitud.",[28,46,47],{},"Enne käivitamist tuleb samasse kausta teha fail solvangud.txt ning igale reale paigutada üks lause, mida robot vastama hakkab.",[49,50],"gist",{"id":51},"2656981",{"title":53,"searchDepth":54,"depth":54,"links":55},"",2,[],"Projects",null,"2010-11-09","md",{},"\u002F2010\u002Fautomaatne-sotsialiseerimine","less than 1 minute",{"title":23,"description":30},"2010\u002Fautomaatne-sotsialiseerimine",[66,67,68,69],"python","bot","dbus","pidgin",84,"5JzZLfwhm2Gy-x9yYpMi8TniZGE4t_HhSIHQR3xlazU",[73,77],{"title":74,"path":75,"stem":76,"children":-1},"Untitled, Unfinished Short Story","\u002F2010\u002Funtitled-unfinished-short-story","2010\u002Funtitled-unfinished-short-story",{"title":78,"path":79,"stem":80,"children":-1},"With great power comes great responsibility...Don't be Evil!","\u002F2010\u002Fwith-great-power-comes-great-responsibility-dont-be-evil","2010\u002Fwith-great-power-comes-great-responsibility-dont-be-evil",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":82},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"m12 19l-7-7l7-7m7 7H5\"\u002F>",{"left":4,"top":4,"width":5,"height":5,"rotate":4,"vFlip":6,"hFlip":6,"body":84},"\u003Cpath fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"round\" stroke-linejoin=\"round\" stroke-width=\"2\" d=\"M5 12h14m-7-7l7 7l-7 7\"\u002F>",{"id":86,"title":87,"body":88,"createdAt":682,"description":53,"extension":59,"files":683,"gistId":51,"meta":684,"navigation":20,"owner":685,"path":686,"seo":687,"stem":688,"url":689,"__hash__":690},"gists\u002Fgists\u002F2656981.md","This program chooses a random line from solvangud.txt and sends it as a reply to Pidgin",{"type":25,"value":89,"toc":680},[90,676],[91,92,96],"pre",{"className":93,"code":94,"filename":95,"language":66,"meta":53,"style":53},"language-python shiki shiki-themes github-light github-dark","# -*- coding: utf-8 -*-\n# This program chooses a random line from solvangud.txt and sends it as a reply to Pidgin\n# Author: Ando Roots\n\nfrom random import choice\nimport difflib\nimport sys\nimport dbus, gobject\nfrom dbus.mainloop.glib import DBusGMainLoop\nimport re\n\n# Generates and returns a new insult. If baseline is defined, some semantic searching will occur.\ndef insult_me(baseline=None):\n    file = open('solvangud.txt','r')\n    lines = file.readlines()\n    insult = []\n\n    if (baseline):\n        insult = difflib.get_close_matches(baseline, lines, cutoff=0.4)\n    if not insult:\n        return choice(lines)\n    else:\n        return '->' + choice(insult)\n    file.close()\n\n# This happens when Pidgin gets a (new) instant message\ndef new_incoming_message(account, sender, message, conversation, flags):\n\n    clean_message = StripHTML(message.encode('utf-8'))\n    msg = insult_me(clean_message)\n    purple.PurpleConvImSend(purple.PurpleConvIm(conversation), msg)\n    print sender + ' said something.'\n\n# Strip out any HTML tags found in input string\ndef StripHTML(data):\n    data = str(data)\n    p = re.compile(r'\u003C.*?>')\n    return p.sub('', data).replace('n','')\n\n# Set up the dbus listener and looping\ndbus.mainloop.glib.DBusGMainLoop(set_as_default=True)\nbus = dbus.SessionBus()\nobj = bus.get_object('im.pidgin.purple.PurpleService', '\u002Fim\u002Fpidgin\u002Fpurple\u002FPurpleObject')\npurple = dbus.Interface(obj, 'im.pidgin.purple.PurpleInterface')\n\nbus.add_signal_receiver(new_incoming_message,\n                        dbus_interface=\"im.pidgin.purple.PurpleInterface\",\n                        signal_name=\"ReceivedImMsg\")\n\nloop = gobject.MainLoop()\nloop.run()\n\n# -- End of file -- #\n","insult.py",[38,97,98,107,112,118,124,141,149,157,165,178,186,191,197,220,249,263,274,279,288,309,320,329,338,352,359,364,370,381,386,403,414,420,435,440,446,457,471,505,529,534,540,556,567,589,605,610,616,630,643,648,659,665,670],{"__ignoreMap":53},[99,100,103],"span",{"class":101,"line":102},"line",1,[99,104,106],{"class":105},"sJ8bj","# -*- coding: utf-8 -*-\n",[99,108,109],{"class":101,"line":54},[99,110,111],{"class":105},"# This program chooses a random line from solvangud.txt and sends it as a reply to Pidgin\n",[99,113,115],{"class":101,"line":114},3,[99,116,117],{"class":105},"# Author: Ando Roots\n",[99,119,121],{"class":101,"line":120},4,[99,122,123],{"emptyLinePlaceholder":20},"\n",[99,125,127,131,135,138],{"class":101,"line":126},5,[99,128,130],{"class":129},"szBVR","from",[99,132,134],{"class":133},"sVt8B"," random ",[99,136,137],{"class":129},"import",[99,139,140],{"class":133}," choice\n",[99,142,144,146],{"class":101,"line":143},6,[99,145,137],{"class":129},[99,147,148],{"class":133}," difflib\n",[99,150,152,154],{"class":101,"line":151},7,[99,153,137],{"class":129},[99,155,156],{"class":133}," sys\n",[99,158,160,162],{"class":101,"line":159},8,[99,161,137],{"class":129},[99,163,164],{"class":133}," dbus, gobject\n",[99,166,168,170,173,175],{"class":101,"line":167},9,[99,169,130],{"class":129},[99,171,172],{"class":133}," dbus.mainloop.glib ",[99,174,137],{"class":129},[99,176,177],{"class":133}," DBusGMainLoop\n",[99,179,181,183],{"class":101,"line":180},10,[99,182,137],{"class":129},[99,184,185],{"class":133}," re\n",[99,187,189],{"class":101,"line":188},11,[99,190,123],{"emptyLinePlaceholder":20},[99,192,194],{"class":101,"line":193},12,[99,195,196],{"class":105},"# Generates and returns a new insult. If baseline is defined, some semantic searching will occur.\n",[99,198,200,203,207,210,213,217],{"class":101,"line":199},13,[99,201,202],{"class":129},"def",[99,204,206],{"class":205},"sScJk"," insult_me",[99,208,209],{"class":133},"(baseline",[99,211,212],{"class":129},"=",[99,214,216],{"class":215},"sj4cs","None",[99,218,219],{"class":133},"):\n",[99,221,223,227,230,233,236,240,243,246],{"class":101,"line":222},14,[99,224,226],{"class":225},"s4XuR","    file",[99,228,229],{"class":129}," =",[99,231,232],{"class":215}," open",[99,234,235],{"class":133},"(",[99,237,239],{"class":238},"sZZnC","'solvangud.txt'",[99,241,242],{"class":133},",",[99,244,245],{"class":238},"'r'",[99,247,248],{"class":133},")\n",[99,250,252,255,257,260],{"class":101,"line":251},15,[99,253,254],{"class":133},"    lines ",[99,256,212],{"class":129},[99,258,259],{"class":225}," file",[99,261,262],{"class":133},".readlines()\n",[99,264,266,269,271],{"class":101,"line":265},16,[99,267,268],{"class":133},"    insult ",[99,270,212],{"class":129},[99,272,273],{"class":133}," []\n",[99,275,277],{"class":101,"line":276},17,[99,278,123],{"emptyLinePlaceholder":20},[99,280,282,285],{"class":101,"line":281},18,[99,283,284],{"class":129},"    if",[99,286,287],{"class":133}," (baseline):\n",[99,289,291,294,296,299,302,304,307],{"class":101,"line":290},19,[99,292,293],{"class":133},"        insult ",[99,295,212],{"class":129},[99,297,298],{"class":133}," difflib.get_close_matches(baseline, lines, ",[99,300,301],{"class":225},"cutoff",[99,303,212],{"class":129},[99,305,306],{"class":215},"0.4",[99,308,248],{"class":133},[99,310,312,314,317],{"class":101,"line":311},20,[99,313,284],{"class":129},[99,315,316],{"class":129}," not",[99,318,319],{"class":133}," insult:\n",[99,321,323,326],{"class":101,"line":322},21,[99,324,325],{"class":129},"        return",[99,327,328],{"class":133}," choice(lines)\n",[99,330,332,335],{"class":101,"line":331},22,[99,333,334],{"class":129},"    else",[99,336,337],{"class":133},":\n",[99,339,341,343,346,349],{"class":101,"line":340},23,[99,342,325],{"class":129},[99,344,345],{"class":238}," '->'",[99,347,348],{"class":129}," +",[99,350,351],{"class":133}," choice(insult)\n",[99,353,354,356],{"class":101,"line":5},[99,355,226],{"class":225},[99,357,358],{"class":133},".close()\n",[99,360,362],{"class":101,"line":361},25,[99,363,123],{"emptyLinePlaceholder":20},[99,365,367],{"class":101,"line":366},26,[99,368,369],{"class":105},"# This happens when Pidgin gets a (new) instant message\n",[99,371,373,375,378],{"class":101,"line":372},27,[99,374,202],{"class":129},[99,376,377],{"class":205}," new_incoming_message",[99,379,380],{"class":133},"(account, sender, message, conversation, flags):\n",[99,382,384],{"class":101,"line":383},28,[99,385,123],{"emptyLinePlaceholder":20},[99,387,389,392,394,397,400],{"class":101,"line":388},29,[99,390,391],{"class":133},"    clean_message ",[99,393,212],{"class":129},[99,395,396],{"class":133}," StripHTML(message.encode(",[99,398,399],{"class":238},"'utf-8'",[99,401,402],{"class":133},"))\n",[99,404,406,409,411],{"class":101,"line":405},30,[99,407,408],{"class":133},"    msg ",[99,410,212],{"class":129},[99,412,413],{"class":133}," insult_me(clean_message)\n",[99,415,417],{"class":101,"line":416},31,[99,418,419],{"class":133},"    purple.PurpleConvImSend(purple.PurpleConvIm(conversation), msg)\n",[99,421,423,426,429,432],{"class":101,"line":422},32,[99,424,425],{"class":215},"    print",[99,427,428],{"class":133}," sender ",[99,430,431],{"class":129},"+",[99,433,434],{"class":238}," ' said something.'\n",[99,436,438],{"class":101,"line":437},33,[99,439,123],{"emptyLinePlaceholder":20},[99,441,443],{"class":101,"line":442},34,[99,444,445],{"class":105},"# Strip out any HTML tags found in input string\n",[99,447,449,451,454],{"class":101,"line":448},35,[99,450,202],{"class":129},[99,452,453],{"class":205}," StripHTML",[99,455,456],{"class":133},"(data):\n",[99,458,460,463,465,468],{"class":101,"line":459},36,[99,461,462],{"class":133},"    data ",[99,464,212],{"class":129},[99,466,467],{"class":215}," str",[99,469,470],{"class":133},"(data)\n",[99,472,474,477,479,482,485,488,492,495,498,501,503],{"class":101,"line":473},37,[99,475,476],{"class":133},"    p ",[99,478,212],{"class":129},[99,480,481],{"class":133}," re.compile(",[99,483,484],{"class":129},"r",[99,486,487],{"class":238},"'",[99,489,491],{"class":490},"sA_wV","\u003C",[99,493,494],{"class":215},".",[99,496,497],{"class":129},"*?",[99,499,500],{"class":490},">",[99,502,487],{"class":238},[99,504,248],{"class":133},[99,506,508,511,514,517,520,523,525,527],{"class":101,"line":507},38,[99,509,510],{"class":129},"    return",[99,512,513],{"class":133}," p.sub(",[99,515,516],{"class":238},"''",[99,518,519],{"class":133},", data).replace(",[99,521,522],{"class":238},"'n'",[99,524,242],{"class":133},[99,526,516],{"class":238},[99,528,248],{"class":133},[99,530,532],{"class":101,"line":531},39,[99,533,123],{"emptyLinePlaceholder":20},[99,535,537],{"class":101,"line":536},40,[99,538,539],{"class":105},"# Set up the dbus listener and looping\n",[99,541,543,546,549,551,554],{"class":101,"line":542},41,[99,544,545],{"class":133},"dbus.mainloop.glib.DBusGMainLoop(",[99,547,548],{"class":225},"set_as_default",[99,550,212],{"class":129},[99,552,553],{"class":215},"True",[99,555,248],{"class":133},[99,557,559,562,564],{"class":101,"line":558},42,[99,560,561],{"class":133},"bus ",[99,563,212],{"class":129},[99,565,566],{"class":133}," dbus.SessionBus()\n",[99,568,570,573,575,578,581,584,587],{"class":101,"line":569},43,[99,571,572],{"class":133},"obj ",[99,574,212],{"class":129},[99,576,577],{"class":133}," bus.get_object(",[99,579,580],{"class":238},"'im.pidgin.purple.PurpleService'",[99,582,583],{"class":133},", ",[99,585,586],{"class":238},"'\u002Fim\u002Fpidgin\u002Fpurple\u002FPurpleObject'",[99,588,248],{"class":133},[99,590,592,595,597,600,603],{"class":101,"line":591},44,[99,593,594],{"class":133},"purple ",[99,596,212],{"class":129},[99,598,599],{"class":133}," dbus.Interface(obj, ",[99,601,602],{"class":238},"'im.pidgin.purple.PurpleInterface'",[99,604,248],{"class":133},[99,606,608],{"class":101,"line":607},45,[99,609,123],{"emptyLinePlaceholder":20},[99,611,613],{"class":101,"line":612},46,[99,614,615],{"class":133},"bus.add_signal_receiver(new_incoming_message,\n",[99,617,619,622,624,627],{"class":101,"line":618},47,[99,620,621],{"class":225},"                        dbus_interface",[99,623,212],{"class":129},[99,625,626],{"class":238},"\"im.pidgin.purple.PurpleInterface\"",[99,628,629],{"class":133},",\n",[99,631,633,636,638,641],{"class":101,"line":632},48,[99,634,635],{"class":225},"                        signal_name",[99,637,212],{"class":129},[99,639,640],{"class":238},"\"ReceivedImMsg\"",[99,642,248],{"class":133},[99,644,646],{"class":101,"line":645},49,[99,647,123],{"emptyLinePlaceholder":20},[99,649,651,654,656],{"class":101,"line":650},50,[99,652,653],{"class":133},"loop ",[99,655,212],{"class":129},[99,657,658],{"class":133}," gobject.MainLoop()\n",[99,660,662],{"class":101,"line":661},51,[99,663,664],{"class":133},"loop.run()\n",[99,666,668],{"class":101,"line":667},52,[99,669,123],{"emptyLinePlaceholder":20},[99,671,673],{"class":101,"line":672},53,[99,674,675],{"class":105},"# -- End of file -- #\n",[677,678,679],"style",{},"html pre.shiki code .sJ8bj, html code.shiki .sJ8bj{--shiki-default:#6A737D;--shiki-dark:#6A737D}html pre.shiki code .szBVR, html code.shiki .szBVR{--shiki-default:#D73A49;--shiki-dark:#F97583}html pre.shiki code .sVt8B, html code.shiki .sVt8B{--shiki-default:#24292E;--shiki-dark:#E1E4E8}html pre.shiki code .sScJk, html code.shiki .sScJk{--shiki-default:#6F42C1;--shiki-dark:#B392F0}html pre.shiki code .sj4cs, html code.shiki .sj4cs{--shiki-default:#005CC5;--shiki-dark:#79B8FF}html pre.shiki code .s4XuR, html code.shiki .s4XuR{--shiki-default:#E36209;--shiki-dark:#FFAB70}html pre.shiki code .sZZnC, html code.shiki .sZZnC{--shiki-default:#032F62;--shiki-dark:#9ECBFF}html pre.shiki code .sA_wV, html code.shiki .sA_wV{--shiki-default:#032F62;--shiki-dark:#DBEDFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}html.dark .shiki span {color: var(--shiki-dark);background: var(--shiki-dark-bg);font-style: var(--shiki-dark-font-style);font-weight: var(--shiki-dark-font-weight);text-decoration: var(--shiki-dark-text-decoration);}",{"title":53,"searchDepth":54,"depth":54,"links":681},[],"2012-05-11T01:42:39Z",[95],{},"anroots","\u002Fgists\u002F2656981",{"title":87,"description":53},"gists\u002F2656981","https:\u002F\u002Fgist.github.com\u002Fanroots\u002F2656981","SUrqhRDDZqML5zgK4ky_zYm1rcOXUnjDrg3wUp1WI6Y",1790886933813]