2016-12-02 07:38:54 +00:00
|
|
|
package main
|
|
|
|
import "strings"
|
2017-01-05 14:41:14 +00:00
|
|
|
import "regexp"
|
2016-12-02 07:38:54 +00:00
|
|
|
|
|
|
|
type Page struct
|
2016-12-18 12:56:06 +00:00
|
|
|
{
|
|
|
|
Title string
|
|
|
|
CurrentUser User
|
2017-01-17 07:55:46 +00:00
|
|
|
NoticeList []string
|
2016-12-18 12:56:06 +00:00
|
|
|
ItemList []interface{}
|
|
|
|
Something interface{}
|
|
|
|
}
|
|
|
|
|
2016-12-21 02:30:32 +00:00
|
|
|
type TopicPage struct
|
2016-12-02 07:38:54 +00:00
|
|
|
{
|
|
|
|
Title string
|
|
|
|
CurrentUser User
|
2017-01-17 07:55:46 +00:00
|
|
|
NoticeList []string
|
2016-12-21 02:30:32 +00:00
|
|
|
ItemList []Reply
|
|
|
|
Topic TopicUser
|
2017-01-21 18:16:27 +00:00
|
|
|
Page int
|
|
|
|
LastPage int
|
2016-12-21 02:30:32 +00:00
|
|
|
ExtData interface{}
|
2016-12-02 07:38:54 +00:00
|
|
|
}
|
|
|
|
|
2017-01-01 15:45:43 +00:00
|
|
|
type TopicsPage struct
|
|
|
|
{
|
|
|
|
Title string
|
|
|
|
CurrentUser User
|
2017-01-17 07:55:46 +00:00
|
|
|
NoticeList []string
|
2017-01-01 15:45:43 +00:00
|
|
|
ItemList []TopicUser
|
|
|
|
ExtData interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ForumPage struct
|
|
|
|
{
|
|
|
|
Title string
|
|
|
|
CurrentUser User
|
2017-01-17 07:55:46 +00:00
|
|
|
NoticeList []string
|
2017-01-01 15:45:43 +00:00
|
|
|
ItemList []TopicUser
|
2017-01-26 13:37:50 +00:00
|
|
|
Forum Forum
|
|
|
|
Page int
|
|
|
|
LastPage int
|
2017-01-01 15:45:43 +00:00
|
|
|
ExtData interface{}
|
|
|
|
}
|
|
|
|
|
|
|
|
type ForumsPage struct
|
|
|
|
{
|
|
|
|
Title string
|
|
|
|
CurrentUser User
|
2017-01-17 07:55:46 +00:00
|
|
|
NoticeList []string
|
2017-01-01 15:45:43 +00:00
|
|
|
ItemList []Forum
|
|
|
|
ExtData interface{}
|
|
|
|
}
|
|
|
|
|
2016-12-26 04:44:07 +00:00
|
|
|
type ProfilePage struct
|
|
|
|
{
|
|
|
|
Title string
|
|
|
|
CurrentUser User
|
2017-01-17 07:55:46 +00:00
|
|
|
NoticeList []string
|
2016-12-26 04:44:07 +00:00
|
|
|
ItemList []Reply
|
|
|
|
ProfileOwner User
|
|
|
|
ExtData interface{}
|
|
|
|
}
|
|
|
|
|
2016-12-05 07:21:17 +00:00
|
|
|
type PageSimple struct
|
|
|
|
{
|
|
|
|
Title string
|
|
|
|
Something interface{}
|
|
|
|
}
|
|
|
|
|
2016-12-06 10:26:48 +00:00
|
|
|
type AreYouSure struct
|
|
|
|
{
|
|
|
|
URL string
|
|
|
|
Message string
|
|
|
|
}
|
|
|
|
|
2017-01-05 14:41:14 +00:00
|
|
|
var urlpattern string = `(?s)([ {1}])((http|https|ftp|mailto)*)(:{??)\/\/([\.a-zA-Z\/]+)([ {1}])`
|
|
|
|
var url_reg *regexp.Regexp
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
url_reg = regexp.MustCompile(urlpattern)
|
|
|
|
}
|
|
|
|
|
2016-12-08 14:11:18 +00:00
|
|
|
func shortcode_to_unicode(msg string) string {
|
|
|
|
//re := regexp.MustCompile(":(.):")
|
|
|
|
msg = strings.Replace(msg,":grinning:","😀",-1)
|
|
|
|
msg = strings.Replace(msg,":grin:","😁",-1)
|
|
|
|
msg = strings.Replace(msg,":joy:","😂",-1)
|
|
|
|
msg = strings.Replace(msg,":rofl:","🤣",-1)
|
|
|
|
msg = strings.Replace(msg,":smiley:","😃",-1)
|
|
|
|
msg = strings.Replace(msg,":smile:","😄",-1)
|
|
|
|
msg = strings.Replace(msg,":sweat_smile:","😅",-1)
|
|
|
|
msg = strings.Replace(msg,":laughing:","😆",-1)
|
|
|
|
msg = strings.Replace(msg,":satisfied:","😆",-1)
|
|
|
|
msg = strings.Replace(msg,":wink:","😉",-1)
|
|
|
|
msg = strings.Replace(msg,":blush:","😊",-1)
|
|
|
|
msg = strings.Replace(msg,":yum:","😋",-1)
|
|
|
|
msg = strings.Replace(msg,":sunglasses:","😎",-1)
|
|
|
|
msg = strings.Replace(msg,":heart_eyes:","😍",-1)
|
|
|
|
msg = strings.Replace(msg,":kissing_heart:","😘",-1)
|
|
|
|
msg = strings.Replace(msg,":kissing:","😗",-1)
|
|
|
|
msg = strings.Replace(msg,":kissing_smiling_eyes:","😙",-1)
|
|
|
|
msg = strings.Replace(msg,":kissing_closed_eyes:","😚",-1)
|
|
|
|
msg = strings.Replace(msg,":relaxed:","☺️",-1)
|
|
|
|
msg = strings.Replace(msg,":slight_smile:","🙂",-1)
|
|
|
|
msg = strings.Replace(msg,":hugging:","🤗",-1)
|
|
|
|
msg = strings.Replace(msg,":thinking:","🤔",-1)
|
|
|
|
msg = strings.Replace(msg,":neutral_face:","😐",-1)
|
|
|
|
msg = strings.Replace(msg,":expressionless:","😑",-1)
|
|
|
|
msg = strings.Replace(msg,":no_mouth:","😶",-1)
|
|
|
|
msg = strings.Replace(msg,":rolling_eyes:","🙄",-1)
|
|
|
|
msg = strings.Replace(msg,":smirk:","😏",-1)
|
|
|
|
msg = strings.Replace(msg,":persevere:","😣",-1)
|
|
|
|
msg = strings.Replace(msg,":disappointed_relieved:","😥",-1)
|
|
|
|
msg = strings.Replace(msg,":open_mouth:","😮",-1)
|
|
|
|
msg = strings.Replace(msg,":zipper_mouth:","🤐",-1)
|
|
|
|
msg = strings.Replace(msg,":hushed:","😯",-1)
|
|
|
|
msg = strings.Replace(msg,":sleepy:","😪",-1)
|
|
|
|
msg = strings.Replace(msg,":tired_face:","😫",-1)
|
|
|
|
msg = strings.Replace(msg,":sleeping:","😴",-1)
|
|
|
|
msg = strings.Replace(msg,":relieved:","😌",-1)
|
|
|
|
msg = strings.Replace(msg,":nerd:","🤓",-1)
|
2016-12-13 02:14:14 +00:00
|
|
|
msg = strings.Replace(msg,":stuck_out_tongue:","😛",-1)
|
|
|
|
return msg
|
2016-12-08 14:11:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func preparse_message(msg string) string {
|
2016-12-13 02:14:14 +00:00
|
|
|
if hooks["preparse_preassign"] != nil {
|
|
|
|
out := run_hook("preparse_preassign", msg)
|
|
|
|
msg = out.(string)
|
|
|
|
}
|
2016-12-08 14:11:18 +00:00
|
|
|
return shortcode_to_unicode(msg)
|
2016-12-03 08:09:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func parse_message(msg string) string {
|
2016-12-08 14:11:18 +00:00
|
|
|
msg = strings.Replace(msg,":)","😀",-1)
|
|
|
|
msg = strings.Replace(msg,":D","😃",-1)
|
2016-12-08 14:24:19 +00:00
|
|
|
msg = strings.Replace(msg,":P","😛",-1)
|
2017-01-05 14:41:14 +00:00
|
|
|
msg = url_reg.ReplaceAllString(msg,"<a href=\"$2$3//$4\" rel=\"nofollow\">$2$3//$4</a>")
|
2016-12-13 02:14:14 +00:00
|
|
|
msg = strings.Replace(msg,"\n","<br>",-1)
|
|
|
|
if hooks["parse_assign"] != nil {
|
|
|
|
out := run_hook("parse_assign", msg)
|
|
|
|
msg = out.(string)
|
|
|
|
}
|
|
|
|
return msg
|
2016-12-02 07:38:54 +00:00
|
|
|
}
|